Bug 33783 - XSLTC confused by multiple default namespaces in transform
Summary: XSLTC confused by multiple default namespaces in transform
Status: CLOSED INVALID
Alias: None
Product: XalanJ1
Classification: Unclassified
Component: Xalan (show other bugs)
Version: 1.x
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: Scott Boag
URL:
Keywords: XSLTBug
Depends on:
Blocks:
 
Reported: 2005-03-01 05:00 UTC by Benjamin
Modified: 2005-03-02 07:55 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin 2005-03-01 05:00:56 UTC
Input template:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<core:Display
	xmlns:core="http://example.com/core"
	xmlns:foo="http://example.com/java/foo"
	>
	<core:Styles xmlns="http://example.com/java/foo">
		<Constant/>
	</core:Styles>
	<core:View xmlns="http://example.com/java/javax.swing">
		<!-- workaround for buggy(?) XSLT processor.-->
		<!--This should work:-->
		<foo:Constant/>
		<!--Workaround is:-->
		<!--xsl:element
			namespace="http://example.com/java/foo"
			name="Constant"
			/-->
	</core:View>
</core:Display>
</xsl:template>
</xsl:stylesheet>

Input document:
<doc/>

Expected result:
<?xml version="1.0" encoding="UTF-8"?>
<core:Display xmlns:core="http://example.com/core"
xmlns:foo="http://example.com/java/foo">
<core:Styles xmlns="http://example.com/java/foo">
<Constant/>
</core:Styles>
<core:View xmlns="http://example.com/java/javax.swing">
<foo:Constant/>
</core:View>
</core:Display>

Actual result:
<?xml version="1.0" encoding="UTF-8"?>
<core:Display xmlns:core="http://example.com/core"
xmlns:foo="http://example.com/java/foo">
<core:Styles xmlns="http://example.com/java/foo">
<Constant/>
</core:Styles>
<core:View xmlns="http://example.com/java/javax.swing">
<Constant/>
</core:View>
</core:Display>

(Note second Constant tag is missing namespace prefix)

The error only occurs when a node is defined when its namespace was the default,
then later the same node is defined when its namespace is no longer the default.
The lack of prefix the second time around means it goes into the new (now
incorrect) default namespace. This example is a cut-down version of working
software.

I'm fairly new to the Java sphere, so am not 100% sure of version numbers. I'm
running Eclipse 3.0 and the 1.5.0 Java SDK and am using whatever the combination
of these two forces brings in by default. The classes that get instantiated
appear to be XSLTC-related, and I'm using the JAXP interface. My code looks
something like this:

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder parser = factory.newDocumentBuilder();
Document template = parser.parse("transform.xsl");
Document instance = parser.parse("doc.xsli");
Document result = parser.newDocument();
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transform = factory.newTransformer(new DOMSource(template));
DOMResult doc = new DOMResult(result);
transform.transform(new DOMSource(instance), doc);

Benjamin.
Comment 1 Benjamin 2005-03-01 05:05:54 UTC
I probably should note that Bugzilla didn't permit me to select XalanJ2 as the
related product and I was unable to find a specific XSLT component to place it
against. I suggest the assignee of this bug push it to the right person...

Benjamin.
Comment 2 Benjamin 2005-03-02 10:08:13 UTC
Thanks to Jeff Turner and Sander Temme who directed me to the new bug database
for XSLTC. I've filed it there as XALANJ-2032. I am happy for this bug to be
resolved as a duplicate of that (hopefully) correctly-filed bug.

Benjamin.
Comment 3 Sander Temme 2005-03-02 16:55:18 UTC
Ben has re-filed in Jira. 
Comment 4 Sander Temme 2005-03-02 16:55:37 UTC
Closing out.