[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Xalan Java 2: doesn't seem to output namespaces to

Subject: RE: Xalan Java 2: doesn't seem to output namespaces to result document ...
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 13 Jan 2005 08:46:59 -0000
xalan namespace alias
> After studying the http://www.w3.org/TR/xslt20/ working draft and much
> experimentation, I am not able to get xsl:namespace to create a
> namespace node in the result document using Xalan Java 2.6.0 or Xalan
> Java 2.2.Dll.

That's because Xalan doesn't implement XSLT 2.0. I would expect it to give
you an error message when you use the xsl:namespace instruction.
> 
> 	<xsl:template match="/">
> 		<xsl:copy-of select="xalan:checkEnvironment()"/>
> 		<xsl:element name="xsl:stylesheet">
> 			<!-- I expect to see a xmlns:test='...' in the
> resulting xsl:stylesheet tag -->
> 			<xsl:namespace name="test"
> select="'http://www.test.com/test'"/>
> 			<xsl:apply-templates />
> 		</xsl:element>
> 	</xsl:template> 
> 
> You mentioned that I would need to also use the 
> xsl:namespace-alias. Can
> you explain more on this as I am not able to find any reference to how
> xsl:namespace and xsl:namespace-alias work together?

They don't work together. As I think I said, xsl:namespace-alias only
affects the results of literal result elements.
> For example, the following:
> 
>    <xsl:stylesheet 
> 	version="2.0"
> 	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
> 	xmlns:xalan="http://xml.apache.org/xalan"
> 	xmlns:test="http://www.test.com/test"
> 	xmlns:cxsl="copy-XSL-nodes"
>    >
> 	<xsl:namespace-alias stylesheet-prefix="cxsl" result-prefix=
> "xsl"/> 
> 	<xsl:template match="/">
> 		<xsl:copy-of select="xalan:checkEnvironment()"/>
> 		<cxsl:stylesheet>
> 			<xsl:namespace name="google"
> select="'http://www.google.com/nothing'"/>
> 			<xsl:apply-templates />
> 		</cxsl:stylesheet>
> 	</xsl:template>
>    </xsl:stylesheet>
> 
> 1) The above copied all namespaces to the result document even though
> I'm not using xmlns:test. 
> 	Why did xmlns:test show up? 

cxsl:stylesheet is a literal result element. When an LRE is evaluated, all
its in-scope namespaces (other than those listed in exclude-result-prefixes)
are copied to the result tree.

> 	And why does the xsl:element not have the same behavior? 

Because that's the way it's specified.
> 
> 2) I expected to see xmlns:google='...' in the cxsl:stylesheet node in
> the result document. Of course, it is not there. 
> 	I'm wondering why?
> 

My only surprise here is that Xalan doesn't error on this stylesheet. The
rule is that an XSLT 1.0 processor, given a stylesheet that says
version="2.0", should give a run-time error if you try to execute an
instruction in the XSLT namespace that hasn't been defined in the XSLT 1.0
specification, unless it has an xsl:fallback child element.

Michael Kay
http://www.saxonica.com/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.