This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Selection Criteria in XSL
- To: xsl-list at lists dot mulberrytech dot com
- Subject: RE: [xsl] Selection Criteria in XSL
- From: Wendell Piez <wapiez at mulberrytech dot com>
- Date: Thu, 22 Mar 2001 11:42:06 +0000
- References: <30402B4CB8C7D311A3C600C04F1513BC33EF80@bg2ipmail>
- Reply-To: xsl-list at lists dot mulberrytech dot com
At 05:29 AM 3/22/01, Brent wrote:
>So my understanding is this:
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> > <xsl:template match="viewentries/viewentry">
> > <xsl:for-each
> > select="./entrydata[@columnnumber='1']/text='Autobiography'">
>
>You are trying to select the specific viewentry node, therefore you would
>have: viewentries/viewentry[some criteria]
This is one approach: works fine. (Except the word 'criteria' is a plural!
Sorry --- it's the English teacher in me.)
>Note: With your's, after you piece together the match & the for-each, you
>get: viewentries/viewentry/entrydata ...
> >> This selects the actual entrydata node.
> Also the /text isn't a node, or anything. Maybe if the XML was
> formed
><entrydata><text></text></entrydata>?
Exactly.
>Actually, I tried to do this selection in two parts, like yours, ie;
> > <xsl:template match="viewentries/viewentry">
> > <xsl:for-each
> select=".[entrydata[@columnnumber='1']='Autobiography']">
>
>but it definitely did not like this. Maybe someone can offer an
>explanation?
It's that illegal ".[entrydata[@columnnumber='1']='Autobiography']". The
abbreviated step "." may not be used with a predicate. (A step may contain
a predicate, but it may not have a predicate.)
But
select="./entrydata[@columnnumber='1']/text()='Autobiography'"
would work fine. More succinctly,
select="entrydata[@columnnumber='1']='Autobiography'"
would work too. (The leading ./ says "start at the context node", which is
redundant. The trailing "/text()" is redundant in this case, because the
value of the entrydata node is the concatenation of the values of its text
node descendants -- and here, it has only one.)
Well done, Brent.
James, I hope all is clear.
Cheers,
Wendell
======================================================================
Wendell Piez mailto:wapiez@mulberrytech.com
Mulberry Technologies, Inc. http://www.mulberrytech.com
17 West Jefferson Street Direct Phone: 301/315-9635
Suite 207 Phone: 301/315-9631
Rockville, MD 20850 Fax: 301/315-8285
----------------------------------------------------------------------
Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list