Subject: [xsl] Trouble with namespaces and running identity transform on XHTML From: "James J. Ramsey" <jjramsey_6x9eq42@xxxxxxxxx> Date: Tue, 9 Mar 2004 13:49:56 -0800 (PST) |
I've been working on a stylesheet to "massage" some XHTML. One variation of a test stylesheet is here: <xsl:transform xmlns:h="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'> <xsl:output method="xml"/> <xsl:template match="h:h1|h:h2"> <p> LOOK MA! <xsl:apply-templates select="@*|node()"/> NO BRAINS! </p> </xsl:template> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:transform> I have four test documents that look something like this: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="test_head_attr"> <title>Sample title</title> </head> <body id="test_body_attr"> <h1>Sample H1</h1> <h2>Sample H2</h2> <p>Body text <br /> Other stuff. <br /></p> </body> </html> One of the four has both the DOCTYPE declaration and an xmlns attribute, one has the DOCTYPE declaration but no xmlns attribute, one has no DOCTYPE declaration but an xmlns attribute, and one has neither a DOCTYPE declaration nor an xmlns attribute. I'd *like* to get a stylesheet that produced the same results on all four test documents, but I'd settle for getting it to work on the documents that set the xmlns attribute explicitly in the html element and the documents with the DOCTYPE declaration. I've tried variants on this with the exclude-result-prefixes attribute of xsl:stylesheet and also tried messing with the xsl:namespace-alias element, but can't seem to this to produce the same output on both xsltproc and Saxon, and I keep getting invalid output with attributes like xmlns="" or xmlns:h="http://www.w3.org/1999/xhtml". Any idea how to do this right? __________________________________ Do you Yahoo!? Yahoo! Search - Find what you?re looking for faster http://search.yahoo.com XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Root when the current nod, Colin Toal | Thread | Re: [xsl] Trouble with namespaces a, Kevin Jones |
[xsl] Root when the current node is, Colin Toal | Date | RE: [xsl] Root when the current nod, Andreas L. Delmelle |
Month |