469,357 Members | 1,930 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,357 developers. It's quick & easy.

how to see if current element value matches previous

Hi,
I am trying to create a table to display the values in the XML below. THe XSL provided works on the XML when there is only one <Step> but not three. Of the three steps in the XML below, two have the same table column headers (found in <FormulaValue> <Name>) and also the same <StepRecipeID>. The third step has different column headers and a different StepRecipeID.

So my question is: how do I tell the XSL to make new table column headers only for the Steps that have new StepRecipeID 's and not for the StepRecipeID's that are not new (that are the same as the previous StepRecipeID)?

Sorry for the long description but it is hard to explain. Please help me!!
Thanks,
Christine



XSL code:
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  3.  
  4. <xsl:output method="html"/>
  5.  
  6. <xsl:template match="/">
  7. <html>
  8. <body>
  9.     <table border="1" >
  10.         <thead>
  11.             <th bgcolor="rgb(70%,70%,70%)" width="250">Steps</th>
  12.             <xsl:for-each select="RecipeElement/Steps/Step/FormulaValue">
  13.                     <th bgcolor="rgb(70%,70%,70%)" width="250"><xsl:value-of select="Name"/></th>
  14.                </xsl:for-each>
  15.         </thead>
  16.  
  17.         <tbody>
  18.  
  19.                 <td><xsl:value-of select="RecipeElement/Steps/Step/Name"/></td>
  20.  
  21.              <xsl:for-each select="RecipeElement/Steps/Step/FormulaValue">
  22.                 <td width="250"><xsl:value-of select="Real"/></td>
  23.                </xsl:for-each>
  24.            </tbody>
  25.  
  26.  
  27.       </table>
  28. </body>
  29. </html>
  30.  
  31. </xsl:template>
  32. </xsl:stylesheet>
  33.  
XML code:
Expand|Select|Wrap|Line Numbers
  1. <Step XPos="600" YPos="598" AcquireUnit="true">
  2.             <Name>Step 1</Name>
  3.             <StepRecipeID>UFDF_CLEANING</StepRecipeID>
  4.             <UnitAlias>UFDF_CLEANING:1</UnitAlias>
  5.  
  6.             <FormulaValue>
  7.                 <Name>Name1A</Name>
  8.                 <Display>false</Display>
  9.                 <Value/>
  10.                 <Real>75</Real>
  11.                 <EngineeringUnits></EngineeringUnits>
  12.             </FormulaValue>
  13.  
  14.             <FormulaValue>
  15.                 <Name>Name2A</Name>
  16.                 <Display>false</Display>
  17.                 <Value/>
  18.                 <Real>35</Real>
  19.                 <EngineeringUnits></EngineeringUnits>
  20.             </FormulaValue>
  21.  
  22.             <FormulaValue>
  23.                 <Name>Name3A</Name>
  24.                 <Display>false</Display>
  25.                 <Value/>
  26.                 <Real>5.7</Real>
  27.                 <EngineeringUnits></EngineeringUnits>
  28.             </FormulaValue>
  29.         </Step>
  30.  
  31. <Step XPos="600" YPos="598" AcquireUnit="true">
  32.             <Name>Step 2</Name>
  33.             <StepRecipeID>UFDF_CLEANING</StepRecipeID>
  34.             <UnitAlias>UFDF_CLEANING:1</UnitAlias>
  35.  
  36.             <FormulaValue>
  37.                 <Name>Name1A</Name>
  38.                 <Display>false</Display>
  39.                 <Value/>
  40.                 <Real>75</Real>
  41.                 <EngineeringUnits></EngineeringUnits>
  42.             </FormulaValue>
  43.  
  44.             <FormulaValue>
  45.                 <Name>Name2A</Name>
  46.                 <Display>false</Display>
  47.                 <Value/>
  48.                 <Real>35</Real>
  49.                 <EngineeringUnits></EngineeringUnits>
  50.             </FormulaValue>
  51.  
  52.             <FormulaValue>
  53.                 <Name>Name3A</Name>
  54.                 <Display>false</Display>
  55.                 <Value/>
  56.                 <Real>5.7</Real>
  57.                 <EngineeringUnits></EngineeringUnits>
  58.             </FormulaValue>
  59.         </Step>
  60.  
  61. <Step XPos="600" YPos="598" AcquireUnit="true">
  62.             <Name>Step 3</Name>
  63.             <StepRecipeID>NEW IDENTIFICATION</StepRecipeID>
  64.             <UnitAlias>NewID</UnitAlias>
  65.  
  66.             <FormulaValue>
  67.                 <Name>Name1C</Name>
  68.                 <Display>false</Display>
  69.                 <Value/>
  70.                 <Real>75</Real>
  71.                 <EngineeringUnits></EngineeringUnits>
  72.             </FormulaValue>
  73.  
  74.             <FormulaValue>
  75.                 <Name>Name2C</Name>
  76.                 <Display>false</Display>
  77.                 <Value/>
  78.                 <Real>35</Real>
  79.                 <EngineeringUnits></EngineeringUnits>
  80.             </FormulaValue>
  81.  
  82.             <FormulaValue>
  83.                 <Name>Name3C</Name>
  84.                 <Display>false</Display>
  85.                 <Value/>
  86.                 <Real>5.7</Real>
  87.                 <EngineeringUnits></EngineeringUnits>
  88.             </FormulaValue>
  89.         </Step>
Jun 15 '07 #1
1 1112
Dököll
2,364 Expert 2GB

Sorry for the long description but it is hard to explain. Please help me!!
Thanks,
Christine
You're doing fine, Christine!

Sometimes thorough, somewhat lengthy description is good...

Couldn't simply adding additional column headers fit your purpose? I am understanding that some IDs are not the same. I also wondered if an if statement could help spin it in the right direction:

http://www.w3schools.com/xsl/xsl_if.asp

Please write if more help is needed, Christine.

In a bit!
Jun 28 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

15 posts views Thread by TJ Walls | last post: by
3 posts views Thread by Christopher Weaver | last post: by
4 posts views Thread by eksamor | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.