You can do something like this:
<xsl:template match="text">
<xsl:element name="xsl:value-of">
<xsl:copy-of select="namespace::*"/>
<xsl:copy-of select="@select"/>
</xsl:element>
</xsl:template>
This will copy all the inscope namespaces from the source <text> element to
the constructed <xsl:value-of> element.
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: Florent Georges [mailto:darkman_spam(_at_)yahoo(_dot_)fr]
Sent: 05 April 2006 23:25
To: XSL Mulberry list
Subject: [xsl] Namespaces: part II
Hi
I have a new question about XSLT and namespaces. I use a
custom document type to generate XSLT scripts. This source
document contains XPath expressions that are copied in the
resulting script, for example:
<doc>
...
<text select="an/xpath/expression"/>
...
</doc>
may result in something like:
<xsl:transform ...>
...
<xsl:value-of select="an/xpath/expression"/>
...
</xsl:transform>
But the source document against wich the generated script
will be applied has element in multiple namespaces. So it
is like this:
<doc xmlns:ns1="ns/1" xmlns:ns2="ns/2" xmlns:ns3="ns/3">
...
<text select="ns1:an/ns2:xpath/ns3:expression"/>
...
</doc>
and:
<xsl:transform xmlns:ns1="ns/1" xmlns:ns2="ns/2"
xmlns:ns3="ns/3" ...>
...
<xsl:value-of select="ns1:an/ns2:xpath/ns3:expression"/>
...
</xsl:transform>
How can I ensure that the same prefixes will be bound to
the same namespace URI in the generated XSLT ?
I guess that with something like this:
<doc>
<ns prefix="ns1" uri="ns/1"/>
<ns prefix="ns2" uri="ns/2"/>
<ns prefix="ns3" uri="ns/3"/>
...
<text select="ns1:an/ns2:xpath/ns3:expression"/>
...
</doc>
I can add the right bindings to the xsl:transform. But I
wonder if it is possible to keep the usual namespace rules
in the source document (using xmlns declarations), and to
keep scope-correctness. By this last point, I mean for
example:
<doc>
...
<text select="1 + 1"/>
<text select="ns:element" xmlns:ns="ns/uri"/>
...
</doc>
and:
<xsl:transform ...>
...
<xsl:value-of select="1 + 1"/>
<xsl:value-of select="ns:element" xmlns:ns="ns/uri"/>
...
</xsl:transform>
Thanks for your help. Regards,
--drkm
______________________________________________________________
_____________
Nouveau : téléphonez moins cher avec Yahoo! Messenger !
Découvez les tarifs exceptionnels pour appeler la France et
l'international.
Téléchargez sur http://fr.messenger.yahoo.com
--~------------------------------------------------------------------
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>
--~--
--~------------------------------------------------------------------
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>
--~--