Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: [xsl] Optional namespace declaration in XML document

From: "Fraser Goffin" <goffinf@----------->
To:
Date: 5/1/2006 2:39:00 PM
Catching up on reading XSl-list digest I came across this one (from Marh 1st 
digest !) :-



Is there any way to have one XSLT 1.0 stylesheet handle situations where 
the XML input has different namespace declarations?

Possible solutions were offered by MK and Ken Holman, but neither mentioned 
the potential use of local-name(). Admittedly this may be inefficient or the 
document to be processed may be so complex that it may not be practical, but 
for simple situations it would be ok wouldn't it ?



The example docs were :-



<mydata xmlns="urn:myns">
	<mydataitem>sample data</mydataitem>
</mydata>

<mydata xmlns="urn:otherns">
	<mydataitem>sample data</mydataitem>
</mydata>

<mydata>
	<mydataitem>sample data</mydataitem>
</mydata>

Wouldn't something like this do ?? :-



<xsl:template match="*[local-name(.) = 'mydata']">
...

<xsl:template match="*[local-name(.) = 'mydataitem']">
...

We use something similar on complex documents where only the top level 
element is declared as a global type and thus has a namespace affiliation, 
all other types are local (and the schema declares 
elementFormDefault='unqualified').



Fraser.


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent