Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to read 2 xml file in one xsl file?

Status
Not open for further replies.

bala143

Programmer
Sep 24, 2002
3
IN
Hi!
Advance Thanks for responding to this request. List of files are as below
1, business rules will be in business rule.xml file
2, data will be in data.xml file
3, read.xsl file

I want to load the filtered data from data.xml based on business rule from rule.xml using read.xsl file.Is it possible?.please help me in the above regard.

Regards
Bala
 
1. The Rule file
-------------- rule.xml -------------------------------
<rules>
<rule id=&quot;J&quot; color=&quot;orange&quot; face=&quot;verdana&quot;/>
<rule id=&quot;K&quot; color=&quot;blue&quot; face=&quot;comic sans ms&quot;/>
<rule id=&quot;P&quot; color=&quot;firebrick&quot; face=&quot;courier new&quot; />
<rule id=&quot;W&quot; color=&quot;green&quot; mask=&quot;****&quot; face=&quot;arial black&quot;/>
</rules>


2. The Data file
-------------- data.xml -------------------------------
<?xml-stylesheet type=&quot;text/xsl&quot; href=&quot;read.xsl&quot;?>
<products>
<product id=&quot;K1&quot;>
<name>Corn Flakes</name>
<price>12.90</price>
</product>
<product id=&quot;J1&quot;>
<name>Orange Jiuce</name>
<price>120.95</price>
</product>
<product id=&quot;J5&quot;>
<name>Banana Jiuce</name>
<price>750.95</price>
</product>
<product id=&quot;P6&quot;>
<name>Yam Pie</name>
<price>10.25</price>
</product>
<product id=&quot;W3&quot;>
<name>Smoked Herbs</name>
<price>320.00</price>
</product>
</products>



3. The Read file
-------------- read.xsl -------------------------------

<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?>
<xsl:stylesheet xmlns:xsl=&quot; version=&quot;1.0&quot;>
<xsl:variable name=&quot;rules&quot; select=&quot;document('rule.xml')/rules&quot; />
<xsl:template match=&quot;/&quot;>
<xsl:apply-templates />
</xsl:template>
<xsl:template match=&quot;products&quot;>
<ul>
<xsl:apply-templates />
</ul>
</xsl:template>
<xsl:template match=&quot;product&quot;>
<xsl:variable name=&quot;ruleId&quot; select=&quot;substring(@id,1,1)&quot; />
<xsl:variable name=&quot;rule&quot; select=&quot;$rules/rule[@id=$ruleId]&quot; />
<b>
<li style=&quot;color:{$rule/@color};font-family:{$rule/@face};&quot;>
<xsl:value-of select=&quot;name&quot; />
<xsl:text> </xsl:text>
<i>
<xsl:choose>
<xsl:when test=&quot;$rule/@mask&quot;>
<xsl:value-of select=&quot;$rule/@mask&quot; />
</xsl:when>
<xsl:eek:therwise>
<xsl:value-of select=&quot;price&quot; />
</xsl:eek:therwise>
</xsl:choose>
</i>
</li>
</b>
</xsl:template>
</xsl:stylesheet>
 
Hi,

Thanks whichman for ur instant response. This code is working in Netscape 6 only, but not working in Ie5 or IE5.5 or IE6.Any alternative solution in order to make comapatible with IE 5.0

Regards
Bala

 
I don't understand, I tested it with IE v6 and IE v5.5 and it worked fine.
Try any of these 2 solutions:

1.) Replace your read.xsl with this file below:
-------------------------------------------------------
<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?>
<xsl:stylesheet xmlns:xsl=&quot; version=&quot;1.0&quot;>
<xsl:variable name=&quot;rules&quot; select=&quot;document('rule.xml')/rules&quot; />
<xsl:template match=&quot;/&quot;>
<xsl:for-each select=&quot;products&quot;>
<ul>
<xsl:for-each select=&quot;product&quot;>
<xsl:variable name=&quot;ruleId&quot; select=&quot;substring(@id,1,1)&quot; />
<xsl:variable name=&quot;rule&quot; select=&quot;$rules/rule[@id=$ruleId]&quot; />
<b>
<li style=&quot;color:{$rule/@color};font-family:{$rule/@face};&quot;>
<xsl:value-of select=&quot;name&quot; />
<xsl:text> </xsl:text>
<i>
<xsl:choose>
<xsl:when test=&quot;$rule/@mask&quot;>
<xsl:value-of select=&quot;$rule/@mask&quot; />
</xsl:when>
<xsl:eek:therwise>
<xsl:value-of select=&quot;price&quot; />
</xsl:eek:therwise>
</xsl:choose>
</i>
</li>
</b>
</xsl:for-each>
</ul>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>
---------------------------------------------------------

OR

2.)
make sure the first line of your read.xsl looks like this:

<xsl:stylesheet xmlns:xsl=&quot; version=&quot;1.0&quot;>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top