Wednesday, 21 August 2013

XSLT on XML with Namespaces

XSLT on XML with Namespaces

I am stuck trying to transform xml with namepsaces using xsl. Here are my
files. As you can see, I am trying multiple xpath options in the xsl
document. I get no errors, only a blank document. I have been researching
for an hour without any luck. Thanks in advance for any assistance!
sample.xml:
<?xml-stylesheet type="text/xsl" href="sample.xsl"?>
<POCollection xmlns:ns1="http://www.a.com/PurchaseOrder/1.0"
xmlns="http://www.a.com/PurchaseOrder/1.0">
<ns1:PurchaseOrder>
<ns1:PurchaseOrderHeader>
<ns1:OUAddressLine1>123 Test Street</ns1:OUAddressLine1>
</ns1:PurchaseOrderHeader>
</ns1:PurchaseOrder>
</POCollection>
sample.xsl:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:ns1="http://www.nsl.ns/"
xmlns:d="http://www.default.ns/"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:value-of
select="/d:POCollection/ns1:PurchaseOrder/ns1:PurchaseOrderHeader/ns1:OUAddressLine1"
/>
<xsl:value-of
select="/ns1:PurchaseOrder/ns1:PurchaseOrderHeader/ns1:OUAddressLine1"
/>
<xsl:value-of
select="/POCollection/ns1:PurchaseOrder/ns1:PurchaseOrderHeader/ns1:OUAddressLine1"
/>
<xsl:value-of
select="/POCollection/PurchaseOrder/PurchaseOrderHeader/OUAddressLine1"
/>
<xsl:value-of select="//OUAddressLine1" />
</xsl:template>
</xsl:stylesheet>

No comments:

Post a Comment