473,772 Members | 2,388 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XSLT Question

Hello,

I have a following situation..
XML Document contains
<PurchaseOrde r>
<LineItems>
<LineItem>
<Description> </Description>
</LineItem>
<LineItem>
<Description> </Description>
</LineItem>
</LineItems>
<Comments>
<Comment>
<NumberInCollec tion>1</NumberInCollect ion>
</Comment>
<Comment>
<NumberInCollec tion>2</NumberInCollect ion>
</Comment>
</Comments>
</PurchaseOrder>
When I am looping through Each Line Item using XSLT - I need to also
get corresponding comment for that line item - I have
NumberInCollect ion which ties with appropriate LineItem but I dont
know how to get this number when I am looping through Each LineItem.

Any Help will be very much apprecieated!

Thanks

AZXML
Jul 20 '05 #1
3 1676
sh*******@hotma il.com (Just Curious) wrote in message news:<d2******* *************** ****@posting.go ogle.com>...
I have
NumberInCollect ion which ties with appropriate LineItem but I dont
know how to get this number when I am looping through Each LineItem.


This is a piece of poor DTD / Schema design - no wonder your XSLT is a
problem.
What connects these two nodes ? In your example, then there's nothing
robust that does it.
For a simple life with XML, then do it by containment:

<PurchaseOrde r>
<LineItems>
<LineItem>
<Description> </Description>
<Comment></Comment>
</LineItem>
<LineItem>
<Description> </Description>
<Comment></Comment>
</LineItem>
</LineItems>
</PurchaseOrder>
If they _must_ be separated, then look at an Ordinal_Name / Reference
scheme. XML does this (badly) with ID and IDREF type attributes. RDF
does it in a more thought-through manner. Look at the RSS 1.0
protocol for a simple example.
In your particular case, then the XSLT is easy. However it's not
robust, because the ordering of the <LineItems> collection is not
reliable against being re-ordered. It would be much improved by some
form of "item number" attribute on each, then referring to that.

If you're stuck with the DTD as it stands, then investigate the
count() and position() functions within XSLT.
Jul 20 '05 #2
In article <d2************ **************@ posting.google. com>, Just Curious wrote:
Hello,

I have a following situation..
XML Document contains
<PurchaseOrde r>
<LineItems>
<LineItem>
<Description> </Description>
</LineItem>
<LineItem>
<Description> </Description>
</LineItem>
</LineItems>
<Comments>
<Comment>
<NumberInCollec tion>1</NumberInCollect ion>
</Comment>
<Comment>
<NumberInCollec tion>2</NumberInCollect ion>
</Comment>
</Comments>
</PurchaseOrder>
When I am looping through Each Line Item using XSLT - I need to also
get corresponding comment for that line item - I have
NumberInCollect ion which ties with appropriate LineItem but I dont
know how to get this number when I am looping through Each LineItem.


If I correctly understand the description, in the for-each on LineItem
elements you can use

<xsl:variable name="pos" select="positio n()"/>

to get the position of the current LineItem element being processed
by the for-each and use the XPATH expression

../following-sibling::Commen ts/Comment[NumberInCollect ion=$pos]

to get the corresponding Comment element.
Jul 20 '05 #3
Thank you that did it!

I am hoping that xslt does processing of XML file in a linear fashion
- meaning - while looping for:each - LineItem 1 gets processeed first,
LineItem 2 gets processed second and so forth from top down

Thank you again!
ag*****@earl-grey.cloud9.net (A. Bolmarcich) wrote in message news:<slrncbuk2 s.t6r.ag*****@e arl-grey.cloud9.net >...
In article <d2************ **************@ posting.google. com>, Just Curious wrote:
Hello,

I have a following situation..
XML Document contains
<PurchaseOrde r>
<LineItems>
<LineItem>
<Description> </Description>
</LineItem>
<LineItem>
<Description> </Description>
</LineItem>
</LineItems>
<Comments>
<Comment>
<NumberInCollec tion>1</NumberInCollect ion>
</Comment>
<Comment>
<NumberInCollec tion>2</NumberInCollect ion>
</Comment>
</Comments>
</PurchaseOrder>
When I am looping through Each Line Item using XSLT - I need to also
get corresponding comment for that line item - I have
NumberInCollect ion which ties with appropriate LineItem but I dont
know how to get this number when I am looping through Each LineItem.


If I correctly understand the description, in the for-each on LineItem
elements you can use

<xsl:variable name="pos" select="positio n()"/>

to get the position of the current LineItem element being processed
by the for-each and use the XPATH expression

../following-sibling::Commen ts/Comment[NumberInCollect ion=$pos]

to get the corresponding Comment element.

Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2124
by: Ringo Langly | last post by:
Hi all, I'm a seasoned web programmer, but I've never touched XSLT. It's always been one of those acronyms I've never needed to educate myself on. Now... we're working with a web content provider who says we need to use XSLT and Web Services to pull the content from their site. Can someone give me a nutshell definition on how this works??? We use Cold Fusion MX on our web server, but I'm having trouble finding a
0
2358
by: Christopher M. Lauer | last post by:
I have done my best to answer this question but can not find the proper set of commands. I would like to transform an xml file (in code behind) and display its output in a specific html tag, such as a div with a runat=server. I can somewhat do this if I create a server control and include the control within the html div tag but this method (borrowed from ASP.NET Website Programming by Wrox press thanks guys) does not give me the full...
3
3092
by: Ian Roddis | last post by:
Hello, I want to embed SQL type queries within an XML data record. The XML looks something like this: <DISPLAYPAGE> <FIELD NAME="SERVER" TYPE="DROPDOWN"> <OPTION>1<OPTION> <OPTION>2<OPTION> <OPTION>3<OPTION> </FIELD>
0
3303
by: DAnne | last post by:
Hi, I'm very new to xslt and this is my first time posting to a Forum so please forgive me if I transgress any protocols. I have to do a tally report. This report is divided up into sections. Each section has a list of questions. Each question has responses. I need to display a list of responses to the questions (i.e. set:distinct), once and only once, each section. My second problem is that these questions can also have corrective...
18
2087
by: yinglcs | last post by:
Hi, I have a newbie XSLT question. I have the following xml, and I would like to find out the children of feature element in each 'features' element. i.e. for each <featuresI would like to look up what each feature depends on and gerenate a text file. For example, in the following file, I would like to find out feature A depends on A1 and A2 and feature B depends on B1 and B2. And write that to a text file.
15
2162
by: Jeff Uchtman | last post by:
Can I draw from 2 XML sources, the structure is exactly the same execpt for data contained into 1 xslt using math to add some structrure, and displaying others as node 1 and node 2? This data is XML from a Barracuda Spam server that has grown to 2. Here is a snip from my form draw. Imports System Imports System.IO Imports System.Net
2
1284
by: MichaelRKramer | last post by:
Hi, I'm new to dotnet 2.0, but I'm an expert in asp 3 or classic asp. Most of my sites are all done with XSLT and ASP which basically writes XMLs. Now I'm reading about the new cool stuff in visual studio 2005. How does VS 2005 or .net 2.0 work with XSLT's? Is what I've been doing the best practice or a dumb ass move? Will I not be using power of 2.0? Lost programmer
14
5157
by: Lee | last post by:
I have a xml file, here is sample part: <?xml version="1.0" encoding="UTF-8"?> <ProducsList> <Product id="1"> <SpecList> <Spec> <SpecLabel>Height</SpecLabel> <SpecValue>10</SpecValue> <SpecCat>Dimension</SpecCat> </Spec>
1
1299
by: nayijitu | last post by:
Hi, I need some thing like this. I have an XML file and it contain some elements(tag) with a proper hierarchy... In that XML a particular element <page> contain some child node element like below ..... <page> <Question></Question> <Question></Question>
2
2502
by: astroboiii | last post by:
New to the whole xml thing and finding w3schools to be an excellent resource. Now down to my question: I have several xml files I need to parse through and grab relevant information from and produce a new xml file. This needs to be automated through ant. The ant script is working fine, and I am usign the <transform> function to use my xslt file and go through all the required xml files, parse them, style them, and ultimately generate my...
0
9621
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10264
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10106
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8937
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7461
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6716
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2851
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.