[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
XSLT and Default namespaces
Subject: XSLT and Default namespaces From: "Raimond Brookman" <nucleon@xxxxxxxxxx> Date: Thu, 5 Oct 2000 21:03:09 +0200 |
Hi, I want to transform an xml document that has declared a namespace, for example: <?xml version="1.0" encoding="UTF-8"?> <test xmlns="myns"> <a> <b></b> </a> </test> The corresponding XSLT is: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/"> <xsl:copy-of select="a/b"/> </xsl:template> </xsl:stylesheet> The resulting output document is empty. When i dont use a default namespace and prefix the root elements in the source document, and also declare the namespace in the XSL and use it in my X-path, it works: <?xml version="1.0" encoding="UTF-8"?> <x:test xmlns:x="myns"> <a> <b></b> </a> </x:test> <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:x="myns"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/"> <xsl:copy-of select="x:test/a/b"/> </xsl:template> </xsl:stylesheet> Result: <?xml version="1.0" encoding="UTF-16"?> <b xmlns:x="myns"></b> So, after this lengthy introduction the following questions: 1. Is there a way to make this work without having to contantly prefix all my xpath queries 2. Secondly, MS has come up with XDR, which is declared as follows: xmlns="x-schema:myschema.xdr" The problem is, that automatic validating happens in this case in tools such as XML spy. I cant find a way to declare that namespace inside an XSLT without having problems running the XLST because validation kicks in..... Anybody know some workarounds for these things? Grtz, Raimond XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: <xsl:stylesheet xmlns:xsl=" ???, Evan Lenz | Thread | RE: XSLT and Default namespaces, Evan Lenz |
(no subject), Ravi | Date | RE: <xsl:stylesheet xmlns:xsl=" ???, Evan Lenz |
Month |