[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: [xsl] namespace dynamic declaration
Subject: RE: [xsl] namespace dynamic declaration From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx> Date: Wed, 26 Jun 2002 15:09:24 +0100 |
In XSLT 2.0 you can do this with the new <xsl:namespace> instruction. In XSLT 1.0 it's more difficult. What you have to do is to create a temporary tree that contains an element in the required namespace; this will automatically create a namespace node for that namespace, and you can then copy this namespace node (with the help of the xx:node-set() extension function) to your result tree: <xsl:variable name="dummy"> <xsl:element name="myprefix:dummy" namespace="{$param}"/> </xsl:variable> <xsl:copy-of select="exslt:node-set($dummy)//namespace::*/> If you don't mind having an unwanted attribute in the result tree, an easier method is to create an attribute whose name in the desired namespace, which will automatically create an associated namespace node. Michael Kay Software AG home: Michael.H.Kay@xxxxxxxxxxxx work: Michael.Kay@xxxxxxxxxxxxxx > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of > Tevoi Andrea > Sent: 26 June 2002 14:28 > To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] namespace dynamic declaration > > > Hi, > > in Xsl i'd like to do something like this: > > <xsl:attribute name="xmlns:myprefix"><xsl:value-of > select="any XPath expression"/></xsl:attribute> > > but for Xsl this is an error (because attribute name begin > with "xmlns"). > > How can i do? I mean: i would create a namespace dynamically > using an XPath expression, because I need to create (by xsl > transformation) a Schema like this: > > <xsd:schema targetNamespace="my dynamic namespace" > xmlns:xsd="http://www.w3.org/2001/XMLSchema" > xmlns:myprefix="my dynamic namespace">... > > I can create a targetNamespace attribute with: > <xsl:attribute name="targetNamespace"><xsl:value-of > select="XPath..."/></xsl:attribute> > > but not a xmlns:myprefix attribute... > > thanks for your attention, > > Andrea Tevoi > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] namespace dynamic declara, Jeni Tennison | Thread | [xsl] How to throw transformation t, Scott Purcell |
Re: [xsl] namespace dynamic declara, Jeni Tennison | Date | [xsl] How to throw transformation t, Scott Purcell |
Month |