Subject: [xsl] 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 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Your Postings to XSL-List had, Mulberry Technologie | Thread | [xsl] Re: xsl-list Digest 24 Sep 20, David Carlisle |
[xsl] Re: xsl-list Digest 24 Sep 20, David Carlisle | Date | Re: [xsl] applying templates to all, Bruce D'Arcus |
Month |