[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Manipulating elements depending on the existence o

Subject: Re: Manipulating elements depending on the existence of sub-elements
From: "Adil Ladhani" <dillio@xxxxxxxxx>
Date: Wed, 12 Mar 2008 10:39:44 -0400
Re:  Manipulating elements depending on the existence o
Hi Wendell,

Thanks for the response (just as a brief aside, you've already been
extremely helpful to me for my current project, as archived posts of
yours have been solving almost every issue I've run into thus far). I
had actually read several posts regarding the caveats about using
position(), but until your response I was still incorrectly assuming
that it referred to the current node's position in a tree
(representing the current context), rather than a list that may or may
not respect the ordering of the document. The numbers were as
expected, so I didn't think twice about them.

Here is what I'm trying to accomplish in regards to the count:
I have an XML document containing information about Transactions
(represented by Transaction elements). Within each Transaction, there
are one or more text lines containing its contents (represented by
Line elements). Each Transaction also has a UniqueInfo element which
specifies its identifying information. For each Transaction, there
will be a row inserted into the database for every Line that it
contains (along with the unique identifying information). Since the
unique identifying information will be the same for every Line in the
Transaction (thus the same for every row inserted for a given
transaction), I want to add a count for Line number, in order to have
a primary key (and to be able to re-create the original document based
on the db entries).

This was all going peachy, but the document being parsed to XML
inexplicably decided to be a rebel and become inconsistent with its
formatting. This lead to a couple cases where one transaction would be
split between two Transaction elements, resulting in something like
the following:

<Transaction>
<Line> Text Here </Line>
<Line> More Text </Line>
</Transaction>

<Transaction>
<Line> Text Text Text </Line>
<Line> qwerty </Line>
<UniqueInfo>
<Number> 123 </Number>
<Name> Bob </Name>
<Type> 02 </Type>
</UniqueInfo>
</Transaction>

Now that I'm using following-sibling to get the UniqueInfo in these
cases, it's okay that the XML is not entirely accurate because the
database entry will be... with the exception of line count.

So basically I want the count to represent the position of a given
Line within a given Transaction, and in cases where a UniqueInfo
element is not present (i.e. it's a stub of a transaction), I want the
line count of that Transaction's following sibling to start where its
own line count left off, rather than back at 1 (which is what's
happening currently and what should be happening for all other
transactions). If this is not possible or more effort than its worth,
I'd settle for a line count representing the position of the line in
the context of the entire document (so the count just increments with
every line). I tried to do the latter by changing the context of
position(), but it didn't work out too well so any help would be most
appreciated.

Thanks,

Adil

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.