IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.



#Automation


#Applicationintegration
#webMethods
#Integration
 View Only
Expand all | Collapse all

Querying an XML node which has only localname and xmlns declared to it.

  • 1.  Querying an XML node which has only localname and xmlns declared to it.

    Posted 03/17/16 03:13 AM

    Hi,
    I have a requirement to query an xml which of the below format

    <root xmlns:xsi=<> xmlns:xsd=<> xmlns:

    value1
    value2

    the requirement is to fetch the value of key1. The way I followed is, I got the rootLocalName of xml and prepared an XPath to query the node like this
    /%rootLocalName%/parent1/key1

    but, the query gave me null results.
    Can some one help me on this?

    BestRegards,
    SasikalaVinay


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 2.  RE: Querying an XML node which has only localname and xmlns declared to it.

    Posted 03/17/16 07:27 AM

    Hi Sasikala,

    do you have the DocType representation available in your IS (i.e. created from a XSD)?

    Then you can just right click on the field in the pipelina and select “copy”.
    This can be pasted into the query field.

    Regards,
    Holger


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 3.  RE: Querying an XML node which has only localname and xmlns declared to it.

    Posted 03/17/16 08:14 AM

    Hi Holger,

    Firstly thanks for your reply!

    I didn’t have DocType for this. The original requirement was with prefix and now, user come up with additional requirement that the service should serve the xmls without rootPrefix.

    I have seen many posts saying that it is difficult to query a node with defaultNamespace. But, I have to get it done without disturbing the input xml root tag.

    Please suggest me way to do it.

    Regards,
    SasikalaVinay


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 4.  RE: Querying an XML node which has only localname and xmlns declared to it.

    Posted 03/17/16 09:07 AM

    [color=blue]Hi Sasikala,

    You mean to say that Root Tag of the XML received can change during run time?

    Whether this path parent1/key1 is unchanged?[/color]

    -Ambrish-


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 5.  RE: Querying an XML node which has only localname and xmlns declared to it.

    Posted 03/17/16 01:32 PM

    Hi Sasikala,

    can you provide a screenshot of your flow implementation?

    You should try to get the XSD for this XML message from the partner as this will ease development a lot.

    Regards,
    Holger


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 6.  RE: Querying an XML node which has only localname and xmlns declared to it.

    Posted 03/18/16 03:49 AM

    Hi Holger,

    sorry, I can’t provide screenshot of the XML.

    Hi Ambrish,

    No, my requirement is to write an xPath to query an XML Node which has default namespace.

    The rootLocalName (root tag) and the child tags will remain same for a given input.

    BestRegards,
    SasikalaVinay.


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 7.  RE: Querying an XML node which has only localname and xmlns declared to it.

    Posted 03/18/16 08:41 AM

    Hi Sasikala,

    then your xpath should be “/root/parent1/key1”.

    Regards,
    Holger


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 8.  RE: Querying an XML node which has only localname and xmlns declared to it.

    Posted 03/18/16 08:43 AM

    Hi Holger,

    That Xpath is not working, it is fetching me null values. I have tried this option as well :frowning:

    Regards,
    SasikalaVinay


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 9.  RE: Querying an XML node which has only localname and xmlns declared to it.

    Posted 03/18/16 10:50 AM

    Hi Sasikala,

    I did some research meanwhile.

    Hopefully your XML is welformed (only one node with name root after the <?xml>-Tag).

    Here are some options to try:

    • /*/parent1/key1
    • parent1/key1

    Did you try to specify the namespace in the nsDecls-Parameter?

    BTW:
    Which QueryLanguage are you using?
    WQL or XQL?
    Usually the XQL should be preferred over WQL.

    If this does not help, please provide a screenshot of pub.xml:queryXMLNode step.

    Regards,
    Holger


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 10.  RE: Querying an XML node which has only localname and xmlns declared to it.

    Posted 03/18/16 12:16 PM

    XQL is preferred way and yes please upload the screenshot clearly the settings you are inputting to queryXMLNode service.

    Attach the test XML also if possible.

    HTH,
    RMG


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 11.  RE: Querying an XML node which has only localname and xmlns declared to it.

    Posted 03/21/16 01:16 AM

    Hi all,

    Thanks for your suggestion and reply.

    I have got the query executed using the below format to fetch the values from XML.

    //:parent1/:key1

    It works for both scenarios, with and without prefix.

    BestRegards,
    SasikalaVinay.


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 12.  RE: Querying an XML node which has only localname and xmlns declared to it.

    Posted 03/21/16 10:25 AM

    Glad to hear you were able to resolve it with the syntax above :smiley:

    Cheers!
    RMG


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 13.  RE: Querying an XML node which has only localname and xmlns declared to it.

    Posted 03/21/16 11:52 AM

    Hi Sasikala,

    I agree with RMG.

    Luckily you have figured out the correct query.

    As there was never a sample xml structure with namespaceprefix present inside the tags we might have been looking in the wrong direction sometimes.

    As there different types of presentations of xml messages regarding the presence or absence of namespace prefixes this can be confusing when not knowing all occuring variants.

    1. All elements have prefixes
    2. No element does have a prefix
    3. Only the root element does have a prefix
      This depends on how xsd are composed/cascaded with namespaces defined and if they define elementFormQualified as true or false.

    In my project I have observed all 3 types of messages for different interfaces causing more or less trouble when importing them into the IS as well as constructing test and reference data for testing them on either 7.1 or 9.5.

    Regards,
    Holger


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 14.  RE: Querying an XML node which has only localname and xmlns declared to it.

    Posted 03/21/16 11:47 PM