Getting "prefix" soap "not defined" in xslt file

I am trying to convert a string with xml data (response from web service). I tried to start simply by simply 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 a "prefix" soap "not defined", how can I fix it? Thanks.

+6
html xml xslt
source share
2 answers

In XSLT, any namespace prefix used in an XPath expression must be defined in the corresponding namespace declaration.

This does not apply to your code and therefore to error.

Decision

Declare a 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/" > 
+5
source share

The soap namespace prefix in your case is simply a shorthand for the real namespace URI. To avoid using http://soap/envelope/ everywhere, you can define once when soap means http://soap/envelope/ , and use soap in the rest of the document.

This means that if you use a namespace prefix, you must define it so that you can find the real namespace.

You can also declare that pizza matches http://soap/envelope/ and use this instead. The soap space prefix is ​​not special.

0
source share

All Articles