Subject: Re: [xsl] Identity Transform and Default Templates, I think... From: "J.Pietschmann" <j3322ptm@xxxxxxxx> Date: Thu, 20 Jun 2002 22:13:16 +0200 |
Me again. As I was moving my lessons learned over to the real application, I noticed that I need a bit more flexibility...
Given this input:
<C3PO> <SOUL id="anewmachine">The Soul</SOUL> <BD id="foo"> <HEAD>The Head</HEAD> <TR> <RF>The Right Foot</RF> <RK>The Right Knee</RK> <HR>The Heart</HR> <Ext id="extid"><ANewLimb>Some new Limb</ANewLimb></Ext> <AnotherNewLimb>Another New Limb</AnotherNewLimb> </TR> </BD> </C3PO>
I'd like to have the AnotherNewLimb element copied to the Torso element of the output document as a sibling of Extension, Chest and RightLeg. But, I'd like to be able to not be tied to the element name, much like I can rename SOUL and HEAD and still get the node copied.
If I add
<xsl:apply-templates/>
to the TR template, I wind up applying the RF, RK, HR and Ext templates twice
If you want to be generic about what's included, you'll have to be specific about what's to be excluded.
Try <xsl:apply-templates select="*[not(self::RF or self::RK or self::HR or self::Ext)]"/>
If this gets too messy, declare the excluded (or included) elements in another form. One possibility is to declare them in the stylesheet: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:data="uri:my.data" exclude-result-prefixes="data"/>
<data:excludes> <exclude name="RF"/> <exclude name="RK"/> <exclude name="HR"/> <exclude name="Ext"/> </data:excludes>
<xsl:variable name="excludes" select="document('')/xsl:stylesheet/data:excludes"/>
<xsl:template .... ... <xsl:apply-templates select=*[not(name()=$excludes/exclude/@name)]"/>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Identity Transform and De, Schneeman, Brent | Thread | Re: [xsl] XSL getting started (on a, Terje Norderhaug |
Re: [xsl] <br />'s double-space aft, Kathryn . Grant | Date | Re: [xsl] Namespaces issue, Mike Brown |
Month |