This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: selecting a subtree from a tree


hi..
if u wana store the record where namedcell name = client,
then you have to declare variable in the following way
<xsl:variable name="client" select="//root/record/namedcell[@name='client']>
same is the case with address.
ie.<xsl:variable name="client" 
select="//root/record/namedcell[@name='client']>
This would store the value of the namedcell, where the name = 'client'
or 'address'. Now if you wana further know what the data is then, you have 
to reach its sibling whose name is data. remember there may be other 
siblings as well for the namedcell so you have to refer to that element with 
the name of the sibling. The following xsl code will get you the data 
associated with the namedcell where name = 'client' and name = 'address'

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:template match="/">
<xsl:variable name="client" 
select="//record/namedcell[@name='client']/following-sibling::data"/>
<xsl:variable name="address" 
select="//record/namedcell[@name='address']/following-sibling::data"/>
Client  : <xsl:value-of select="$client"/> <br></br>
Address : <xsl:value-of select="$address"/>
</xsl:template>
</xsl:stylesheet>

This would produce a result
Client client x

Address xmlstreet 15

when viewed as a HTML output..
Hope This Helps
laura

>From: "Joeri Belis" <joeri.belis@nollekens.be>
>Reply-To: xsl-list@lists.mulberrytech.com
>To: <xsl-list@lists.mulberrytech.com>
>Subject: [xsl] selecting a subtree from a tree
>Date: Fri, 5 Apr 2002 14:34:51 +0200
>
>consider this XML
>
><root>
>   <record>
>      <namedcell name="ordernr"/>
>      <data>1</data>
>   </record>
>   <record>
>      <namedcell name="client"/>
>      <data>client x</data>
>   </record>
>   <record>
>      <namedcell name="address"/>
>      <data>xmlstreet 15</data>
>   </record>
>   <record>
>      <namedcell name="country">
>      <data>Transformatia</data>
>   </record>
></root>
>
>how can i select the 2 record of client and address and assign them to a
>variable.
>I don't need the first and last record (ordernr and country ) in this
>nodeset.
>
>Thanks
>
>
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>




_________________________________________________________________
Join the world’s largest e-mail service with MSN Hotmail. 
http://www.hotmail.com


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]