Subject: Re: [xsl] separating elements/attributes From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Wed, 22 Aug 2001 09:54:51 +0100 |
Hi Samina, > Now for all the "unused" elements/attributes, I want > to do something like this in my stylesheet: > > <moreover:tagline><xsl:value-of > select="tagline"/></moreover:tagline> > <moreover:access_reg><xsl:value-of > select="access_reg"/></moreover:access_reg> > <moreover:access_status><xsl:value-of > select="access_status"/></moreover:access_status> Sure. Make a template that matches all these elements: <xsl:template match="*"> ... </xsl:template> You want to decide the name of the new element on the fly, so you have to use xsl:element to create it. The value of the new element is the same as the value of the element you're matching, so you just want the value to be the value of the current node: <xsl:template match="*"> <xsl:element name="..."> <xsl:value-of select="." /> </xsl:element> </xsl:template> The (local) name of the new element is the same as the (local) name of the element. But you want it to be in the moreover namespace. You can use an attribute value template in the name attribute of the xsl:element instruction to determine the name of the element dynamically. Assuming that you've declared the moreover namespace with the prefix 'moreover' in the stylesheet, you can use: <xsl:template match="*"> <xsl:element name="moreover:{local-name()}"> <xsl:value-of select="." /> </xsl:element> </xsl:template> Otherwise (or as well, if you like), you can declare the namespace explicitly in the namespace attribute of xsl:element: <xsl:template match="*"> <xsl:element name="moreover:{local-name()}" namespace="http://www.moreover.com/"> <xsl:value-of select="." /> </xsl:element> </xsl:template> I hope that helps, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Migrating from xalan to o, Steve Muench | Thread | [xsl] Passing the current node list, Paul Ackley |
Re: [xsl] Passing the current node , Joerg Pietschmann | Date | Re: [xsl] conditional copying of no, Jeni Tennison |
Month |