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

Re: key from one file to another set of files

Subject: Re: key from one file to another set of files
From: "Ganesh Babu N" <nbabuganesh@xxxxxxxxx>
Date: Fri, 12 Dec 2008 15:48:42 +0530
Re:  key from one file to another set of files
Can somebody help me in solving this problem. Please

Regards,
Ganesh


On Thu, Dec 11, 2008 at 5:24 PM, Ganesh Babu N <nbabuganesh@xxxxxxxxx> wrote:
> Yes mike you are correct. I am getting all the col[3] values in a single go.
>
> But I am not getting the result. I have tried in different manner in
> which i can able to fetch info from collection() files and which are
> matching with col[1] value in the input but I am unable to get col[3]
> and col[2] values which is matching with col[1].
>
> Please guide. Here is my latest XSL:
>
> <xsl:key name="order" match="/issues/articles/row/col[3]"
> use="/issues/articles/row/col[1]"/>
>        <xsl:template match="/" name="main">
>                <xsl:variable name="index" select="."/>
>        <cover-body>
> <xsl:for-each select="collection('file:///D:/cover/sample
> xmls/pageall/else/nima?select=*.xml;recurse=yes;on-error=ignore')">
>        <xsl:variable name="a" select="."/>
>        <xsl:if test="$a/article/item-info/aid =
> document('input.xml')/issue/articles/row/col[1]">
>        <para>
>        <aid><xsl:value-of select="$a/article/item-info/aid"/></aid>
>        <aug><xsl:apply-templates
> select="$a/article/head/ce:author-group/ce:author"/>            <xsl:apply-templates
> select="$a/article/head/ce:author-group/ce:collaboration"/></aug>
>        <article><xsl:value-of select="$a/article/head/ce:title"/></article>
>        <page><xsl:value-of
> select="key('order',$a/article/item-info/aid,$index)"/></page>
> </para>
> </xsl:if>
> </xsl:for-each>
> </cover-body>
> </xsl:template>
>
> Regards,
> Ganesh
>
> On Wed, Dec 10, 2008 at 5:30 PM, Michael Kay <mike@xxxxxxxxxxxx> wrote:
>> The key() function searches the document containing the context node, unless
>> you supply a third argument, in which case it searches the document (or
>> subtree) identified in the third argument. You want
>>
>> <xsl:template match="/" name="main">
>>  <xsl:variable name="index" select="."/>
>>
>>   ... then ...
>>
>>  <xsl:if test="key('order', '$a/article/item-info/aid', $index)">
>>
>> Except that you don't only want to test whether the article exists, you want
>> to find the right row, and use it when you do
>>
>> <page>
>> <xsl:value-of select="document('input.xml')/articles/row/col[3]"/>
>> </page>
>>
>> because that is otherwise going to give you the third column of every row.
>>
>> Michael Kay
>> http://www.saxonica.com/
>>
>>
>>> -----Original Message-----
>>> From: Ganesh Babu N [mailto:nbabuganesh@xxxxxxxxx]
>>> Sent: 10 December 2008 11:48
>>> To: XSL
>>> Subject:  key from one file to another set of files
>>>
>>> Dear All,
>>>
>>> input.xml
>>>
>>> <articles>
>>>    <row>
>>>          <col>4039</col>
>>>          <col>Review Articles</col>
>>>          <col>1</col>
>>>       </row>
>>>       <row>
>>>          <col>3957</col>
>>>          <col>Review Articles</col>
>>>          <col>9</col>
>>>       </row>
>>>       <row>
>>>          <col>3986</col>
>>>          <col>Papers</col>
>>>          <col>22</col>
>>>       </row>
>>>       <row>
>>>          <col>3985</col>
>>>          <col>Papers</col>
>>>          <col>29</col>
>>>       </row>
>>> </articles>
>>>
>>> x number of article.xml files with content:
>>>
>>> 1.xml
>>>
>>> <article>
>>> <aid>4039</aid>
>>> <author>nnn</author>
>>> <title>xxxxx<title>
>>> </article>
>>>
>>> 2.xml
>>>
>>> <article>
>>> <aid>3957</aid>
>>> <author>nnn</author>
>>> <title>xxxxx<title>
>>> </article>
>>>
>>> 3.xml
>>>
>>> <article>
>>> <aid>3986</aid>
>>> <author>nnn</author>
>>> <title>xxxxx<title>
>>> </article>
>>>
>>> 4.xml
>>>
>>> <article>
>>> <aid>3985</aid>
>>> <author>nnn</author>
>>> <title>xxxxx<title>
>>> </article>
>>>
>>> Required output:
>>>
>>> <cover-body>
>>> <section>
>>> <section-title>Review Articles</section-title>
>>> <para><aid>4039</aid> <author>nnn</author>
>>> <title>xxxxx<title> <page>1</page></para>
>>> <para><aid>3957</aid> <author>nnn</author>
>>> <title>xxxxx<title> <page>9</page></para> </section>
>>> <section> <section-title>Papers</sectitle>
>>> <para><aid>3986</aid> <author>nnn</author>
>>> <title>xxxxx<title> <page>1</page></para>
>>> <para><aid>3985</aid> <author>nnn</author>
>>> <title>xxxxx<title> <page>9</page></para> </section> <cover-body>
>>>
>>> XSL:
>>> <xsl:template match="/" name="main">
>>> <cover-body>
>>>                       <xsl:for-each
>>> select="collection('file:///D:/cover/sample
>>> xmls/pageall/else/nima?select=*.xml;recurse=yes;on-error=ignore')">
>>>                               <xsl:variable name="a" select="."/>
>>>                               <xsl:if test="key('order',
>>> '$a/article/item-info/aid')">
>>>                               <xsl:if
>>> test="(document('input.xml')/articles/row/col[2])[1]">
>>>                               <section>
>>>                               <section-title><xsl:value-of
>>> select="."/></section-title>
>>>                               <para>
>>>                                       <aid>
>>>                                               <xsl:value-of
>>> select="$a/article/item-info/aid"/>
>>>                                       </aid>
>>>                                       <aug>
>>>
>>> <xsl:apply-templates
>>> select="$a/article/head/ce:author-group/ce:author"/>
>>>                                       </aug>
>>>                                       <article>
>>>                                               <xsl:value-of
>>> select="$a/article/head/ce:title"/>
>>>                                       </article>
>>>                                       <page>
>>>                                               <xsl:value-of
>>> select="document('input.xml')/articles/row/col[3]"/>
>>>                                       </page>
>>>                               </para>
>>>                               </section>
>>>                               </xsl:if>
>>>                               </xsl:if>
>>>                       </xsl:for-each>
>>>               </cover-body>
>>> </xsl:template>
>>>
>>> The key is not working for me. i have tried adding the
>>> document() in the match but it is showing the error.
>>>
>>> Regards,
>>> Ganesh

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.