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

RE: xsl-list Digest 24 Sep 2004 05:10:00 -0000 Issue 1

Subject: RE: xsl-list Digest 24 Sep 2004 05:10:00 -0000 Issue 187
From: "Paria Heidari" <pheidari@xxxxxxxxxxxxxx>
Date: Fri, 24 Sep 2004 08:48:27 -0400
paria heidari
This is what my xml might look like:
<x>
 <CUSTOMERS>
...
 </CUSTOMERS>
<CUSTOMERS>
...
 </CUSTOMERS>
<CUSTOMERS>
...
 </CUSTOMERS>
</x>

OR

<x>
 <CLIENTS>
...
 </CLIENTS>
 <CLIENTS>
...
 </CLIENTS>
 <CLIENTS>
...
 </CLIENTS>
</x>

OR

<x>
  <SUPPLIERS>
..
 </SUPPLIERS>
  <SUPPLIERS>
..
 </SUPPLIERS>
 <SUPPLIERS>
..
 </SUPPLIERS>
</x>

The "x" value is the only constant I know. The first child node will
come to me as a Param value.

Could you please tell me what should I use for my <xsl:apply-template...
and <xsl:template match... ?

Thank you,
Paria


-----Original Message-----
From: David Carlisle [mailto:davidc@xxxxxxxxx]
Sent: Friday, September 24, 2004 8:36 AM
To: Paria Heidari
Cc: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: xsl-list Digest 24 Sep 2004 05:10:00 -0000 Issue 187


  None of the below call works:
  <xsl:template match="CUSTOMERS/*[name()=($ROOT)]">
  <xsl:template match="($ROOT)">
  <xsl:template match="name()">


A match pattern can't use a variable, and can't consist of top level
use of () or the name function.

You would just use a normal match template

match="CUSTOMERS"

for example would match CUSTOMERS. the point of the

<xsl:apply-templates select="*[name()=$ROOT]"/>

is to allow the parameter to affect the nodes to which templates are
applied, you don't need to do anything special to define teh templates,
that is the whole point of the exercise.

In all your postings I don't think you've really stated what your real
input is like, in the examples you have posted there has only been one
element in the relevant position in the source file so really you would
not need any parameter at all, you can just apply templates to whatever
element is there (which is the default XSLT behaviour) given that you
say you needed a parameter I'm assuming that your real input looks ike

<x>
 <CUSTOMERS>
...
 </CUSTOMERS>
 <CLIENTS>
...
 </CLIENTS
 <SUPPLIERS>
..
 </SUPPLIERS>
</x>

and you want your parameter to choose between CUSTOMERS CLIENTS and
SUPPLIERS
in which case you would have templates matching those as normal and have
<xsl:template match="x">
 <xsl:apply-templates select="*[name()=$ROOT]"/>
</xsl:template>

so if $ROOT was "SUPPLIERS" then just SUPPLIERS would be processed and
the other templates would never be activated.



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.