[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Adding namespaces to output
On Monday 23 Dec 2002 7:18 pm, G. Ken Holman wrote: > Close, but I can think of two problems with this, Kevin, > Cut.. > >You can get the same effect by using a temporary tree and then copying the > >namespace out of it. > > > ><xsl:variable name="dummy"> > > <xsl:element name="p:a" namespace="something"/> > ></xsl:variable> > > > ><a> > > <xsl:copy-of select="$dummy/*/namespace::*[1]"/> > ></a> > > > >You will need to use your processors nodeset function to access $dummy in > > the copy-of. > > (1) if the user is using W3C standard XSLT 1.0 without extensions, a result > tree fragment cannot be supplied to xsl:copy-of except by variable name > only. Yep. Thats why I suggested he use nodeset on the copy-of. For interest are there any prcoessors that do not have support a nodeset function yet? > > (2) XSLT 1.1 allowed this, but since the order of namespace nodes is > arbitrary and possibly different with all processors, and there may be any > number of ancestral namespace declarations, the namespace for 'p:' isn't > necessarily the first and the following would not be subject to the order: > > <xsl:copy-of select="$dummy/*/namespace::*[name(.)='p']"/> I am exploiting the fact that I know exactly what the RTF looks like because I created it in the variable. Therefore I know the namspace node is the only one and its at position one of the first element. I don't think there is any way this can be wrong in a 1.0 conforming processor. Having said that your solution will clearly be more resiliant to anybody hacking the variable around. Regards, Kev. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|