Hi,
I am working on an XSL stylesheet and I have a loop within a loop where I need to compare element values from the inside loop to values from the outer loop (see bolded line in XSL below). The inside loop references elements from a second XML document, which makes this especially difficult (at least difficult for me).
The outermost (first) loop references elements in the Primary XML file (the one to which the XSL is applied directly) and the inner loop references elements in the Second XML file.
Hopefully this makes sense...
Thank you so much!!
Christine
XSL:
<?xml version="1.0"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:variable name="file2" select="document('C:\Documents and Settings\e\My Documents\Trial XML\Recipe Code\UP_X783X_UFDF_CLEANING.XML')"/>
<html>
<body>
<table border="0" width="100%">
<tr align="left">
<th>Step</th>
<th>Parameter</th>
<th>Origin</th>
<th>Low</th>
<th>Value</th>
</tr>
<xsl:for-each select="RecipeElement/Steps/Step">
<xsl:sort select="@YPos" data-type="number"/>
<xsl:sort select="@XPos" data-type="number"/>
<xsl:for-each select="FormulaValue">
<tr>
<td>
<xsl:value-of select="ancestor::Step/Name/text()"/>
</td>
<td>
<xsl:value-of select="Name"/>
</td>
<xsl:if test="Value">
<td>Value</td>
<xsl:if test="Real">
<xsl:for-each select="$file2/RecipeElement/Parameter">
<xsl:if test="matches('Name/text()','FormulaValue/Name/text()=current()')"> <td>
0
</td>
</xsl:if>
</xsl:for-each>
<td>
<xsl:value-of select="Real"/>
</td>
<td>
High
</td>
</xsl:if>
</xsl:if>
</tr>
</xsl:for-each>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Primary XML:
<?xml version="1.0" encoding="UTF-8"?>
<RecipeElement>
<Step XPos="600" YPos="598" AcquireUnit="true">
<Name>UP_X783X_UFDF_CLEANING:1</Name>
<StepRecipeID>UP_X783X_UFDF_CLEANING</StepRecipeID>
<UnitAlias>UP_X783X_UFDF_CLEANING:1</UnitAlias>
<FormulaValue>
<Name>CIP_FEED_PUMP_SPEED</Name>
<Display>false</Display>
<Value/>
<Real>75</Real>
<EngineeringUnits/>
</FormulaValue>
<FormulaValue>
<Name>CIP_XFER_PUMP_SPEED</Name>
<Display>false</Display>
<Value/>
<Real>35</Real>
<EngineeringUnits/>
</FormulaValue>
</Step>
</RecipeElement>
Second XML:
<?xml version="1.0" encoding="UTF-8"?>
<RecipeElement>
<Parameter>
<Name>CIP_FEED_PUMP_SPEED</Name>
<ERPAlias/>
<PLCReference>1</PLCReference>
<Real>45</Real>
<High>100</High>
<Low>0</Low>
<EngineeringUnits>%</EngineeringUnits>
<Scale>false</Scale>
</Parameter>
<Parameter>
<Name>CIP_XFER_PUMP_SPEED</Name>
<ERPAlias/>
<PLCReference>1</PLCReference>
<Real>30</Real>
<High>100</High>
<Low>0</Low>
<EngineeringUnits>%</EngineeringUnits>
<Scale>false</Scale>
</Parameter>
</RecipeElement>