Altova Mailing List Archives


RE: [xsl] Another problem

From: "Gabriel Osorio" <gosorio@----------->
To:
Date: 9/28/2005 3:18:00 PM
-----Original Message-----
From: Ragulf Pickaxe [mailto:ragulf.pickaxe@xxxxxxxxx] 
Sent: Wednesday, September 28, 2005 1:08 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] 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

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.