XPath Problem in XHTML Files
Posted: Sun Nov 23, 2003 8:11 pm
I've been trying to transform some valid XHTML strict files using XSLT.
In straight edit mode, if I include a DOCTYPE declaration (whether the local Oxygen version or the online W3C one) the transformation does not work as I would anticipate (whether I use Saxon or Xalan) and I get some odd results in the XPath console.
When the DOCTYPE is declared, the XPath query "/html" gets me a dialog box informing me that "The XPath query returned no results". If I remove the DOCTYPE declaration, the query gives me the html element as one would expect. Further, regardless of DOCTYPE presence or absence, the same query in Tree Editor mode gives me the html element.
However, the presence of the DOCTYPE does not entirely cripple XPath. So a query of "//*" returns all elements and a query of "//@href" returns all href attributes. So the odd result seems to apply only when I query for elements by name and seems not to apply to attributes.
My desire for DOCTYPEs is not just HTML snobbery, but has real world implicatons for me, since DOCTYPEs are important for persuading the Explorer 6 browser to act no more foolish about CSS than it has to.
Is this an XHTML thing, an XSLT thing, a parser thing or an Oxygen thing? Is there a workaround that would allow me to keep my DOCTYPEs?
Thanks in advance for any help you can give.
In straight edit mode, if I include a DOCTYPE declaration (whether the local Oxygen version or the online W3C one) the transformation does not work as I would anticipate (whether I use Saxon or Xalan) and I get some odd results in the XPath console.
When the DOCTYPE is declared, the XPath query "/html" gets me a dialog box informing me that "The XPath query returned no results". If I remove the DOCTYPE declaration, the query gives me the html element as one would expect. Further, regardless of DOCTYPE presence or absence, the same query in Tree Editor mode gives me the html element.
However, the presence of the DOCTYPE does not entirely cripple XPath. So a query of "//*" returns all elements and a query of "//@href" returns all href attributes. So the odd result seems to apply only when I query for elements by name and seems not to apply to attributes.
My desire for DOCTYPEs is not just HTML snobbery, but has real world implicatons for me, since DOCTYPEs are important for persuading the Explorer 6 browser to act no more foolish about CSS than it has to.
Is this an XHTML thing, an XSLT thing, a parser thing or an Oxygen thing? Is there a workaround that would allow me to keep my DOCTYPEs?
Thanks in advance for any help you can give.