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

Re: How to pick and choose nodes to get value

Subject: Re: How to pick and choose nodes to get value
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 4 Jan 2002 16:51:09 +0000
get elements nodes by value
Hi Khalid,

> in the above code what I want to do is to get all the nodes
> excluding system-id and last-modified one'e. and I want to get value
> of rest of the nodes one by one,Unlike, I have used select = "."
> code, which returns a long string with all the values in it. I want
> to get value of each node at a time not explicitly knowing that what
> node I am getting value for .except the system id and last modified
> nodes?

To explicitly know what kind of node you're dealing with each time
(presumably so that you can treat them differently), I'd use templates
that match each kind of node. So you'd have one template for
trading-name:

<xsl:template match="trading-name">
  ...
</xsl:template>

One template for number-and-street-name:

<xsl:template match="number-and-street-name">
  ...
</xsl:template>

and so on for the rest of the elements that you're interested in.

To ignore the system-id and last-modified elements, you have two
choices. First, within the template for the address element (or
wherever you're processing the address element, if it's not in its own
template), you could apply templates to only the elements that you're
interested in:

<xsl:template match="address">
  <xsl:apply-templates
    select="*[not(self::system-id or self::last-modified)]" />
</xsl:template>

Second, you could apply templates to all the child elements:

<xsl:template match="address">
  <xsl:apply-templates select="*" />
</xsl:template>

and then have a template that matches the elements that you want to
ignore and does nothing with them:

<xsl:template match="system-id | last-modified" />

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 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.