GNOME Bugzilla – Bug 158553
Non-standard behavior on invalid XPath
Last modified: 2009-08-15 18:40:50 UTC
Please describe the problem: In an XSLT sheet with: <xsl:template match="/"> <xsl:template match="@id=''" /> </xsl:template> xsltproc silently exits, printing: xsltApplyOneTemplate: template was not compiled Which is rather cryptic and internal(I can't tell what's wrong). I would like to know /where/ "it" was wrong(file, line number), and /what/ was wrong with the XPath. Also, I don't know if it's even valid XPath(it selects attribute nodes from the current node that are empty?), but in case it isn't, I guess xsltproc should stop processing. Another thing: I managed to misspell the xml processing instruction, and xsltproc didn't barf: <?uxml version="1.0" encoding="UTF-8" ?>. Should XML processors silently accept processing instructions they don't understand? Cheers, Frans Steps to reproduce: Actual results: Expected results: Does this happen every time? Other information:
for point 1/ template is not compiled because it is not a child of the stylesheet element. This is a duplicate of bug #153094 your stylesheet is broken but the compilation process did not detect it it should have failed to compile it in the first place. The XPath expression is not wrong, it's the englobing template construct which is. => Duplicate of #153094 for point 2/ - <?xml ... is an XML Declaration. This is *not* a Processing Instruction. - Processing Instructions can perfectly be placed at the top of a document. and an XML Declaration is not mandatory - the XML parser doesn't do any semantic processing for markup constructs that it doesn't know, this is true for name occuring everywhere in element, attributes, PIs. The only thing is that name starting with xml (case insensitive) are reserved for W3C XML specifications. => NOTABUG Daniel *** This bug has been marked as a duplicate of 153094 ***
Sorry for the bogus report, and thanks for telling about XML declarations. Frans
no problem see the following for the reference: http://www.w3.org/TR/REC-xml/#NT-XMLDecl Daniel
<?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="@id=''"/> <xsl:template match="/" /> </xsl:stylesheet> If I run this with ` xsltproc test.xsl`(no document) I get: bash-2.05b$ xsltproc test.xsl compilation error: file test.xsl line 5 element template xsltCompilePattern : failed to compile '@id=''' bash-2.05b$ I can't tell what's wrong, but you said the XPath was ok, so what is done wrong? Cheers, Frans
A pattern match allows only a *subset* of the full XPath syntax http://www.w3.org/TR/xslt#NT-Pattern For XSLT and XPath it is worth reading the specs, it's not XML Schemas Structure, one can actually find the information there. The fact that libxslt failed to compile '@id=''' sounds relatively clear to me. Daniel
This should be closed by release of libxslt-1.1.15 thanks, Daniel