This may be a really simple question, but its one I can't seem to get and am tearing my hair out over. I have the following XML:
<?xml-stylesheet type="text/xsl" href="email.xsl"?>
<Example xmlns="">
<Name xmlns="urn:rnb.fulfilment.bus.contracts.public.exampleBookName.v1">Mark</Name>
</Example>
And am trying to use the following XSLT:
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:template match="/">
<html>
<body>
<table width="90%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<p>AUTOMATED CONFIRMATION: This confirmation email is unable to take replies. For further assistance please visit our Help pages or Contact us</p>
<p>Dear <xsl:value-of select="Name"/>,</p>
<p>Thank you for blah blah... </p>
</td>
</tr>
</table>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
I cannot get the Name to appear when I am using the xmlns=urn:rnb.fulfilment.bus.contracts.public.exampleBookName.v1
in the XML feed, when I remove the xmlns
, the name displays fine.
Is there some syntax I'm missing? I've tried adding the namespace to the <xsl:stylesheet>
element:
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:rpg="urn:rnb.fulfilment.bus.contracts.public.exampleBookName.v1"
>
Then using the prefix I gave to the XSLT in the XPath expression:
<xsl:value-of select="Name"/>
But this doesn't work either. Can anyone help? Thanks in advance.
Your approach with declaring the namespace at <xsl:stylesheet>
was the right direction already. Now all you got to do is use the prefix also:
<xsl:value-of select="Example/rpg:Name" />
I further recommend a tiny change to your template to better reflect your input:
<xsl:template match="Example">
<!-- ... -->
<xsl:value-of select="rpg:Name" />
</xsl:template>
You need to use the same namespace in the XSLT so that the XPath expression for Name
matches.
<xsl:value-of select="x:Name" xmlns:x="urn:rnb.fulfilment.bus.contracts.public.exampleBookName.v1"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With