Transform data does not change
I have a xsl doc that needs to loop through the xml and output a set of instructions it has to go sequentialy as if I was telling you what to do. My problem is that when the same thing has to get done again, but a little different twist, it only outputs the last instruction it transformed as many times as it occurs in the document.
What is the deal with that? and or how do you empty the buffer in between instruction? or is there a better way to fix it.
here is an example of my xsl sheet named MyxslSheet.xsl
-------------------------------*********************
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<html>
<body>
<h2 align="center">My Instructions For You</h2>
<xsl:for-each select="//step">
<xsl:choose>
<xsl:when test="defaults">
<p align="center">
<xsl:value-of select="//description"/>
</p>
<br/>
</xsl:when>
<xsl:otherwise>
<b>
<xsl:number value="position()-1" format="71000. "/>
</b>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="instruction1">
<b>instruction 1</b>
<br/>
<xsl:value-of select="//instruction1/description"/>
<br/>[list]
<li>
<xsl:value-of select="//instruction1/drive"/>
<xsl:value-of select="//instruction1/location"/>
</li>
</ul>
</xsl:when>
<xsl:when test="instruction2">
<b>instruction 2</b>
<br/>
<xsl:value-of select="//instruction2/description"/>
<br/>[list]
<li>
<xsl:value-of select="//instruction2/drive"/>
<xsl:value-of select="//instruction2/location"/>
</li>
</ul>
</xsl:when>
<xsl:when test="instruction3">
<b>instruction 3</b>
<br/>
<xsl:value-of select="//instruction3/description"/>
<br/>[list]
<li>
<xsl:value-of select="//instruction3/drive"/>
<xsl:value-of select="//instruction3/location"/>
</li>
</ul>
</xsl:when>
<xsl:when test="instruction4">
<b>instruction 4</b>
<br/>
<xsl:value-of select="//instruction4/description"/>
<br/>[list]
<li>
<xsl:value-of select="//instruction4/drive"/>
<xsl:value-of select="//instruction4/location"/>
</li>
</ul>
</xsl:when>
</xsl:choose>
</xsl:for-each>
<br/>
<br/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
-------------------------------*******
Here is a example of my xsl name instructions.xml
-------------------------------********
<?xml-stylesheet type="text/xsl" href="MyxslSheet.xsl"?>
<instructions requestid="UserName">
<step type="defaults">
<defaults>
<description>This is the title of the document</description>
</defaults>
</step>
<step type="instruction1">
<instruction1>
<description>This is instruction 1</description>
<drive>c:</drive>
<location>\MyDirectory</location>
</instruction1>
</step>
<step type="instruction2">
<instruction2>
<description>This is instruction 2</description>
<drive>A:</drive>
<location>\ThisDirectory</location>
</instruction2>
</step>
<step type="instruction3">
<instruction3>
<description>This is instruction 3</description>
<drive>a:</drive>
<location>\ThisDirectory2</location>
</instruction3>
</step>
<step type="instruction3">
<instruction3>
<description>This is instruction again </description>
<drive>a:</drive>
<location>\ThisDirectory4</location>
</instruction3>
</step>
<step type="instruction3">
<instruction3>
<description>This is instruction 1 again and agian</description>
<drive>a:</drive>
<location>\ThisDirectory5</location>
</instruction3>
</step>
<step type="instruction4">
<instruction4>
<description>This is instruction 4</description>
<drive>D:</drive>
<location>\ThatDirectory</location>
</instruction4>
</step>
</instructions>
------------------------------*********
thanks in advance
Vince.Stanzione
|