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

Re: selecting a subtree from a tree

Subject: Re: selecting a subtree from a tree
From: Greg Faron <gfaron@xxxxxxxxxxxxxxxxxx>
Date: Fri, 05 Apr 2002 10:59:00 -0700
node set xsl subtree
At 05:34 AM 4/5/2002, you wrote:
<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">

Typo above: The tag is not closed.


     <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.

<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" encoding="UTF-8"/> <xsl:template match="/"> <output> <xsl:apply-templates/> </output> </xsl:template> <xsl:template match="root"> <!-- Select all children of "root" that have a child element "namedcell". Furthermore, that element must have an attribute called "name" and the value of the attribute must be either "client" or "address". --> <xsl:variable name="short-list" select="child::*[namedcell/@name='client' or namedcell/@name='address']"/> <xsl:copy-of select="$short-list"/> </xsl:template> </xsl:stylesheet>

produced:

<output>
  <record>
    <namedcell name="client" />
    <data>client x</data>
  </record>
  <record>
    <namedcell name="address" />
    <data>xmlstreet 15</data>
  </record>
</output>



Greg Faron
Integre Technical Publishing Co.



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


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.