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

Re: select element based on value of one of the childr

Subject: Re: select element based on value of one of the children
From: Ragulf Pickaxe <ragulf.pickaxe@xxxxxxxxx>
Date: Tue, 11 Oct 2005 11:28:08 +0200
xslt selecting element values
Hi Bjorn,

> Dear reader,
> As a XML and XSL newbie I would like to know whether it is possible to
> select an element based on the value of one of children and how this can
> best be done.
>

<xsl:template match="a[b='7']">
  <xsl:copy-of select="."/>
</xsl:template>

If you wish to do further processing rather than just a copy, you can
apply templates instead. What it is saying is that it should match all
a elements with a child element b whose value is equal to '7'. The
XSLT parser makes an implicit conversion to a string, but otherwise
you might use [string(b)='7'] instead.

> P.S. I tried to do my "homework" and found the following example
> http://www.dpawson.co.uk/xsl/sect2/N3235.html#d4086e214. I, however, do
> not understand what their solution to the problem is.

What this says (from your homework):
<xsl:apply-templates mode="copy"
select="record[data-field/subfield='0039-0310X']" />

Is to apply templates to all record elements that have a child
data-field with another child whose string value is equal to
'0039-0310X'. They use mode so that the template matching * (all
elements) is not invoked by default.

Hope this helps.

Regards,
Ragulf Pickaxe :-)

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.