Five Stars

tXmlMap : use variable in namespace

Hi,

 

Is it possible to have dynamical namespace in tXmlMap componant ? The setAsAnamesapce property seems to always used as s litteral string.

 

 

pat

1 ACCEPTED SOLUTION

Accepted Solutions
Moderator

Re: tXmlMap : use variable in namespace

Hi,

Please feel free to create a new feature jira issue on talend bug tracker.

https://jira.talendforge.org/secure/Dashboard.jspa

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
4 REPLIES
Moderator

Re: tXmlMap : use variable in namespace

Hi,

Please feel free to create a new feature jira issue on talend bug tracker.

https://jira.talendforge.org/secure/Dashboard.jspa

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Five Stars

Re: tXmlMap : use variable in namespace

Thks Sabrina, I will do it. I have applied a work around with a tJava that modify Dom NameSpace before tXmlMapCall
Moderator

Re: tXmlMap : use variable in namespace

Hi,

Thanks for your feedback. Could you please share your work around tjava on forum?

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Five Stars

Re: tXmlMap : use variable in namespace

Capture.PNGCapture2.PNG

 

 

WS mapping in TXmlMap6 is done without specify nameSpaces, nameSpaces are set by prepareInsertion.

 

prepareInsertion : set nodes NameSpace with two NameSpaces stored in variables : context.productDelayServicesSONS and context.productDelayServiceBPMLeadtimefileNS

-----------------------

 

org.dom4j.Document document = ((routines.system.Document)input_row.payload).getDocument();
org.dom4j.Element root = document.getRootElement();
// treat context node
org.dom4j.Element elementContext = root.element("context");
elementContext.add(new org.dom4j.Namespace(null, context.productDelayServicesSONS));
// treat domainObject node
elementContext = root.element("domainObject");
elementContext.add(new org.dom4j.Namespace(null, context.productDelayServiceBPMLeadtimefileNS));

output_row.payload = input_row.payload;

 

alignResponse :clear WS response namespaces to treat them in new WS call

--------------------

 

org.dom4j.Document document2 = ((routines.system.Document)input_row.payload).getDocument();
org.dom4j.Element root2 = document2.getRootElement();


org.dom4j.Namespace ns = root2.getNamespace();

List<org.dom4j.Element> elementLst = root2.elements();
for (int i=0,l=elementLst.size();i<l;i++)
{
    elementLst.get(i).setQName(new org.dom4j.QName(elementLst.get(i).getName(), org.dom4j.Namespace.NO_NAMESPACE,     elementLst.get(i).getQualifiedName()));
    elementLst.get(i).setQName(org.dom4j.QName.get(elementLst.get(i).getName(), (String)null, (String)null));
    ns = elementLst.get(i).getNamespaceForPrefix("tns");
    
    List<org.dom4j.Element> elementLst2 = elementLst.get(i).elements();
    if (elementLst2!=null)
    {
        for (int j=0,k=elementLst2.size();j<k;j++)
        {

            elementLst2.get(j).setQName(new org.dom4j.QName(elementLst2.get(j).getName(), org.dom4j.Namespace.NO_NAMESPACE, elementLst2.get(j).getQualifiedName()));
            elementLst2.get(j).setQName(org.dom4j.QName.get(elementLst2.get(j).getName(), (String)null, (String)null));
    
        }
    }
    
}
output_row.payload = input_row.payload;