473,414 Members | 2,019 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Compare Current Value to Preceeding Values

Hi,
I am trying to create an XSL document which will output the word "Header" only if the <StepRecipeID> string for the current step is not equal to the <StepRecipeID> from previous steps. Thus, for the XML below, the word "Header" should be output twice (once for each of the two steps in the XML) since each step has a different string value for the <StepRecipeID>. Likewise, if the <StepRecipeID> 's were the same strings, the output would only be one "Header".
Does anyone know how to do this with the XSL?? I am trying to use XPath code within the XSL but I don't know if that is correct and I can't seem to figure it out. Any help would be much appreciated!!

Thank you!
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:template match="/">
  5.  
  6. <xsl:for-each select="RecipeElement/Steps">
  7.  
  8.     <xsl:if test="'Step/StepRecipeID' != 'previous::*'">
  9.  
  10.         <t>Header </t>
  11.  
  12.     </xsl:if>
  13. </xsl:for-each>
  14. </xsl:template>
  15. </xsl:stylesheet>
  16.  
  17.  
XML Code:

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <?xml-stylesheet type="text/xsl" href="stylesheet13.xsl"?>
  3. <RecipeElement>
  4. <RecipeElementID>UFDF_CLEANING</RecipeElementID>
  5.     <Steps>
  6.         <InitialStep XPos="700" YPos="100">
  7.             <Name>INITIALSTEP:1</Name>
  8.         </InitialStep>
  9.         <TerminalStep XPos="50" YPos="50">
  10.             <Name>TERMINALSTEP:1</Name>
  11.         </TerminalStep>
  12.  
  13.         <Step XPos="600" YPos="500" AcquireUnit="true">
  14.             <Name>Step 1</Name>
  15.             <StepRecipeID>StepOne</StepRecipeID>
  16.             <UnitAlias>UFDF_CLEANING:1</UnitAlias>
  17.         </Step>
  18.  
  19.         <Step XPos="600" YPos="1000" AcquireUnit="true">
  20.             <Name>Step 2</Name>
  21.             <StepRecipeID>StepTwo</StepRecipeID>
  22.             <UnitAlias>UFDF_CLEANING:1</UnitAlias>
  23.         </Step>
  24.     </Steps>
  25. </RecipeElement>
  26.  
  27.  
Jun 19 '07 #1
1 1203
Dököll
2,364 Expert 2GB
Hate to do this to you, Christine...

I just love this site:

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

Please write if more help is needed!
Jun 26 '07 #2

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

Similar topics

8
by: peashoe | last post by:
I have an asp page that uses a calendar.js (pop-up) file to add an exact date format in the text field (txtDDate). My problem is I need some javascript that sets an alert that does not allow them...
9
by: Rich | last post by:
Thanks for the Help in my previous post. I've been working on this and it's almost what I want. I want to obtain the user's current age by comparing their date of birth (user inputs) to the...
11
by: Russ Green | last post by:
How does this: public TimeSpan Timeout { get { return timeout; } set { timeout = value; if(timeout < licenseTimeout) licenseTimeout = timeout; }
7
by: James P. | last post by:
Hello there, In my asp.net page using VB, I have a date text field in mm/dd/yyyy format. When a date is entered, I'd like to validate it to make sure the date is greater than or equal to the...
17
by: Mark A | last post by:
DB2 8.2 for Linux, FP 10 (also performs the same on DB2 8.2 for Windoes, FP 11). Using the SAMPLE database, tables EMP and EMLOYEE. In the followng stored procedure, 2 NULL columns (COMM) are...
10
by: Y2K | last post by:
Any suggestions to compare two values, and if either value changes, then both values now become the changed values. Right now I'm doing it with a textbox and onchange event, but would like to get...
13
by: Shelley | last post by:
Compare Current Year Worksheet with Previous Year Worksheet and if SSN exists in Current Year Worksheet & Not in Previous Year - Copy this Row from Current Year Worksheet & Paste into Previous Year...
3
by: super.raddish | last post by:
Greetings, I am relatively new to, what I would call, advanced XSLT/XPath and I am after some advice from those in the know. I am attempting to figure out a mechanism within XSLT to compare the...
12
by: blackirish | last post by:
Hi all, I am trying to merge 2 XML files that first of all i need to compare nodes of both files according to 2 attributes in the nodes. If those 3 attributes are equal, i need to replace the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.