[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Optional namespace declaration in XML document
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.
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|