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

Re: Complex recursion in XSLT 1.0

Subject: Re: Complex recursion in XSLT 1.0
From: "Manfred Staudinger" <manfred.staudinger@xxxxxxxxx>
Date: Fri, 22 Feb 2008 17:27:57 +0100
Re:  Complex recursion in XSLT 1.0
>   Bizarre...  I've checked a couple of algorithms books around there
>  and all assume LIFO = stack and FIFO = queue (yes, I've also always
>  seen FIFO instead of LILO, but that's not the point).
Sorry for that, I should have used FIFO instead of LILO (it's the
same) and thanks for your patience.

For a stack you can use only top, push and pop (per definition), but
to me a queue is much more general and may be manipulated in many
different ways. Now, a non-empty stack is a LIFO-stack if and only if
the relation
     top($s) == top(pop(push($s)))
holds true, and it is a FIFO-stack if and only if
     top($s) != top(pop(push($s)))
holds true. So, a pop(push($s)) is a NOP for a LIFO-stack, but not for
a (non-empty) FIFO-stack.

Now, taking the code given by Florent, and taking into account the
remark from Michael, a FIFO-stack would look like:
 <xsl:function name="x:push" as="item()+">
      <xsl:param name="stack" as="item()*"/>
      <xsl:param name="item"  as="item()"/>
      <xsl:sequence select="$stack, $item"/>
   </xsl:function>

   <xsl:function name="x:pop" as="item()*">
      <xsl:param name="stack" as="item()*"/>
      <xsl:sequence select="remove($stack, 1)"/>
   </xsl:function>

   <xsl:function name="x:top" as="item()?">
      <xsl:param name="stack" as="item()*"/>
      <xsl:sequence select="$stack[1]"/>
   </xsl:function>

I also looked up the ADT's (Abstract Data Types) at Aberdeen University
http://www.maths.abdn.ac.uk/~igc/tch/mx4002/notes/node48.html
and found the terminology changed from what I used to know, but is in
accordance with Florents usage. So
ADT stack == LIFO-stack
ADT queue == FIFO-stack
I think both variants are still in use and the terminology has not
settled yet, as the use of terms like "stack" or "pushdown stack" seem
to show.

Regards,

Manfred

On 21/02/2008, Florent Georges <lists@xxxxxxxxxxxx> wrote:
> Manfred Staudinger wrote:
>
>  > On 21/02/2008, Florent Georges wrote:
>
>
> > >   I don't understand.  By LILO I assume a queue and by LIFO
>  > a stack.
>
>  > No, both are meant to be stacks.
>
>
>   Bizarre...  I've checked a couple of algorithms books around there
>  and all assume LIFO = stack and FIFO = queue (yes, I've also always
>  seen FIFO instead of LILO, but that's not the point).
>
>   Besides defining top, pop and push, there are also relations like:
>
>     top($s) == top(pop(push($s)))
>
>  those make the difference between both, I think.  Do you have a ref
>  with a "FIFO stack"?
>
>   Interestingly, Sedgewick uses "stack" and "queue," as well as the
>  more verbose "pushdown stack" and "FIFO queue," it seems in order to
>  distinguish the "FIFO queue" from the "priority queue" and the
>  "generalized queue" (the generalization of all those ADTs.)  There is
>  even a "LIFO queue" in the index (refering to stacks in the text.)
>
>   Regards,
>
>
>  --drkm

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.