Subject: RE: [xsl] Another <xsl:key> problem From: "Gabriel Osorio" <gosorio@xxxxxxxxxxx> Date: Wed, 28 Sep 2005 10:17:21 -0500 |
-----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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Another <xsl:key> problem, Ragulf Pickaxe | Thread | Re: [xsl] Another <xsl:key> problem, Ragulf Pickaxe |
Re: [xsl] Basic question about Name, Geert Josten | Date | Re: [xsl] Basic question about Name, David Carlisle |
Month |