Hi folks,
I having a problem getting Xalan to match input which explicitly is governed by a schema defined to be the default namespace.
test.xsd: --------
<?xml version='1.0' encoding='UTF-8'?> <xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
targetNamespace="http://junk.com/Test"
<xsd:element name="test">
<xsd:complexType>
<xsd:sequence minOccurs="1" maxOccurs="unbounded">
<xsd:element name="this" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>input.xml ---------
<?xml version='1.0' encoding='UTF-8' standalone="no" ?> <test xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
xmlns= "http://junk.com/Test" xsi:schemaLocation="http://junk.com/Test test.xsd"
<this>
thisdata
</this>
</test>XSL:
transform.xsl ------------- <?xml version='1.0' encoding='UTF-8' standalone="no" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
<xsl:output method = "xml" indent = "yes" />
<!-- the root element is schema --> <xsl:template match="/"> ## root was matched count this: <xsl:value-of select="count(//this)"/> <xsl:apply-templates select="*"/> </xsl:template>
<xsl:template match="this" >
elem name=<xsl:value-of select="name()"/>
## this was matched
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>I've tried Xalan 1.2.2, 2.1.0, and 2.2.D14 all which produce this result which does not match elements in the default name space. --------- <?xml version="1.0" encoding="UTF-8"?> ## root was matched count this: 0
thisdata ------
The <this> element goes unmatched.
By replacing the use of: xmlns= "http://junk.com/Test" xsi:schemaLocation="http://junk.com/Test test.xsd" With: xsi:noNamespaceLocation="test.xsd"
Things work as expected, producing the desired result:
<?xml version="1.0" encoding="UTF-8"?>
## root was matched count this: 1
elem name=this ## this was matched
thisdata
Interestingly if I Turbo XML on this same input.xml (which uses Xalan for XSLT) I get the correct result.
The problem goes away if input.xml uses a non-default namespace for all the elements to be matched (with associated namespace changes in transform)
input.xml:
<?xml version='1.0' encoding='UTF-8' standalone="no" ?> <foo:test xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
xmlns:foo= "http://junk.com/Test" xsi:schemaLocation="http://junk.com/Test test.xsd"
<foo:this>
thisdata
</foo:this>
</foo:test>transform.xsl
<?xml version='1.0' encoding='UTF-8' standalone="no" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:foo="http://junk.com/Test"
<xsl:output method = "xml" indent = "yes" />
<!-- the root element is schema --> <xsl:template match="/"> ## root was matched count this: <xsl:value-of select="count(//foo:this)"/> <xsl:apply-templates select="*"/> </xsl:template>
<xsl:template match="foo:this" >
elem name=<xsl:value-of select="name()"/>
## this was matched
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>Why is Xalan not matching elements when the input document has a default namespace that is explicitly declared (as opposed to using noNameSpaceLocation)?
-- ------------------------------------------------------------------------- Jason Winshell, Principal Consulting Engineer [EMAIL PROTECTED] Bear River Associates, Inc. http://www.bearriver.com
