[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[xsl] transform mixing up namespaces
Subject: [xsl] transform mixing up namespaces From: "Huebel, David" <dhuebel@xxxxxxxxxxxxxx> Date: Thu, 24 May 2001 08:19:49 -0500 |
Hello all, My xsl transform seems to be mixing up namespaces. In the simplified example below, the "content" element is in the null namespace in the transform, but in the result, it appears to be in the default namespace, which is bound to "uri:foo". Is this correct behavior, and if so, why, and how can I get the transform to leave the content element in the null namespace? I am using Xalan 1.2. (Another behavior that is annoying, but correct as far as I know, is that Xalan will create result documents with unused namespace declarations. See an example at the bottom of this email.) Another question: I use IE5 and the latest version of MSXML to view xml documents with the <?xml-stylesheet?> directive. Can I use MSXML to transform documents from the command line (without buying anything)? Thanks, David "Live as if you will die tomorrow - study as if you will live forever." -- Erasmus ---------------------------------------------------------------------------- - Namespace mix-up example: Source: <?xml version="1.0"?> <top xmlns="uri:foo"> <next name="bar"/> <next name="baz"/> </top> ---------------------------------------------------------------------------- - First transform: <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:po="uri:foo" version="1.0"> <xsl:template match="po:next"> <xsl:copy> <xsl:value-of select="@name"/> <xsl:apply-templates select="*"/> </xsl:copy> </xsl:template> <xsl:template match="po:top"> <xsl:copy> <xsl:element name="content"> <xsl:apply-templates select="*"/> </xsl:element> </xsl:copy> </xsl:template> </xsl:stylesheet> ---------------------------------------------------------------------------- - Result of first transform: <?xml version="1.0" encoding="UTF-8"?> <top xmlns="uri:foo"> <content xmlns:po="uri:foo"> <next>bar</next> <next>baz</next> </content> </top> ---------------------------------------------------------------------------- - Example showing unused namespace declaration: Source: same as above Transform: <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:po="uri:foo" version="1.0"> <xsl:template match="po:top"> <xsl:copy-of select="."/> </xsl:template> </xsl:stylesheet> Result: <?xml version="1.0" encoding="UTF-8"?> <top xmlns="uri:foo" xmlns:po="uri:foo"> <next name="bar"/> <next name="baz"/> </top> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] RE: Java-based XPath tool, Dimitre Novatchev | Thread | Unused namespaces (was RE: [xsl] tr, Gareth Sylvester-Bra |
[xsl] RE: Java-based XPath tool, Dimitre Novatchev | Date | [xsl] Ann: Generic Templates -- min, Dimitre Novatchev |
Month |