Result order for for-each

View: New views
4 Messages — Rating Filter:   Alert me  

Result order for for-each

by Dan Vint :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have a stylesheet that is used to generate Next/Previous information for
XML being chnked into HTML pages. The code in question uses a for-each
like this:

<xsl:for-each select="following-sibling::*[name()='chapter' or
                     name()='section' or name()='subsection' or
                     name()='subpara3' or name()='subpara2' or
                     name()='subpara1' or name()='para0' or
                     name()='code' or name()='prelim-proced'][1]">
      <xsl:call-template name="build-link-dest" />
</xsl:for-each>

This is used to produce a line like this in the HTML file that is then
read by Javascript to create a Next/Previous button.

var  nextPage="chap1-1-3.html#p0000032chap1-2.html#e0000003chap2.html#c0000003";

I'm not sure why the previous developer created it this way, but the
Javascript takes the first entry chap1-1-3.html#p0000032 and makes a
hyperlink and ignores all the other returned results.

This was running with Saxon 6 (stable version) and I recently switched to
Saxon 9. The results are being returned in what appears to be the reverse
order and now my links go to the wrong location.

Is there any requirement that for-each produce results in a certain order
that maybe has changed? I'm assuming that this is unspecified and that
this was a side effect of Saxon 6 that we shouldn't have depended upon.

I'm looking into this some more, but I wanted to confirm this suspicion
before I went much further.

..dan

---------------------------------------------------------------------------
Danny Vint

Specializing in Panoramic Images of California and the West
http://www.dvint.com

Voice:510:522-4703
FAX: 801-749-3229

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@...
https://lists.sourceforge.net/lists/listinfo/saxon-help 

Re: Result order for for-each

by Michael Kay :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I can't see any reason why anything should have changed here.

I'm rather puzzled by your description of the problem, because the select
expression has a predicate [1] at the end, so it only selects a single node,
so I can't see where any re-ordering could take place. Perhaps there's
something else happening in the code that you haven't shown us?

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 


> -----Original Message-----
> From: Dan Vint [mailto:dvint@...]
> Sent: 29 October 2009 11:59
> To: saxon-help@...
> Subject: [saxon] Result order for for-each
>
> I have a stylesheet that is used to generate Next/Previous
> information for XML being chnked into HTML pages. The code in
> question uses a for-each like this:
>
> <xsl:for-each select="following-sibling::*[name()='chapter' or
>                      name()='section' or name()='subsection' or
>                      name()='subpara3' or name()='subpara2' or
>                      name()='subpara1' or name()='para0' or
>                      name()='code' or name()='prelim-proced'][1]">
>       <xsl:call-template name="build-link-dest" /> </xsl:for-each>
>
> This is used to produce a line like this in the HTML file
> that is then read by Javascript to create a Next/Previous button.
>
> var  
> nextPage="chap1-1-3.html#p0000032chap1-2.html#e0000003chap2.ht
> ml#c0000003";
>
> I'm not sure why the previous developer created it this way,
> but the Javascript takes the first entry
> chap1-1-3.html#p0000032 and makes a hyperlink and ignores all
> the other returned results.
>
> This was running with Saxon 6 (stable version) and I recently
> switched to Saxon 9. The results are being returned in what
> appears to be the reverse order and now my links go to the
> wrong location.
>
> Is there any requirement that for-each produce results in a
> certain order that maybe has changed? I'm assuming that this
> is unspecified and that this was a side effect of Saxon 6
> that we shouldn't have depended upon.
>
> I'm looking into this some more, but I wanted to confirm this
> suspicion before I went much further.
>
> ..dan
>
> --------------------------------------------------------------
> -------------
> Danny Vint
>
> Specializing in Panoramic Images of California and the West
> http://www.dvint.com
>
> Voice:510:522-4703
> FAX: 801-749-3229
>
> --------------------------------------------------------------
> ----------------
> Come build with us! The BlackBerry(R) Developer Conference in
> SF, CA is the only developer event you need to attend this
> year. Jumpstart your developing skills, take BlackBerry
> mobile applications to market and stay ahead of the curve.
> Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> saxon-help mailing list archived at
> http://saxon.markmail.org/ saxon-help@...
> https://lists.sourceforge.net/lists/listinfo/saxon-help 


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@...
https://lists.sourceforge.net/lists/listinfo/saxon-help 

Re: Result order for for-each

by Dan Vint :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I've taken the code down to the bare minimum to make sure there isn't
anything else going on. this is all part of a choose statement that first
determines if I need to look at the following, ancestor or descendant
paths and after that determineation this code is run.

I pulled out the predicate and this seems to put them in the right order,
the other change is that I now have some extra returned values.

..dan

---------------------------------------------------------------------------
Danny Vint

Specializing in Panoramic Images of California and the West
http://www.dvint.com

Voice:510:522-4703
FAX: 801-749-3229

On Thu, 29 Oct 2009, Michael Kay wrote:

>
> I can't see any reason why anything should have changed here.
>
> I'm rather puzzled by your description of the problem, because the select
> expression has a predicate [1] at the end, so it only selects a single node,
> so I can't see where any re-ordering could take place. Perhaps there's
> something else happening in the code that you haven't shown us?
>
> Regards,
>
> Michael Kay
> http://www.saxonica.com/
> http://twitter.com/michaelhkay
>
>
>> -----Original Message-----
>> From: Dan Vint [mailto:dvint@...]
>> Sent: 29 October 2009 11:59
>> To: saxon-help@...
>> Subject: [saxon] Result order for for-each
>>
>> I have a stylesheet that is used to generate Next/Previous
>> information for XML being chnked into HTML pages. The code in
>> question uses a for-each like this:
>>
>> <xsl:for-each select="following-sibling::*[name()='chapter' or
>>                      name()='section' or name()='subsection' or
>>                      name()='subpara3' or name()='subpara2' or
>>                      name()='subpara1' or name()='para0' or
>>                      name()='code' or name()='prelim-proced'][1]">
>>       <xsl:call-template name="build-link-dest" /> </xsl:for-each>
>>
>> This is used to produce a line like this in the HTML file
>> that is then read by Javascript to create a Next/Previous button.
>>
>> var
>> nextPage="chap1-1-3.html#p0000032chap1-2.html#e0000003chap2.ht
>> ml#c0000003";
>>
>> I'm not sure why the previous developer created it this way,
>> but the Javascript takes the first entry
>> chap1-1-3.html#p0000032 and makes a hyperlink and ignores all
>> the other returned results.
>>
>> This was running with Saxon 6 (stable version) and I recently
>> switched to Saxon 9. The results are being returned in what
>> appears to be the reverse order and now my links go to the
>> wrong location.
>>
>> Is there any requirement that for-each produce results in a
>> certain order that maybe has changed? I'm assuming that this
>> is unspecified and that this was a side effect of Saxon 6
>> that we shouldn't have depended upon.
>>
>> I'm looking into this some more, but I wanted to confirm this
>> suspicion before I went much further.
>>
>> ..dan
>>
>> --------------------------------------------------------------
>> -------------
>> Danny Vint
>>
>> Specializing in Panoramic Images of California and the West
>> http://www.dvint.com
>>
>> Voice:510:522-4703
>> FAX: 801-749-3229
>>
>> --------------------------------------------------------------
>> ----------------
>> Come build with us! The BlackBerry(R) Developer Conference in
>> SF, CA is the only developer event you need to attend this
>> year. Jumpstart your developing skills, take BlackBerry
>> mobile applications to market and stay ahead of the curve.
>> Join us from November 9 - 12, 2009. Register now!
>> http://p.sf.net/sfu/devconference
>> _______________________________________________
>> saxon-help mailing list archived at
>> http://saxon.markmail.org/ saxon-help@...
>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> saxon-help@...
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@...
https://lists.sourceforge.net/lists/listinfo/saxon-help 

Re: Result order for for-each

by Michael Kay :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

If you can supply a repro for the problem that shows different results for
Saxon6 and Saxon9, I'll be happy to look at it.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 

> -----Original Message-----
> From: Dan Vint [mailto:dvint@...]
> Sent: 29 October 2009 17:12
> To: Mailing list for the SAXON XSLT and XQuery processor
> Subject: Re: [saxon] Result order for for-each
>
> I've taken the code down to the bare minimum to make sure
> there isn't anything else going on. this is all part of a
> choose statement that first determines if I need to look at
> the following, ancestor or descendant paths and after that
> determineation this code is run.
>
> I pulled out the predicate and this seems to put them in the
> right order, the other change is that I now have some extra
> returned values.
>
> ..dan
>
> --------------------------------------------------------------
> -------------
> Danny Vint
>
> Specializing in Panoramic Images of California and the West
> http://www.dvint.com
>
> Voice:510:522-4703
> FAX: 801-749-3229
>
> On Thu, 29 Oct 2009, Michael Kay wrote:
>
> >
> > I can't see any reason why anything should have changed here.
> >
> > I'm rather puzzled by your description of the problem, because the
> > select expression has a predicate [1] at the end, so it
> only selects a
> > single node, so I can't see where any re-ordering could take place.
> > Perhaps there's something else happening in the code that
> you haven't shown us?
> >
> > Regards,
> >
> > Michael Kay
> > http://www.saxonica.com/
> > http://twitter.com/michaelhkay
> >
> >
> >> -----Original Message-----
> >> From: Dan Vint [mailto:dvint@...]
> >> Sent: 29 October 2009 11:59
> >> To: saxon-help@...
> >> Subject: [saxon] Result order for for-each
> >>
> >> I have a stylesheet that is used to generate Next/Previous
> >> information for XML being chnked into HTML pages. The code in
> >> question uses a for-each like this:
> >>
> >> <xsl:for-each select="following-sibling::*[name()='chapter' or
> >>                      name()='section' or name()='subsection' or
> >>                      name()='subpara3' or name()='subpara2' or
> >>                      name()='subpara1' or name()='para0' or
> >>                      name()='code' or name()='prelim-proced'][1]">
> >>       <xsl:call-template name="build-link-dest" /> </xsl:for-each>
> >>
> >> This is used to produce a line like this in the HTML file that is
> >> then read by Javascript to create a Next/Previous button.
> >>
> >> var
> >> nextPage="chap1-1-3.html#p0000032chap1-2.html#e0000003chap2.ht
> >> ml#c0000003";
> >>
> >> I'm not sure why the previous developer created it this
> way, but the
> >> Javascript takes the first entry
> >> chap1-1-3.html#p0000032 and makes a hyperlink and ignores all the
> >> other returned results.
> >>
> >> This was running with Saxon 6 (stable version) and I recently
> >> switched to Saxon 9. The results are being returned in
> what appears
> >> to be the reverse order and now my links go to the wrong location.
> >>
> >> Is there any requirement that for-each produce results in
> a certain
> >> order that maybe has changed? I'm assuming that this is
> unspecified
> >> and that this was a side effect of Saxon 6 that we shouldn't have
> >> depended upon.
> >>
> >> I'm looking into this some more, but I wanted to confirm this
> >> suspicion before I went much further.
> >>
> >> ..dan
> >>
> >> --------------------------------------------------------------
> >> -------------
> >> Danny Vint
> >>
> >> Specializing in Panoramic Images of California and the West
> >> http://www.dvint.com
> >>
> >> Voice:510:522-4703
> >> FAX: 801-749-3229
> >>
> >> --------------------------------------------------------------
> >> ----------------
> >> Come build with us! The BlackBerry(R) Developer Conference
> in SF, CA
> >> is the only developer event you need to attend this year.
> Jumpstart
> >> your developing skills, take BlackBerry mobile
> applications to market
> >> and stay ahead of the curve.
> >> Join us from November 9 - 12, 2009. Register now!
> >> http://p.sf.net/sfu/devconference
> >> _______________________________________________
> >> saxon-help mailing list archived at
> >> http://saxon.markmail.org/ saxon-help@...
> >> https://lists.sourceforge.net/lists/listinfo/saxon-help
> >
> >
> >
> ----------------------------------------------------------------------
> > -------- Come build with us! The BlackBerry(R) Developer
> Conference in
> > SF, CA is the only developer event you need to attend this year.
> > Jumpstart your developing skills, take BlackBerry mobile
> applications
> > to market and stay ahead of the curve. Join us from
> November 9 - 12,
> > 2009. Register now!
> > http://p.sf.net/sfu/devconference
> > _______________________________________________
> > saxon-help mailing list archived at http://saxon.markmail.org/ 
> > saxon-help@...
> > https://lists.sourceforge.net/lists/listinfo/saxon-help
> >
>
> --------------------------------------------------------------
> ----------------
> Come build with us! The BlackBerry(R) Developer Conference in
> SF, CA is the only developer event you need to attend this
> year. Jumpstart your developing skills, take BlackBerry
> mobile applications to market and stay ahead of the curve.
> Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> saxon-help mailing list archived at
> http://saxon.markmail.org/ saxon-help@...
> https://lists.sourceforge.net/lists/listinfo/saxon-help 


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@...
https://lists.sourceforge.net/lists/listinfo/saxon-help