Unanswered How to avoid namespaces from xml with the help of xslt

  • Monday, February 18, 2013 7:52 AM
     
      Has Code

    I have this xml

    <BPEL_MaximoOrg1ProcessResponse xmlns="http://MaximoProcess.bpel"> <result>  <MXORGANIZATIONSet>   <ORGANIZATION>    <COMPANYSETID>APEK</COMPANYSETID>    <DESCRIPTION_LONGDESCRIPTION></DESCRIPTION_LONGDESCRIPTION>    <ENTERBY>313096</ENTERBY>    <ENTERDATE>2013-01-24T17:44:31+05:30</ENTERDATE>    <ITEMSETID>AJ</ITEMSETID>    <ORGANIZATIONID>7</ORGANIZATIONID>    <ORGID>AJORG</ORGID>   </ORGANIZATION>  </MXORGANIZATIONSet> </result></BPEL_MaximoOrg1ProcessResponse>

    I want <COMPANYSETID>APEK<COMPANYSETID>  from this xml in out.xml,but i cant overcome the namespace that is why the desired result is not coming.

    please help me to get out of this..

    Thanks

All Replies

  • Thursday, February 21, 2013 12:37 PM
     
     

    One method could be this:

    <?xml version="1.0" encoding="utf-16"?>
    <xsl:stylesheet version="1.0" exclude-result-prefixes="source" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:source="http://MaximoProcess.bpel">
      <xsl:template match="source:BPEL_MaximoOrg1ProcessResponse">
        <Destination>
          <COMPANYSETID>
            <xsl:value-of select="source:result/source:MXORGANIZATIONSet/source:ORGANIZATION/source:COMPANYSETID" />
          </COMPANYSETID>
        </Destination>
      </xsl:template>
    </xsl:stylesheet>

    If you simply want XPath to be able to ignore namespaces you can you this syntax:

    <?xml version="1.0" encoding="utf-16"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:template match="/">
        <Destination>
          <COMPANYSETID>
            <xsl:value-of select="//*[local-name() = 'COMPANYSETID']" />
          </COMPANYSETID>
        </Destination>
      </xsl:template>
    </xsl:stylesheet>

    Morten la Cour