[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Best namespace attribute removal strategy?
Hi,
I'm new to the list and also somewhat of an XSLT neophyte, so please bear with me as I lay out a question you no doubt have encountered before... I am developing a simple content management system for my own needs. I have chosen to use XHTML for data storage, and I use XSLT to grab the body of the document and insert it into the page, adding other stuff using PHP. I'm using PHP's integrated XSLT processing extension. --- My XHTML source: --- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>The Title</title> </head> <body> <h1>A Heading.</h1> <p> Lorem ipsum dolor sit amet. </p> </body> </html> ------------------------
<xsl:output method="xhtml"/> <xsl:template match="/"> <xsl:copy-of select="xhtml:html/xhtml:body/*"/> </xsl:template> </xsl:stylesheet> -------------------------- The problem (as you can probably guess by now) is that the XSLT processor is outputting XML namespace attributes for each element, like this: --- Output 1: --- <h1 xmlns="http://www.w3.org/1999/xhtml">A Heading.</h1> <p xmlns="http://www.w3.org/1999/xhtml"> Lorem ipsum dolor sit amet. </p> ----------------- I am aware of the fact that using copy-of _will_ copy the implicit namespace nodes. I also am aware of the fact that exclude-result-prefixes won't work in this case. What I would like to know is what would be the most elegant solution to this problem? I have come up with one potential candidate: If I modify the stylesheet's copy-of element's select attribute to "xhtml:html/xhtml:body" I will get the following output: --- Output 2: --- <body xmlns="http://www.w3.org/1999/xhtml"> <h1>A Heading.</h1> <p> Lorem ipsum dolor sit amet. </p> </body> ----------------- Using PHP it would be rather trivial to remove the body tag, effectively solving my problem. I guess I am just wondering if anyone has a better solution. My desired end result is the source of Output 1 with the xmlns attributes removed. Sincerely, Max Romantschuk
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|