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

Re: unique-sequence-numbering

Subject: Re: unique-sequence-numbering
From: "Yates, Danny (ANTS)" <danny.yates@xxxxxxxxxx>
Date: Thu, 8 Aug 2002 09:00:26 +0100
call template param node
Hi,

Sorry if this message doesn't thread properly - I'm normally a
digest subscriber, so I'm having to "fake it"!

>  <?xml version="1.0"?>
>  <students>
>      <student id = "101">
>        <name>A</name>
>        <address>XXX</address>
>      </student>
>      <student id = "201">
>        <name>B</name>
>        <address>YYY</address>
>      </student>
>      <student id = "301">
>        <name>C</name>
>        <address>XXX</address>
>      </student>
>      <student id = "401">
>        <name>E</name>
>      <address>YYY<address>
>    </student>
>  </students>

Here is some XSL-like pseudo-code which may help. My XSL is not
hot enough to make it up on-the-fly and I don't want to confuse
you by sending something which looks a lot like XSL, but isn't!

template match="students"
  call-template name="OutputStudent"
    with-param node=student[1]
    with-param seq=1

template name="OutputStudent"
  param node
  param seq

  if $node/address = "YYY"
    write out CSV line including $seq
    write out CSV line including ($seq + 1)
    call-template name="OutputStudent"
      with-param node=$node/following-sibling::student[1]
      with-param seq=$seq + 2

  if $node/address != "YYY"
    write out CSV line including $seq
    call-template name="OutputStudent"
      with-param node=$node/following-sibling::student[1]
      with-param seq=$seq + 1

An alternative implementation of the OutputStudent template:

template name="OutputStudent"
  param node
  param seq
  param already-repeated default 0

  write out CSV line including $seq

  if ($node/address = "YYY") and ($already-repeated = 0)
    call-template name="OutputStudent"
      with-param node=.
      with-param seq = $seq + 1
      with-param already-repeated = 1

  if ($node/address != "YYY") or ($already-repeated != 0)
    call-template name="OutputStudent"
      with-param node=$node/following-sibling::student[1]
      with-param seq=$seq + 1

This separates out the CSV writing code, but makes the 'if'
statements a bit more complex.

You may have to think a bit about the "base case" which stops
recurrsion, i.e. if there is no following-sibling.

Hope that helps,

Dan.

-- 
Danny Yates
Technical Architect
Abbey National Treasury Services
E-mail: Danny.Yates@xxxxxxxxxx


***************************************************************************
This communication (including any attachments) contains confidential information.  If you are not the intended recipient and you have received this communication in error, you should destroy it without copying, disclosing or otherwise using its contents.  Please notify the sender immediately of the error.

Internet communications are not necessarily secure and may be intercepted or changed after they are sent.  Abbey National Treasury Services plc does not accept liability for any loss you may suffer as a result of interception or any liability for such changes.  If you wish to confirm the origin or content of this communication, please contact the sender by using an alternative means of communication.

This communication does not create or modify any contract and, unless otherwise stated, is not intended to be contractually binding.

Abbey National Treasury Services plc. Registered Office:  Abbey National House, 2 Triton Square, Regents Place, London NW1 3AN.  Registered in England under Company Registration Number: 2338548.  Regulated by the Financial Services Authority (FSA).
***************************************************************************


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.