XML parsing issues with XSL in it

When I try to read my xml from a web page, I get: "Error: on line 8, column 23: unbound prefix" Below is my xml:

<?xml version="1.0"?> <outertag> <innertag sampleattribute="innertagAttribute"> <Retailer> RetailerName: <xsl:template match="link"> <a href="LinkGoesHere">Link</a> </xsl:template> </Retailer> </innertag> 

Any ideas on what's wrong? Can i use xsl: template inside my xml? Any help is appreciated.

+4
source share
1 answer

When I try to read my xml from a web page, I get: "Error: on line 8, column 23: unbound prefix" Below is my XML:

 <?xml version="1.0"?> <outertag> <innertag sampleattribute="innertagAttribute"> <Retailer>RetailerName: <xsl:template match="link"> <a href="LinkGoesHere">Link</a> </xsl:template> </Retailer> </innertag> </outertag> 

Any ideas on what's wrong? Can I not use xsl: template inside my xml?

The submitted document is not correct and the error message says very well what the reason is:

There is an element named xsl:template , but there is no namespace declaration in the entire document that associates the xsl: prefix with any namespace.

Decision

Correct the malformed text into a well-formed XML document by providing a namespace declaration for the XSLT namespace:

 <outertag> <innertag sampleattribute="innertagAttribute"> <Retailer>RetailerName: <xsl:template match="link" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <a href="LinkGoesHere">Link</a> </xsl:template> </Retailer> </innertag> </outertag> 
+4
source

Source: https://habr.com/ru/post/1336655/


All Articles