Bug vs spec change?

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Bug vs spec change?

Dave Pawson-2
I had

<xsl:variable name="in" select="'Now is the time'"/>

This block works ok.
[<xsl:sequence select="
for $i in 1 to 5
return (substring($in, $i, 1))"/>]


This fails
[<xsl:sequence select="string-join(
for $i in (string-length($in)) to 1
return (substring($in, $i, 1)),' ')"/>]


Is the x to 1 no longer supported please Mike?
or is it the m to n?

I can't figure out
http://www.w3.org/TR/xpath20/#doc-xpath-ExprSingle

regards



--
Dave Pawson
XSLT XSL-FO FAQ.
http://www.dpawson.co.uk


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: Bug vs spec change?

Michael Kay
The spec changed quite a while ago to disallow descending sequences in (1 to
$n).

The reason for this was that it spoilt the common use case

for $i in 1 to count($SEQ) return $SEQ[$i]

in the case where SEQ was an empty sequence: (1 to 0) returned the sequence
(1,0) and therefore attempted to access two non-existent items in the
sequence/

Instead we introduced a reverse() function so you can write reverse(1 to $n)

Michael Kay

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of
> Dave Pawson
> Sent: 04 November 2005 14:14
> To: [hidden email]
> Subject: [saxon] Bug vs spec change?
>
> I had
>
> <xsl:variable name="in" select="'Now is the time'"/>
>
> This block works ok.
> [<xsl:sequence select="
> for $i in 1 to 5
> return (substring($in, $i, 1))"/>]
>
>
> This fails
> [<xsl:sequence select="string-join(
> for $i in (string-length($in)) to 1
> return (substring($in, $i, 1)),' ')"/>]
>
>
> Is the x to 1 no longer supported please Mike?
> or is it the m to n?
>
> I can't figure out
> http://www.w3.org/TR/xpath20/#doc-xpath-ExprSingle
>
> regards
>
>
>
> --
> Dave Pawson
> XSLT XSL-FO FAQ.
> http://www.dpawson.co.uk
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by:
> Tame your development challenges with Apache's Geronimo App
> Server. Download
> it for free - -and be entered to win a 42" plasma tv or your very own
> Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
> _______________________________________________
> saxon-help mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>




-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

Re: Bug vs spec change?

Dave Pawson-2
Thanks Mike.
  It retains the trend to complexity!

regards DaveP

On 04/11/05, Michael Kay <[hidden email]> wrote:

> The spec changed quite a while ago to disallow descending sequences in (1 to
> $n).
>
> The reason for this was that it spoilt the common use case
>
> for $i in 1 to count($SEQ) return $SEQ[$i]
>
> in the case where SEQ was an empty sequence: (1 to 0) returned the sequence
> (1,0) and therefore attempted to access two non-existent items in the
> sequence/
>
> Instead we introduced a reverse() function so you can write reverse(1 to $n)
>
> Michael Kay
>
> > -----Original Message-----
> > From: [hidden email]
> > [mailto:[hidden email]] On Behalf Of
> > Dave Pawson
> > Sent: 04 November 2005 14:14
> > To: [hidden email]
> > Subject: [saxon] Bug vs spec change?
> >
> > I had
> >
> > <xsl:variable name="in" select="'Now is the time'"/>
> >
> > This block works ok.
> > [<xsl:sequence select="
> > for $i in 1 to 5
> > return (substring($in, $i, 1))"/>]
> >
> >
> > This fails
> > [<xsl:sequence select="string-join(
> > for $i in (string-length($in)) to 1
> > return (substring($in, $i, 1)),' ')"/>]
> >
> >
> > Is the x to 1 no longer supported please Mike?
> > or is it the m to n?
> >
> > I can't figure out
> > http://www.w3.org/TR/xpath20/#doc-xpath-ExprSingle
> >
> > regards
> >
> >
> >
> > --
> > Dave Pawson
> > XSLT XSL-FO FAQ.
> > http://www.dpawson.co.uk
> >
> >
> > -------------------------------------------------------
> > SF.Net email is sponsored by:
> > Tame your development challenges with Apache's Geronimo App
> > Server. Download
> > it for free - -and be entered to win a 42" plasma tv or your very own
> > Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
> > _______________________________________________
> > saxon-help mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/saxon-help
> >
>
>
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by:
> Tame your development challenges with Apache's Geronimo App Server. Download
> it for free - -and be entered to win a 42" plasma tv or your very own
> Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
> _______________________________________________
> saxon-help mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>


--
Dave Pawson
XSLT XSL-FO FAQ.
http://www.dpawson.co.uk


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

Re: Bug vs spec change?

David Carlisle
In reply to this post by Dave Pawson-2

for $i in (string-length($in)) to 1

string-length will be greater than 1 most of the time in which case
Xpath says of a range expression

  If either operand is an empty sequence, or if the integer derived from
  the first operand is greater than the integer derived from the second
  operand, the result of the range expression is an empty sequence.

so your for is iterating over an empty sequence and will return ().


If you go back to
http://www.w3.org/TR/2003/WD-xpath20-20030502/#construct_seq
then xpath said

  If the first operand is less than the second, the sequence is in
  increasing order, otherwise it is in decreasing order.

So this has changed, but not in the last couple of drafts, I think.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

Re: Bug vs spec change?

Dave Pawson-2
On 04/11/05, David Carlisle <[hidden email]> wrote:
>
> for $i in (string-length($in)) to 1

> so your for is iterating over an empty sequence and will return ().

Thanks David.
<xsl:variable name="in" select="'Now is the time'"/>
<b>
<xsl:value-of select="string-join(
for  $i in (reverse((1 to string-length($in))))
return (substring($in, $i, 1)),'')"/>]</b>

Mmm. Works but getting very close to perl^H line noise?

regards


--
Dave Pawson
XSLT XSL-FO FAQ.
http://www.dpawson.co.uk


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

Re: Bug vs spec change?

David Carlisle

> Mmm. Works but getting very close to perl^H line noise?

perhaps you'd prefer

<xsl:variable name="in" select="'Now is the time'"/>
<b>
<xsl:value-of select="codepoints-to-string(reverse(string-to-codepoints($in)))"/>
</b>


but this is the wrong list as not really saxon related.

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: Bug vs spec change?

Michael Kay
In reply to this post by Dave Pawson-2
You can always do

codepoints-to-string(reverse(string-to-codepoints($in)))

In fact the technique of splitting a string into characters using
string-to-codepoints() is often handy when doing complex string handling.

Michael Kay

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of
> Dave Pawson
> Sent: 04 November 2005 14:50
> To: [hidden email]
> Subject: Re: [saxon] Bug vs spec change?
>
> On 04/11/05, David Carlisle <[hidden email]> wrote:
> >
> > for $i in (string-length($in)) to 1
>
> > so your for is iterating over an empty sequence and will return ().
>
> Thanks David.
> <xsl:variable name="in" select="'Now is the time'"/>
> <b>
> <xsl:value-of select="string-join(
> for  $i in (reverse((1 to string-length($in))))
> return (substring($in, $i, 1)),'')"/>]</b>
>
> Mmm. Works but getting very close to perl^H line noise?
>
> regards
>
>
> --
> Dave Pawson
> XSLT XSL-FO FAQ.
> http://www.dpawson.co.uk
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by:
> Tame your development challenges with Apache's Geronimo App
> Server. Download
> it for free - -and be entered to win a 42" plasma tv or your very own
> Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
> _______________________________________________
> saxon-help mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>




-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

Re: Bug vs spec change?

Dave Pawson-2
In reply to this post by David Carlisle
Are you two working together today
(Or just thinking alike after so long )




> <xsl:variable name="in" select="'Now is the time'"/>
> <b>
> <xsl:value-of select="codepoints-to-string(reverse(string-to-codepoints($in)))"/>
> </b>

Certainly neater.

Thanks Both.


--
Dave Pawson
XSLT XSL-FO FAQ.
http://www.dpawson.co.uk


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help