Re: [xsl] Accessing two XML files from XSL file

Subject: Re: [xsl] Accessing two XML files from XSL file
From: Wolfhart Totschnig <wolfhart@xxxxxxxxxxxxx>
Date: Sat, 09 Jul 2011 22:30:25 -0500
Hi,

If I understand your problem correctly, the document() function is what you need:

<xsl:for-each select="document('second.xml')/xml2/button">

Wolfhart




Sanjaya Liyanage wrote:
Hi,
   I want to access two XML files within my XSL file.How can I achieve
it? Any ideas are welcome

I can access the first.xml file as below because it has the reference
to XSL file(xsl1.xsl).

   <xsl:for-each select="xml1/button">
   <button id="{id}" type="button"
style="position:fixed;top:{y}px;left:{x}px;"><xsl:value-of
select="value"/></button>
   </xsl:for-each>

I want to have something like below which is working which access the second.XML

   <xsl:for-each select="xml2/button">
   <button id="{id}" type="button"
style="position:fixed;top:{y}px;left:{x}px;"><xsl:value-of
select="value"/></button>
   </xsl:for-each>

first.xml

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="xslt1.xsl"?>

<xml1>
<button>
<id>btn1</id>
<x>225</x>
<y>450</y>
<value>Submit</value>
</button>
</xml1>

second.xml

<?xml version="1.0" encoding="UTF-8"?>

<xml2>
<button>
<id>btn2</id>
<x>325</x>
<y>550</y>
<value>Submit</value>
</button>
</xml2>

Thank you
Sanjaya Liyanage

Current Thread