[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] getting rid of namespaces
Dear XSL List,
I'm trying to get rid of a pesky namespace declaration, and I've tried to follow the rules (as I ... er ... understand them), but without success. Can someone please advise me on where my blind spot lies? Here's a sample XML document instance: <?xml version="1.0" encoding="UTF-8"?> <root> <p>A paragraph in no namespace</p> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Title in html namespace</title> </head> <body> <p>A paragraph in the html namespace</p> </body> </html> </root> Here's the XSLT: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:html="http://www.w3.org/1999/xhtml" version="2.0" exclude-result-prefixes="#all"> <xsl:template match="/"> <html> <head> <title>Test of removing namespaces</title> </head> <body> <xsl:apply-templates/> </body> </html> </xsl:template> <xsl:template match="p"> <p> <xsl:apply-templates/> </p> </xsl:template> <xsl:template match="html:html/html:body/html:*"> <xsl:copy-of select="." copy-namespaces="no"/> </xsl:template> <xsl:template match="html:html/html:head"/> </xsl:stylesheet> I specify exclude-result-prefixes="#all" on the <xsl:stylesheet> node and I specify copy-namespaces="no" on the <xsl:copy-of> instruction that copies all elements in the body the html document that is embedded in my XML source. The first of these strategies makes the namespace declaration on the paragraph in no namespace go away (so far, so good), but the second does not suppress the unwanted namespace declaration on the embedded <html:p>. Here's the output of a Saxon 8.9.0.4J transformation (I've edited out some unwanted white space): <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Test of removing namespaces</title> </head> <body> <p>A paragraph in no namespace</p> <p xmlns="http://www.w3.org/1999/xhtml">A paragraph in the html namespace</p> </body> </html> What should I be doing to get rid of the xhtml namespace declaration? Thanks! Best, David djbpitt+xml@xxxxxxxx
|
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
|