I am trying to transform a string with xml data (response from a web service). I tried to start simple by just getting the name:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<table>
<tr>
<th>Name</th>
</tr>
<xsl:for-each select="soap:Envelope/soap:Body/ABRSearchByABNResponse/ABRPayloadSearchResults/response/legalName/">
<tr>
<td>
<xsl:value-of select="givenName"/>
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
However, I get "prefix 'soap' is not defined", how do I fix this? Thanks.
In XSLT any namespace prefix used in an XPath expression must be defined in a corresponding namespace declaration.
This is not the case with your code and hence the error.
Solution:
Declare the soap namespace:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:soap="http://soap/envelope/"
>
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