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

RE: Another <xsl:key> problem

Subject: RE: Another <xsl:key> problem
From: "Gabriel Osorio" <gosorio@xxxxxxxxxxx>
Date: Wed, 28 Sep 2005 10:17:21 -0500
gabriel osorio
-----Original Message-----
From: Ragulf Pickaxe [mailto:ragulf.pickaxe@xxxxxxxxx] 
Sent: Wednesday, September 28, 2005 1:08 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  Another <xsl:key> problem

Hi Aaron,

I have looked a bit on your problem.

Presumably you have:
<text:p>
    <bookmark-start id="bib1"/>
    <user-field name="bib-reference">Ref</user-field>
</text:p>
...

--------------------------

Sorry for interfering, but I need understand this.

First Aaron message was:

--------------------------


hi all,
   I have a problem with <xsl:key>, here is my xml and sample output.

<root>
       <text:p>
              <bookmark-start id="bib1"/>
              <user-field
name="bib-reference">Ref</user-field>
       </text:p>
       <text:p>
              <user-field
name="sb:reference">BB</user-field>
       </text:p>
       <text:p>
              <user-field
name="sb:contribution">Contribution</user-field>
       </text:p>
       <text:p>
              <user-field
name="sb:authors">Authors</user-field>
       </text:p>
       <text:p>
               <user-field
name="sb:author">Author</user-field>
               <user-field
name="sb:given-name">Given-Name</user-field>
               <user-text>A.</user-text>
               <user-field
name="sb:surname">Surname</user-field>
               <user-text>Andrade</user-text>
       </text:p>
       <text:p>
                <user-field
name="sb:title">Title</user-field>
                <user-text>Mathematics</user-text>
       </text:p>
       <text:p>
                <user-field
name="sb:host">Host</user-field>
       </text:p>
       <text:p>
                <user-field
name="sb:issue">Issue</user-field>
       </text:p>
       <text:p>
                <user-field
name="sb:series">Series</user-field>
        </text:p>
       <text:p>
                <user-field
name="sb:title">Title</user-field>
                <user-text>Science</user-text>
       </text:p>
       <text:p>
                <user-field
name="sb:volume-nr">Volume-nr</user-field>
                <user-text>12</user-text>
       </text:p>
       <text:p>
                <user-field
name="sb:date">Date</user-field>
                <user-text>1988</user-text>
                <bookmark-end id="bib1"/>
       </text:p>
...............
</root>

output:
<bib-reference id="bib1">  
    <sb:reference>
        <sb:contribution>
            <ce:authors>
                <ce:author>
                         
<sb:given-name>A.</sb:given-name>
                         
<sb:surname>Andrade</sb:surname>
                </ce:author>
            </ce:authors>
        <sb:title>Mathematics</sb:title>
        </sb:contribution>
        <sb:host>
            <sb:issue>
                <sb:series>
                    <sb:title>Science</sb:title>
                    <sb:volume-nr>12</sb:volume-nr>
                </sb:series>
            <sb:date>1988</sb:date>
            </sb:issue>
        </sb:host>
    </sb:reference>
 </bib-reference>
.....................

my problem is, I want to create an index containing all the nodes from
<bookmark-start> to <bookmark-end> with their corresponding id's, then from
that, separate all the nodes from <bb> to <host> then from <host> to <date>.
I used <xsl:key> to create an index for that, then used the <xsl:for-each>
to process all the nodes for every  key that I created, is my declaration
with <xsl:key> and key() correct?

    <xsl:key name="bookmark_start"
match="text:bookmark-start" use="@id"/>
    <xsl:key name="bookmark_end"
match="text:bookmark-end" use="@id"/>
   
    <xsl:key name="contribution"
match="text:user-field-get" use="@name"/>
    <xsl:key name="h_issue"
match="text:user-field-get" use="@name"/>

<xsl:template match="bookmark-start">

        <xsl:variable name="begin1" 
select="key('bookmark_start',concat('bib',
$bib_number))[1] /ancestor-or-self::text:p[1]"/>
        <xsl:variable name="end1"    
select="key('bookmark_end',concat('bib',
$bib_number))[1]/ancestor-or-self::text:p[1]"/>      

        <xsl:variable name="biblio" 
select="($begin1/following-sibling::node()|$begin1)[(.|following-sibling::*)
[generate-id()=generate-id($end1)]]"/>

        <xsl:variable name="contrib_start" 
select="key('contribution','sb:contribution')[$biblio]/ancestor-or-self::tex
t:p[$bib_number]"/>
        <xsl:variable name="contrib_end"  
select="key('contribution','sb:issue')[$biblio]/ancestor-or-self::text:p[$bi
b_number]"/>
     
        <xsl:variable name="contrib_sample" 
select="($contrib_start/following-sibling::node()|$contrib_start)[(.|followi
ng-sibling::*)[generate-id()=generate-id($contrib_end)]]"/>
 

        <xsl:variable name="begin" 
select="key('h_issue','sb:issue')[$bib_number]
/ancestor-or-self::text:p[$bib_number]"/>
        <xsl:variable name="end"    
select="key('h_issue','sb:date')[$bib_number]/ancestor-or-self::text:p[$bib_
number]"/>
     
        <xsl:variable name="sample" 
select="($begin/following-sibling::node()|$begin)[(.|following-sibling::*)[g
enerate-id()=generate-id($end)]]"/>
 

       <xsl:for-each  $biblio
                    <xsl:for-each $contrib_sample
                    </xsl:for-each>
                    <xsl:for-each $sample
                    </xsl:for-each>
       </xsl:for-each>

  </xsl:template>

thanks and regards.
aaron

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.