Subject: Re: [xsl] PART 3 -THE REVERSE DIRECTION -- Yet still moving elements -- to a new location in a different Result-tree From: David Carlisle <davidc@xxxxxxxxx> Date: Fri, 16 Sep 2005 11:21:49 +0100 |
<!-- Minor question: Is there a better way to do this than using 'local' variables?--> <xsl:variable name="IND_NAME"> <xsl:value-of select="name()"/> </xsl:variable> If you _did_ need a variable then you should not define it like that: as it makes a result tree fragment which you don't need, you would just do <!-- Minor question: Is there a better way to do this than using 'local' variables?--> <xsl:variable name="IND_NAME" select="name()"/> But you should almost never test on name() that is just re-implementing (inefficiently, and in a way that is not namespace-safe) template matching. <xsl:variable name="CURRENT_NODE"> <xsl:value-of select="node()"/> </xsl:variable> That confusingly does not define CURRENT_NODE to be the current node (to do that you would do <xsl:variable name="CURRENT_NODE" select="."/> It defines it to be a result tree fragment representing _copies_ of _children_ of the current node. so don't do this <xsl:when test="$IND_NAME='NAME_MIDDLE'"> <abc:field name="THE_ALIAS" number="2"> you could do <xsl:when test="self::NAME_MIDDLE"> <abc:field name="THE_ALIAS" number="2"> But that, as I say is just a poir man's version of template matching so get rid of teh whole xsl:choose and just have <xsl:template match="NAME_MIDDLE"> .... <xsl:when test="$IND_NAME='NAME_PREFIX'"> So the current node here is NAME_PREFIX <xsl:apply-templates select="ALIAS" /> so the above line applies templates to all the ALIAS element children of the NAME_PREFIX element, but there are none. You presumably want to apply templates to ../ALIAS not ALIAS as ALIAS is your brother not your child. David ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] PART 3 -THE REVERSE DIRECTIO, Graves, Jim \(CONTR\ | Thread | [xsl] zero-width spaces problem - t, paul . griffin |
Re: [xsl] Convert Word XML to Hiera, Joris Gillis | Date | RE: [xsl] Convert Word XML to Hiera, Michael Kay |
Month |