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

Re: xpath expression restriction

Subject: Re: xpath expression restriction
From: ac <ac@xxxxxxxxxxxxx>
Date: Fri, 04 Mar 2011 05:52:16 -0500
Re:  xpath expression restriction
Hi Michael,

Clear and thorough, again.
I appreciate.

Thank you.

Regards,
Andre

PS: I hope that it clears-up for the book(s) too.


On 04/03/2011 08:10, ac wrote:
Hi Mukul,

It works with the braces.
Still I wonder why it did not pick the "if" and evaluate it?

The grammar requires the operand of "gt" to be a RangeExpr, and a conditional expression is not a RangeExpr.


If a conditional expression were allowed here, it would create (more) confusion over expressions such as

3 gt if (a) then 2 else 3 + 5

Personally I would have preferred a self-closing conditional expression, like Algol-68's

if c then a else b fi

but the WG was convinced it was better to repeat the mistakes of the past in the interests of familiarity.

Michael Kay
Saxonica

I am not sure if I understand your question right, but
In the example, $cond is only checking for empty (null) or not.
In the code, it is more like
if ($logging or ($logged and string($nxtid))) then 1 else 0
also, abc is a sequence closer to
$data//wf/*
and the idea is simply to not copy the first element, under some condition
also, it is not really an xsl:copy-of, but an xsl:sequence ...


Thank you.

Regards,
ac




Hi Andre,
      I'm not sure, but perhaps writing the whole if condition in
braces may force evaluation of the if expression before providing this
operand to operator "gt".

i.e could you please try if following works,

<xsl:copy-of select="abc[position() gt (if ($cond) then 1 else 0)]"/>

also curious to know, what do you write to evaluate $cond?

On Fri, Mar 4, 2011 at 11:22 AM, ac<ac@xxxxxxxxxxxxx> wrote:
Hi,

There must be a reason why I can write

<xsl:variable name="x" select="if ($cond) then 1 else 0"/>
<xsl:copy-of select="abc[position() gt $x]"/>

but not

<xsl:copy-of select="abc[position() gt if ($cond) then 1 else 0]"/>

What is the reason?  Is there any way to avoid having to declare the
variable?

Thank you,

Regards,
Andre

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.