This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: How to pick and choose nodes to get value
- From: Jeni Tennison <jeni at jenitennison dot com>
- To: "Khalid" <k_ali at telusplanet dot net>
- Cc: XSL-List at lists dot mulberrytech dot com
- Date: Fri, 4 Jan 2002 16:51:09 +0000
- Subject: Re: [xsl] How to pick and choose nodes to get value
- Organization: Jeni Tennison Consulting Ltd
- References: <3c35d233.5172.0@telusplanet.net>
- Reply-to: xsl-list at lists dot mulberrytech dot com
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