[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] Xalan Java 2: doesn't seem to output namespaces to result document ...


Subject: RE: [xsl] Xalan Java 2: doesn't seem to output namespaces to result document ...
From: "Ross, Douglas" <DRoss@xxxxxxxxxx>
Date: Wed, 12 Jan 2005 14:05:16 -0500

Michael,

Thank you for the prompt answer. I'm trying to understand how the
xsl:namespace instruction works.

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.

	<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?

When I change xsl:element to cxsl:element or even to just element, Xalan
Java 2.6 copies all namespaces from the root node just like 2.2.Dll
does. But xsl:namespace still seems like it is not really doing
anything.

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?
	And why does the xsl:element not have the same behavior?

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?

Any advice and/or pointers is appreciated.

Douglas Ross
Developer, HTML UI Framework
Kronos
E-mail: dross@xxxxxxxxxx

PS

The Result from the above XSLT:

<?xml version="1.0" encoding="UTF-8"?>
<checkEnvironmentExtension>
<EnvironmentCheck version="$Revision: 1.26 $">
<environment>
<item key="version.DOM.draftlevel">2.0fd</item>
<item key="java.class.path">.</item>
<item key="version.JAXP">1.1 or higher</item>
<item key="java.ext.dirs">C:\Program
Files\Java\j2re1.4.1_05\lib\ext</item>
<foundJar desc="path" name="xalan.jar">C:\Program
Files\Java\j2re1.4.1_05\lib\endorsed\xalan.jar</foundJar>
<foundJar desc="apparent.version"
name="xalansamples.jar">xalansamples.jar
present-unknown-version</foundJar>
<foundJar desc="path" name="xalansamples.jar">C:\Program
Files\Java\j2re1.4.1_05\lib\endorsed\xalansamples.jar</foundJar>
<foundJar desc="apparent.version" name="xercesImpl.jar">xercesImpl.jar
from Xerces-J-bin.2.6.2</foundJar>
<foundJar desc="path" name="xercesImpl.jar">C:\Program
Files\Java\j2re1.4.1_05\lib\endorsed\xercesImpl.jar</foundJar>
<foundJar desc="apis.jar-apparent.version" name="xml">xml-apis.jar from
tck-jaxp-1_2_0 branch of xml-commons, tag:
xml-commons-external_1_2_01</foundJar>
<foundJar desc="apis.jar-path" name="xml">C:\Program
Files\Java\j2re1.4.1_05\lib\endorsed\xml-apis.jar</foundJar>
<item key="version.xerces2">Xerces-J 2.6.2</item>
<item key="version.xerces1">not-present</item>
<item key="version.xalan2_2">Xalan Java 2.6.0</item>
<item key="version.xalan1">not-present</item>
<item key="version.ant">not-present</item>
<item key="java.version">1.4.1_05</item>
<item key="version.DOM">2.0</item>
<item key="version.crimson">present-unknown-version</item>
<item key="sun.boot.class.path">C:\Program
Files\Java\j2re1.4.1_05\lib\endorsed\bsf.jar;C:\Program
Files\Java\j2re1.4.1_05\lib\endorsed\xalan.jar;C:\Program
Files\Java\j2re1.4.1_05\lib\endorsed\xalansamples.jar;C:\Program
Files\Java\j2re1.4.1_05\lib\endorsed\xercesImpl.jar;C:\Program
Files\Java\j2re1.4.1_05\lib\endorsed\xml-apis.jar;C:\Program
Files\Java\j2re1.4.1_05\lib\endorsed\xsltcapplet.jar;C:\Program
Files\Java\j2re1.4.1_05\lib\endorsed\xsltcbrazil.jar;C:\Program
Files\Java\j2re1.4.1_05\lib\endorsed\xsltcejb.jar;C:\Program
Files\Java\j2re1.4.1_05\lib\endorsed\xsltcservlet.jar;C:\Program
Files\Java\j2re1.4.1_05\lib\rt.jar;C:\Program
Files\Java\j2re1.4.1_05\lib\i18n.jar;C:\Program
Files\Java\j2re1.4.1_05\lib\sunrsasign.jar;C:\Program
Files\Java\j2re1.4.1_05\lib\jsse.jar;C:\Program
Files\Java\j2re1.4.1_05\lib\jce.jar;C:\Program
Files\Java\j2re1.4.1_05\lib\charsets.jar;C:\Program
Files\Java\j2re1.4.1_05\classes</item>
<item key="version.SAX">2.0</item>
<item key="version.xalan2x">Xalan Java 2.6.0</item>
</environment>
<status result="OK"/>
</EnvironmentCheck>
</checkEnvironmentExtension>
<cxsl:stylesheet
xmlns:cxsl="http://www.w3.org/1999/XSL/Transform"
xmlns:test="http://www.test.com/test"
xmlns:xalan="http://xml.apache.org/xalan">
	Stuff
	More Stuff
</cxsl:stylesheet>


Current Thread