|
Subject: Re: [xsl] Problem with generating sequence ids. From: Mukul Gandhi <mukul_gandhi@xxxxxxxxx> Date: Wed, 6 Jul 2005 06:13:50 -0700 (PDT) |
XSLT 2.0 spec has introduced a function to find a
random permutation of a sequence of integers. I don't
know if this helps, but Saxon 8.4 provides
implementation of this function along with the full
XSLT specification.
Please take my word, Saxon deserves 10/10 rating in
XSLT circles.
Regards,
Mukul
--- Lakshmi narayana <lchintala@xxxxxxxxxxxx> wrote:
>
> Hi,
> I am facing the problem to create the IDs to the
> elements. See the
> following example XML file.
> <A1 sequence="1">
> <B1 sequence="3"/>
> <B2 sequence="1">
> <C1 sequence="4"></C1>
> <C2 sequence="11">
> <D1 sequence="01"/>
> </C2>
> </B2>
> </A1>
>
> I want the xslt code to get the result as
> <A1 sequence="1" id="001000000000000">
> <B1 sequence="3" id="001003000000000"/>
> <B2 sequence="1" id="001001000000000">
> <C1 sequence="4"
> id="001001004000000"></C1>
> <C2 sequence="11"
> id="001001011000000">
> <D1 sequence="01"
> id="001001011001000"/>
> </C2>
> </B2>
> </A1>
>
> Steps to generate id value :
> Note : Maximum width of id is 15.
> Maximum width of sequence attribute is
> 3.
> If the sequence is like 3, we have to replace it by
> adding leading zeros
> and make that sequence as 3 digit number.
> 1) Get the sequence attribute value.
> For example for node <A1>
> Assume that id=000000000000000
> if(sequence attribute value is not null)
> {
> then id=sequnce value in 3 digit
> format+000000000000
> (eg: for A, seq value is 1. then the result id is
> 001000000000000)
> )
>
> Here we filled the first 3 positions in the id
> value. Remaining all are
> zeros only.
> 2) Get the sequnece attribute value of child of A1.
> ie..B1 node.
> Because it is having the parent, id = (id value of
> parent)
> if(sequence attribute value of current node is not
> null)
> {
> get the sequence attribute value of current node.
> add this value to the computed id value of its
> parent.
> eg: its parent id value is 001000000000000
> its sequence value is 3.
> Then the new id will come like this..
> parent id : 001000000000000
> sequenc : 003
> --------------------------------------------
> Result Id : 001003000000000
> ---------------------------------------------
> }
> else
> current id = parent id.
> 3) for our xml, ids are like this
> 000000000000000
> A1 001
> -----------------------------------
> 001000000000000
> B1 003
> -----------------------------------
> 001003000000000
> B2 001
> ------------------------------------------
> 001001000000000
>
> For C1: 001001000000000
> 004
> --------------------------------------
> 001001004000000
>
> Can any one give me the xslt code for this.
>
> Thanks,
> Laxmi Narayana Babu.
>
>
____________________________________________________
Sell on Yahoo! Auctions no fees. Bid on great items.
http://auctions.yahoo.com/
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] Problem with generating s, Michael Kay | Thread | Re: [xsl] Problem with generating s, Joris Gillis |
| RE: [xsl] Problem with generating s, Michael Kay | Date | [xsl] Problem with generating seque, Lakshmi narayana |
| Month |