[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: PART 3 -THE REVERSE DIRECTION -- Yet still moving

Subject: Re: 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
reverse direction
  <!-- 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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.