xsl-list
[Top] [All Lists]

RE: [xsl] Optional namespace declaration in XML document

2006-05-01 07:39:07
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.



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>