[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: [xsl] Namespaces: part II
Subject: RE: [xsl] Namespaces: part II From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Thu, 6 Apr 2006 09:54:21 +0100 |
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@xxxxxxxx] > 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 : tiliphonez moins cher avec Yahoo! Messenger ! > Dicouvez les tarifs exceptionnels pour appeler la France et > l'international. > Tilichargez sur http://fr.messenger.yahoo.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Namespaces: part II, Florent Georges | Thread | [xsl] Factorial Calculation, Pankaj Bishnoi |
RE: [xsl] Man Page Transform and Mo, Michael Kay | Date | RE: [xsl] filtering elements by sin, Tomas Kolaci |
Month |