xsl-list
[Top] [All Lists]

Re: PART 3 -THE REVERSE DIRECTION -- Yet still moving elements -- to a new location in a different Result-tree

2005-09-16 03:21:49
  <!-- 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
________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>