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

RE: Predicates question

Subject: RE: Predicates question
From: Roelof Wobben <rwobben@xxxxxxxxxxx>
Date: Sat, 17 Dec 2011 18:25:06 +0000
RE:  Predicates question
I know logical expressions but I had no clue how to combine them.

So thanks for showing me how to combine them in xslt.



Roelof











---------------------------------------- > Date: Sat, 17 Dec 2011 19:11:58
+0100 > From: wolfgang.laun@xxxxxxxxx > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx >
Subject: Re:  Predicates question > > An XPath expression may contain
predicates that filter the set of > nodes returned by that XPath. Now, a
filter for "book" is written as a > bracketed expression > >
select="/bookstore/book[ ...predicate expression goes here... ]" > > Within
the brackets, you are in a certain context: the one established > by the XPath
expression up to the opening '['. And filtering > predicates should deal with
book elements, referring to their position > within the store, or by
investigating book elements such as title or > price. > > If you want a
combination of restrictions of book positions, you'll > have to write a more
complex predicate (= logical expression). If you > are familiar with logical
expressions in any programming language it > shouldn't come as a surprise that
you can combine any term with > another using the logical operators "and" and
"or". > > select="/bookstore/book[position() > 1 and position() < 3 ]" > >
Common sense would make you think that filters can be applied one > after the
other as well. So you should try > > select="/bookstore/book[position() >
1][position() < 3 ]" > > If the result surprises you, ask yourself: what
passes through the > first filter? > > Also, try > >
select="/bookstore/book[position() > 1][position() < 3 ]" > > > A term such as
> /bookstore[position() > 1 ] > doesn*t make sense at all. Since /bookstore is
the one and only root > element, there won't be another one at any position
greater than one. > > -W > > > On 17 December 2011 17:08, Roelof Wobben wrote:
> > > > I found that already. > > > > Im now trying to solve this one : > > >
> > > > > > > > > > > > > > > > > > > > > > >

> > > > > > > > > > > > > > > > > > But I see now this message : > > > > > > >
> Invalid XPath expression > > Unexpected end of statement > >
select="/bookstore/book[position() < 5 and /bookstore[position() > 1 ]" > > >
> > > > > So i try to find the books between the 1 and 5 position of the list.
> > > > > > > > Roelof > > > > > > > > > > > > > > > > > > > > > > > > > > > >
---------------------------------------- > Date: Sat, 17 Dec 2011 09:24:14
-0500 > From: voldrani@xxxxxxxxx > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx >
Subject: Re:  Predicates question > > You have a couple of other syntax
errors, too. You forgot to close > your "". Try this: > >
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> method="xml" version="1.0"
encoding="UTF-8" indent="yes"/> > select="/bookstore/book[position()<3]" /> >
> > select="title"/> > > > > On Sat, Dec 17, 2011 at 8:58 AM, Wolfgang Laun
wrote: > > > > A basic requirement for writing XML (and XSLT is XML) is to
represent > > all '<' that are part of the data (element or attribute or
other) as > > < > > > > Another characters in the same category is '&', which
must be written > > as &. when it is a data character (and not part of a
character > > reference that begins with '&'). > > > > (You may also find '>'
written as >.) > > > > There's also a construct known as CDATA section, which
is a general > > "escape" mechanism for element data. See /bookstore/book[2]
for > > details ;-) > > > > -W > > > > On 17 December 2011 14:39, Roelof
Wobben wrote: > > > > > > > > > I have this small xml file : > > > > > > > > >
> > > > > > > > > > > > > > > Harry Potter > > > 29.99 > > > > > > > > > > > >
Learning XML > > > 39.95 > > > > > > > > > > > > > > > > > > > > > And now I
want to show only a few books. > > > > > > According to this page :
http://www.w3schools.com/xpath/xpath_syntax.asp I can use this xslt : > > > >
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >> > >
> > > > > >> > > > > > > > > > > >> > > > > > > > > But if I try this on
xmlspy I get this message : > > > > > > > > > > > > Character '<' is
grammatically unexpected > > > Reason: one of the following is expected (see
below) > > > '"' > > > '&' > > > '&#' > > > '&#x' > > > [^<&"] > > > Details >
> > XML production: Production 'AttValue' not satisfied > > > > > > > > > > >
> What part did I misunderstood. > > > > > > > > > > > > Roelof > > > > > > >

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.