Re: [xsl] Extracting data from external file

Subject: Re: [xsl] Extracting data from external file
From: Ganesh Babu N <nbabuganesh@xxxxxxxxx>
Date: Mon, 31 Aug 2009 17:35:29 +0530
Dear Joga,

remove the space in attribute "a" . In the input it is "file _2"
instead of "file_2" in file_ext.xml

Regards,
Ganesh


On Mon, Aug 31, 2009 at 5:24 PM, Joga Singh Rawat<jrawat@xxxxxxxxxxxxxx>
wrote:
> No results only <found/> empty tag!!!
>
> -----Original Message-----
> From: Jingjun Long [mailto:longjingjun@xxxxxxxxx]
> Sent: Monday, August 31, 2009 3:43 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re: [xsl] Extracting data from external file
>
> hi Joga,
>
> Try this:
>
> <xsl:template match="b">
>  <xsl:variable name="a" select="substring-before(@n, '_')"/>  <xsl:variable
> name="file" select="document(concat('dir/', $a,'_ext.xml'))"/>
>
>  <xsl:variable name="v_n" select="@n"/>
>
>  <found><xsl:value-of select="$file/xxx/x[@a = $v_n]/y"/></found>
> </xsl:template>
>
> Jingjun
>
>
> 2009/8/31 Jingjun Long <longjingjun@xxxxxxxxx>:
>> By looking into the example data you provided, file_ext.xml is loaded
>> twice. Your current output is exactly reflect your logic in the XSLT
>> code.
>>
>> There are many ways to get your expected output but what logic are you
>> going to put there.
>>
>>
>> 2009/8/31 Joga Singh Rawat <jrawat@xxxxxxxxxxxxxx>:
>>> Hi,
>>> I want to extract data from external file i.e. file_ext.xml but not
>>> getting the required OUTPUT. Can anyone correct me about my mistake.
>>>
>>> dir/file_ext.xml
>>> <xxx>
>>>  <x a="file_1">
>>>    <y>first</y>
>>>  </x>
>>>  <x a="file _2">
>>>    <y>second</y>
>>>  </x>
>>> </xxx>
>>>
>>> b.xml
>>> <aaa>
>>>  <b n="file_1">
>>>  <b n="file_2">
>>> </aaa>
>>>
>>> XSLT Code
>>> <xsl:template match="b">
>>>  <xsl:variable name="a" select="substring-before(@n, '_')"/>
>>>  <xsl:variable name="file" select="document(concat('dir/', $a,
>>> '_ext.xml'))"/>
>>>   <found><xsl:value-of select="$file/xxx/x[@a = @n]/y"/></found>
>>> </xsl:template>
>>>
>>> OUTPUT
>>> <found>first second</found>
>>> <found>first second</found>
>>>
>>> Required OUTPUT
>>> <found>first</found>
>>> <found>fsecond</found>
>>>
>>> Thanks

Current Thread