using XPATH over namespaces
Posted: Tue Aug 09, 2005 3:55 pm
Hi @ll.
I have an XPATH-Problem I am going to lose my hair about ):
In this example:
#XML
#XSLT
Here the output is correctly and expectedly: BOAH EY EY!
However in the Real World(tm) case below, the XML contains namespaces and I just can't get the stylesheet to work correctly. It must produce the same output as above, but just outputs "BOAH!".
#XML
#XSLT
Please help, this is production critical and I am lost.
I have an XPATH-Problem I am going to lose my hair about ):
In this example:
#XML
Code: Select all
<?xml version="1.0" encoding="ISO-8859-1"?>
<ehd>
<body>
<gnr_liste>
<gnr V="01100" USE="74" USE-DOMAIN="1.2.276.0.76.5.233" />
<gnr V="01101" USE="74" USE-DOMAIN="1.2.276.0.76.5.233" />
</gnr_liste>
</body>
</ehd>
Code: Select all
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:strip-space elements="*"/>
<xsl:output method="text" encoding="ISO-8859-1" />
<xsl:template match="/ehd">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="body">
<xsl:text>BOAH</xsl:text>
<xsl:apply-templates />
<xsl:text>!</xsl:text>
</xsl:template>
<xsl:template match="gnr_liste/gnr">
<xsl:text> EY</xsl:text>
</xsl:template>
</xsl:stylesheet>
However in the Real World(tm) case below, the XML contains namespaces and I just can't get the stylesheet to work correctly. It must produce the same output as above, but just outputs "BOAH!".
#XML
Code: Select all
<?xml version="1.0" encoding="ISO-8859-1"?>
<ehd:ehd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:ehd/go/001" xmlns:ehd="urn:ehd/001" ehd_version="1.20">
<ehd:body>
<gnr_liste>
<gnr V="01100" USE="74" USE-DOMAIN="1.2.276.0.76.5.233" />
<gnr V="01101" USE="74" USE-DOMAIN="1.2.276.0.76.5.233" />
</gnr_liste>
</ehd:body>
</ehd:ehd>
Code: Select all
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ehd="urn:ehd/001">
<xsl:strip-space elements="*"/>
<xsl:output method="text" encoding="ISO-8859-1" />
<xsl:template match="/ehd:ehd">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="ehd:body">
<xsl:text>BOAH</xsl:text>
<xsl:apply-templates />
<xsl:text>!</xsl:text>
</xsl:template>
<xsl:template match="gnr_liste/gnr">
<xsl:text> EY</xsl:text>
</xsl:template>
</xsl:stylesheet>