Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 7th, 2007, 05:28 PM
Registered User
 
Join Date: Aug 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Comparing elements in an XML document

I am trying to compare the element names in an XSL document and am having problems getting it done. By the way, I am using XSLT to process the XML document. Here is my situation:

Sample XML:

<dfd>
<field num="1">
<sub>1</sub>
<heading />
<descr>Description 1-1</descr>
<tag>tag-1-1</tag>
</field>
<field num="2">
<sub>1</sub>
<heading>This is my heading 2-1</heading>
<descr />
<tag />
</field>
<field num="2">
<sub>2</sub>
<heading />
<descr>Description2-2</descr>
<tag>tag-2-2</tag>
</field>
<dfd>
<dfes>
<dfe-tag-1-1>Description 1-1</dfe-tag-1-1>
<dfe-tag-1-2>Description 2-2</dfe-tag-1-2>
<dfe-tag-2-1>Description 2-1</dfe-tag-2-1>
<dfe-tag-2-2>Description 2-2</dfe-tag-2-2>
<dfe-tag-2-3 />
<dfe-tag-2-4/>
</dfes>

What I need to do is to loop through all of the dfd/field elements that have the same num attribute one at at time and loop through the dfes elements looking for a dfe element with the same name as the dfd/tag with dfe- concatenated on the front of it. If I find the matching element in the dfes elements then I need to ensure there is a text value associated with that element and return either the text value of the element or a boolean true that it was found.

Example:

Loop dfd/fields[@num = 2]
set variable dfdele to concat('dfe-', tag)
loop dfes/* elements
    if dfes/child[name] contains the value in dfdele
     set a variable value to either the text value of the dfe/child
         or set a boolean to true so that when this loop is finished
         there is a value advising me that the element was found in
         the dfes tree
     end-if
end-loop
end-loop

Synopsis - what I need to know is if there is a field element with the same attribute number as the attribute number I am processing and it has a tag value, is there a matching element in the dfes tree that contains the tag value with a dfe- concatenated on the front.

Any help would be muchly appreciated.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
accessing elements using document() function geoGregory3 XSLT 2 February 28th, 2008 07:39 PM
Problem comparing xml data vb6 method Pro VB 6 5 May 9th, 2007 11:19 AM
Get all elements from XML olster XSLT 0 February 13th, 2007 06:39 AM
convert elements based on place in document jefke XSLT 2 May 17th, 2004 05:32 AM



All times are GMT -4. The time now is 01:08 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.