Hi All,
Given the following XML, I've been trying to figure out what XPATH
expression will give me the "position" of a <lineitem> within the
<shipto> that is its grandparent.
To give you an idea of what I'm trying to do...I'm transforming this
XML into XSL-FO; which I will process with FOP to produce a PDF file.
Each <shipto> element with the XML correlates to a new "section"
within the target PDF document. I need to know when I've reached the
last <lineitem> within a <shipto> so I can output some summary
information.
The way I'm approaching this in the XSLT stylesheet is
1. Within the template for <lineitem>, I can use
"count(../..//lineitem)" to give me the total number of <lineitem>'s
within this <shipto>. Then, I want to get the "position" of the
current <lineitem> within the current <shipto>, which I can them
compare against the total to see if this is the last <lineitem>.
I know the XPATH will be "count({somethi ng}) + 1", but I've just not
had any luck determining what "{something }" should be.
Obviously, there could be (and probably is :-) a better (or at least
more elegant) solution to this; but it seems like this will work.
Thanks in advance for any assistance.
Regards,
Mark
<?xml version="1.0" encoding="UTF-8"?>
<shipment_coo >
<shipto code="1">
<invoice id="1">
<lineitem id="1"/>
<lineitem id="2"/>
<lineitem id="3"/>
<lineitem id="4"/>
</invoice>
<invoice id="2">
<lineitem id="1"/>
<lineitem id="2"/>
<lineitem id="3"/>
<lineitem id="4"/>
</invoice>
<invoice id="3">
<lineitem id="1"/>
<lineitem id="2"/>
<lineitem id="3"/>
<lineitem id="4"/>
</invoice>
</shipto>
<shipto code="2">
<invoice id="4">
<lineitem id="1"/>
<lineitem id="2"/>
<lineitem id="3"/>
<lineitem id="4"/>
</invoice>
<invoice id="5">
<lineitem id="1"/>
<lineitem id="2"/>
<lineitem id="3"/>
<lineitem id="4"/>
</invoice>
</shipto>
</shipment_coo> 2 5157
"Mark Bordner" <ma***@trebax.c om> wrote in message
news:27******** *************** ***@posting.goo gle.com... Hi All,
Given the following XML, I've been trying to figure out what XPATH expression will give me the "position" of a <lineitem> within the <shipto> that is its grandparent.
To give you an idea of what I'm trying to do...I'm transforming this XML into XSL-FO; which I will process with FOP to produce a PDF file. Each <shipto> element with the XML correlates to a new "section" within the target PDF document. I need to know when I've reached the last <lineitem> within a <shipto> so I can output some summary information.
Use:
not(following-sibling::lineit em) and not(../following-sibling::invoic e)
When the current node is a "lineitem" the above XPath expression will
evaluate to true() only when this "lineitem" element is the last "grandson"
of its "grandfathe r".
Cheers,
Dimitre Novatchev [XML MVP],
FXSL developer, XML Insider, http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
Outstanding! I was thinking that there was a different way to look at
this problem. Thank you very much for the solution and the insight.
Dimitre Novatchev [MVP XML] wrote: "Mark Bordner" <ma***@trebax.c om> wrote in message news:27******** *************** ***@posting.goo gle.com...
Hi All,
Given the following XML, I've been trying to figure out what XPATH expression will give me the "position" of a <lineitem> within the <shipto> that is its grandparent.
To give you an idea of what I'm trying to do...I'm transforming this XML into XSL-FO; which I will process with FOP to produce a PDF file. Each <shipto> element with the XML correlates to a new "section" within the target PDF document. I need to know when I've reached the last <lineitem> within a <shipto> so I can output some summary information .
Use:
not(following-sibling::lineit em) and not(../following-sibling::invoic e)
When the current node is a "lineitem" the above XPath expression will evaluate to true() only when this "lineitem" element is the last "grandson" of its "grandfathe r". Cheers,
Dimitre Novatchev [XML MVP], FXSL developer, XML Insider,
http://fxsl.sourceforge.net/ -- the home of FXSL Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: nobody |
last post by:
hi there!
given
<!ELEMENT a (#PCDATA | x)*>
<!ELEMENT x (#PCDATA)>
how can I find out if x is "embedded" at the beginning
<a><x>xxx</x>aaa</a>
or at the end
<a>aaa<x>xxx</x></a>
or in the middle
|
by: Jessard |
last post by:
Hi All,
I am writing a .NET app that accesses an access View. The view has a table
column called 'Position'. When i try and right an UpdateCommand string for
this using this column I am greeted with a 'Syntax error in Update
statement.' when attempting the update. I take that field out and the update
works. I am assuming Position is a reserved word. I have even tried
changing the name of the column in the View to something other...
|
by: Ghyslaine Crespe |
last post by:
Hello,
In my script, the line
document.getElementById(id).style.background-position = "-200px -500px";
fails !
So, how can I change the background-position value ?
|
by: Guy |
last post by:
Hi,
I read an XML file to an XMLDocument and iterate through its nodes. How do I
get the XPath position (index) of a certain element? For example If I on the
second "b" node I want to get "2":
<a>
<b/>
<c/>
<b/> <--- This one
|
by: tschoepi |
last post by:
Hi there,
if I try to access a table named Position in an Access-Database via
OleDbDataAdapter I get an error. If I rename the table to e.g.
Positions it works.
Any idea how to solve this problem?
(There are about 5.000 databases out there at our customers with a
table in it named Position!)
Thanks a lot for your help
| |
by: petermichaux |
last post by:
Hi,
I tried the following and everything worked fine.
element.style.position="relative";
Then I tried to make the CSS rule important and it didn't work. The
positioning was all wrong in Safari and very jerky in Firefox.
element.style.position="relative !important";
|
by: vunet.us |
last post by:
Mozilla reported the fix to this bug: https://bugzilla.mozilla.org/show_bug.cgi?id=167801.
When input text field is located over div, the cursor cannot be seen
unless special CSS properties are applied. The link above illustrates
many example.
The problem I came across with, is almost identical, except that I
need to use position:fixed for my div element instead of
position:absolute as in all examples illustrated on Mozilla link. It
is...
|
by: Ronald S. Cook |
last post by:
Consider the following DataTable:
FoodId FoodName FoodType
1 Apple Fruit
2 Pear Fruit
3 Corn Vegetable
4 Bread Starch
5 Cereal Starch
6 Carrot Vegetable
7 Grapes Fruit
|
by: thomasv |
last post by:
Hi,
I want to convert the following XML (OpenOffice Calc file):
<?xml version="1.0" encoding="UTF-8"?>
<office:document-content
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.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 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,...
|
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...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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();...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |