xsl-list
[Top] [All Lists]

[xsl] Extracting data from external file

2009-08-31 05:51:22
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[(_at_)a = @n]/y"/></found>
</xsl:template>
 
OUTPUT
<found>first second</found>
<found>first second</found>
 
Required OUTPUT
<found>first</found>
<found>fsecond</found>
 
Thanks


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>