473,569 Members | 2,526 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to test if node name matches given string value

7 New Member
Hi,
I am trying to figure out how to see if any of a given set of childnodes equals a given string. For example, in the XML and XSL code below, I want the text in the "xsl:when" statement to output when any of the childnodes of <FormulaValue > equal the string "Value". How can I do this?? I am trying to use XPath code but I can't get it to work.
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.    <xsl:template match="/">
  4.       <html>
  5.          <body>
  6.          <xsl:for-each select="RecipeElement/Steps/Step/FormulaValue">
  7.          <xsl:choose>
  8.          <xsl:when test="name(child::node()[3])=Value">
  9.                  <d>Value is present</d>
  10.          </xsl:when>
  11.          </xsl:choose>
  12.          </xsl:for-each>
  13.          </body>
  14.       </html>
  15.    </xsl:template>
  16. </xsl:stylesheet>
  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="800" YPos="1098">
  10.             <Name>TERMINALSTEP:1</Name>
  11.         </TerminalStep>
  12.  
  13.     <Step XPos="600" YPos="598" AcquireUnit="true">
  14.             <Name>UFDF_CLEANING:1</Name>
  15.             <StepRecipeID>UFDF_CLEANING</StepRecipeID>
  16.             <UnitAlias>UFDF_CLEANING:1</UnitAlias>
  17.         <FormulaValue>
  18.             <Name>PUMP_SPEED</Name>
  19.             <Display>false</Display>
  20.             <Value />
  21.             <Real>5</Real>
  22.             <EngineeringUnits />
  23.         </FormulaValue>
  24.     </Step>
  25.     </Steps>
  26. </RecipeElement>
  27.  
Jun 25 '07 #1
1 7075
Dököll
2,364 Recognized Expert Top Contributor
Hi,
I am trying to figure out how to see if any of a given set of childnodes equals a given string. For example, in the XML and XSL code below, I want the text in the "xsl:when" statement to output when any of the childnodes of <FormulaValue > equal the string "Value". How can I do this?? I am trying to use XPath code but I can't get it to work.
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.    <xsl:template match="/">
  4.       <html>
  5.          <body>
  6.          <xsl:for-each select="RecipeElement/Steps/Step/FormulaValue">
  7.          <xsl:choose>
  8.          <xsl:when test="name(child::node()[3])=Value">
  9.                  <d>Value is present</d>
  10.          </xsl:when>
  11.          </xsl:choose>
  12.          </xsl:for-each>
  13.          </body>
  14.       </html>
  15.    </xsl:template>
  16. </xsl:stylesheet>
  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="800" YPos="1098">
  10.             <Name>TERMINALSTEP:1</Name>
  11.         </TerminalStep>
  12.  
  13.     <Step XPos="600" YPos="598" AcquireUnit="true">
  14.             <Name>UFDF_CLEANING:1</Name>
  15.             <StepRecipeID>UFDF_CLEANING</StepRecipeID>
  16.             <UnitAlias>UFDF_CLEANING:1</UnitAlias>
  17.         <FormulaValue>
  18.             <Name>PUMP_SPEED</Name>
  19.             <Display>false</Display>
  20.             <Value />
  21.             <Real>5</Real>
  22.             <EngineeringUnits />
  23.         </FormulaValue>
  24.     </Step>
  25.     </Steps>
  26. </RecipeElement>
Hello, Christine!

I am going to refer you to a wonderful link for the time being, see what you can pull up, find examples there:

http://www.w3schools.com/default.asp
Jun 26 '07 #2

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

Similar topics

1
2618
by: discomiller | last post by:
Mario Mueller: Hello *, radiobuttons belong to other radiobuttons by the "name="any_value"" attribut. Thats a fakt. I got the following XML: **************************************************************
3
1261
by: mike | last post by:
I am have a problem with my xslt test. <data> <struct_id>34</struct_id> <par_struct_id>0</par_struct_id> <chd_struct_id>41</chd_struct_id> </data> .. .. ..
4
62333
by: n_o_s_p_a__m | last post by:
My xml doc has many <title></title> and <title> in it, meaning the nodes have no content (although some do). How can I test for this? I tried title (doesn't work) I tried //title (doesn't work) I tried //title (doesn't work) I tried //title (doesn't work) Any suggestions welcome.
3
1870
by: Scott M. Lyon | last post by:
I'm trying to figure out the best way (considering there could be instances where I get a lot of data in this XML, and I want to minimize any slowdowns) to extract the value of one particular node from an XML string (not saved as a file, but passed as a string from another module). For example, let's assume I get back XML in a string that...
6
2733
by: SHC | last post by:
Hi all, I created an application from the Console Application (.NET) of VC++ .NET 2003, and I did "Build" the application of the attached .cpp file, volcanoes.xml and geology.dtd on my VC++ .NET 2003 - Windows XP Pro PC suscessfully. But when I ran it from the command line - C:\Documents and Settings\SHC\My Documents\Visual Studio...
2
5206
by: Kathy Burke | last post by:
Hi, I'm using Dim xDoc as XmlDocument Dim xElem As xmlElement = xDoc("xpath") I then assign a variable to a value from the result node: Dim r As String = xElem.Attributes.GetNamedItem("name").Value This works fine unless there is no node returned, then I get an "object reference not set" error.
1
1781
by: Dica | last post by:
hi all first off, i'm not trying to cross post, but couldn't find this newsgroup earlier (got here from a recommendation on microsoft.public.vb, where i originally posted this question). anyhow, i'm just getting into .Net and am trying to parse a document, but not able to read the values for the nodes consistently. anybody know what i'm...
31
3107
by: Peter Michaux | last post by:
Hi, I want to know the name of an object's constructor function as a string. Something like this <script type="text/javascript"> function Foo(){}; var a = new Foo(); alert('"' + a.constructor.toString().match(/function\s*(+)/)
4
2088
by: daniel.bron | last post by:
Hello, Given a XML document, an XPath to a leaf node, and a string value, what is the briefest XSLT transform to change that node's value to the given string? The node is unique, unrepeated, and guaranteed to exist. The real life scenario is an application's configuration file. I want to extract a particular config parameter, do some...
0
7700
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7614
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8125
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7974
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.