I am doing a very simple xslt to convert a html page to a xml file.
But it appears to me that the starting point is not that straightforward to me.My first goal is t
The purpose of XSLT is to transform XML documents into other XML documents. HTML is not a XML document. While XHTML is XML, it is actually HTML reformulated so I'm just not sure what you want to do is easy or possible with XSLT.
You may want to try to remove the first template or make it more specific than matching every node with node()
.
XSLT 1.0:
Try adding xmlns:x="http://www.w3.org/1999/xhtml"
to your xsl:stylesheet
and changing your match to match="x:html"
. (Note: you don't have to use "x"; you can choose anything you want.)
XSLT 2.0:
Either use the above method or replace the namespace prefix in your match(es) to "*" (match="*:html"
). You could also add xpath-default-namespace="http://www.w3.org/1999/xhtml"
to the xsl:stylesheet
.