XSLT and XQuery on invalid html input, URI fragments look like objects

I am using Saxon 9 to parse invalid html sources. In particular, html has href values ​​like:

<a href = "blah.asp? fn = view & g_varID = 1234"> some text </a>

I am getting errors:

"Error reported by XML parser: object reference" g_varID "must end with ';' Separator".

The xml parser reads the string "& g_varID" and complains that there should be a ";" to delineate an object. But of course this is not intended as an HTML entity - it is just a snippet of a URI.

How can I make the parser ignore it? Note. I am using non-competitive Saxon, not Saxon-SA.

0


a source to share


3 answers


Make sure you have the correct xhtml DOCTYPE. As per the xhtml1-strict.dtd I'm looking at, the href attribute is declared as CDATA, not PCDATA, which means literal and perfectly fine and shouldn't be parsed as an entity.



+1


a source


If your HTML is not XML, then how do you expect some XML processor to process it?



+3


a source


As mentioned above, this is invalid XML, this is HTML. However, this particular issue is that the default HTML is cleared: http://www.w3.org/People/Raggett/tidy/ . Use it with the following command line arguments to convert HTML to XHTML:

tidy -asxhtml foo.html > foo.xhtml

      

And then you should be able to run it through your XSLT.

0


a source







All Articles