473,802 Members | 2,172 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

use of following-sibling

I have a simple document like this:

<Accept>
<XXXX/>
<Token image="From"/>
<Date value="2007-01-01"/>
<Token image="To"/>
<Date value="2007-01-01"/>
</Accept>

where i want to get the date element following the to token. (from and
to are both optional, so it cannot be only position relative)

I am using the following query: "child::Tok en[fn:upper-
case(@image)='T O']/following-sibling::*"
but my problem is that it's always returning me the token and the date
element. I would have expected to only get the date element.

For now i changed it to: "child::Tok en[fn:upper-case(@image)='F ROM']/
following-sibling::*[2]" and that works, but I feel like I am missing
something here.

Please help.
Thanks
Alain

Jun 8 '07 #1
12 3665
I am using the following query: "child::Tok en[fn:upper-
case(@image)='T O']/following-sibling::*"
but my problem is that it's always returning me the token and the date
element. I would have expected to only get the date element.
The following sibling axis returns all following siblings, unless you
specify which one you want -- by name, by position, or by some other
criterion.

If you want the single Date most closely following the FROM Token, try
"child::Tok en[fn:upper-case(@image)='F ROM']/following-sibling::Date[1]"

XSLT is a programming language. If you're fuzzy about what you ask for,
you get back fuzzy results.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Jun 8 '07 #2
In article <Wq************ *************** ***@comcast.com >,
Joe Kesselman <ke************ @comcast.netwro te:
>I am using the following query: "child::Tok en[fn:upper-
case(@image)=' TO']/following-sibling::*"
but my problem is that it's always returning me the token and the date
element. I would have expected to only get the date element.
>The following sibling axis returns all following siblings, unless you
specify which one you want -- by name, by position, or by some other
criterion.
Yes, but given the OP's example:

<Accept>
<XXXX/>
<Token image="From"/>
<Date value="2007-01-01"/>
<Token image="To"/>
<Date value="2007-01-01"/>
</Accept>

the Token element with @image=To only has one following-sibling
element. His expression should therefore return only the final Date
element.

-- Richard
--
"Considerat ion shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Jun 8 '07 #3
Richard Tobin wrote:
Yes, but given the OP's example:
You're right, I was reading in a hurry, as well entangling his two
sketched soltuions. (Sorry; negotiating on a house and somewhat
distracted.) Lemme recheck...
<Accept>
<XXXX/>
<Token image="From"/>
<Date value="2007-01-01"/>
<Token image="To"/>
<Date value="2007-01-01"/>
</Accept>
>"child::Toke n[fn:upper- case(@image)='T O']/following-sibling::*"
In this particular example, that should return the second Date. If there
are any other elements following the "TO" token, they will also be
returned. Given the <XXXX/>, I presume this is a simplified example, and
thus I presume he'd be better off limiting it.

"child::Tok en[fn:upper- case(@image)='T O']/following-sibling::*[1]"
indeed ought to work, to return the first following sibling element.
(though I'd still suggest explicitly using "child::Tok en[fn:upper-
case(@image)='T O']/following-sibling::Date[1]")

His workaround, "child::Tok en[fn:upper-case(@image)='F ROM']/
following-sibling::*[2]", SHOULDN'T work -- that should be returning the
"TO" token, not the date, assuming the description of the input is
correct. He claims it does work, which suggests that either the XPath
implementation he's using is broken or that the input isn't actually as
shown.

I may still be half-asleep and distracted and incoherent; apologies if
so... but there's something here I'm missing.
(This is why associated data should generally be grouped as
parent-child, or in a higher-level wrapper, or as attributes on a single
element, rather than counting on the order.)

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Jun 8 '07 #4
Sorry I see a few inconsistencies in my example Like from instead of
to in the query.

But, first I learned that following sibling returns all the following
siblings, thanks.

But, my working example ""child::To ken[fn:upper-case(@image)='T O']/
following-sibling::*[2]", is still problematic from what i understand
here, since the element Token with the selected attribute image of
"TO" shouldn't be selected as a sibling of itself and have to be
filtered. Am I getting this part right?

BTW, the reason that I am using a start after the following-sibling,
is that in the real world the next element following the from or to
token, can be one of about 4 different element names.

I am using Saxon as my XQuery processor.
Jun 8 '07 #5
In article <11************ **********@q69g 2000hsb.googleg roups.com>,
<ap*****@benchm arkconsulting.c omwrote:
>I am using Saxon as my XQuery processor.
It would be useful if you could reproduce your example as a short XML
file and stylesheet that others can run. Then we can see if it's a bug
in Saxon.

-- Richard
--
"Considerat ion shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Jun 8 '07 #6
ap*****@benchma rkconsulting.co m wrote:
But, my working example ""child::To ken[fn:upper-case(@image)='T O']/
following-sibling::*[2]", is still problematic from what i understand
here, since the element Token with the selected attribute image of
"TO" shouldn't be selected as a sibling of itself and have to be
filtered. Am I getting this part right?

BTW, the reason that I am using a start after the following-sibling,
is that in the real world the next element following the from or to
token, can be one of about 4 different element names.

I am using Saxon as my XQuery processor.
With the XML being your original sample

<Accept>
<XXXX/>
<Token image="From"/>
<Date value="2007-01-01"/>
<Token image="To"/>
<Date value="2007-01-01"/>
</Accept>

and the XQuery expression being

/Accept/child::Token[fn:upper-case(@image)='T O']/following-sibling::*

Saxon 8.9 returns

<?xml version="1.0" encoding="UTF-8"?>
<Date value="2007-01-01"/>

for me which is only the Date element so it returns what you are looking
for.

I have run the Java version of Saxon from the command line.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jun 8 '07 #7
ap*****@benchma rkconsulting.co m wrote:
"TO" shouldn't be selected as a sibling of itself and have to be
filtered. Am I getting this part right?
That's correct. It sounds like either you aren't running the code/data
you think you are, or there's a bug in the processor.
--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Jun 8 '07 #8
Well, thanks everyone for your help and my apologies about to Saxon.

We are running Saxon with a wrapper implementation that feeds it nodes
and items from an underlying object tree structure, instead of from
XML. We have been using this layer for over 2 years without problems,
but we are now starting to get more creative in our queries and have
uncovered found a bug in the list that iterateAxis() was returning for
following siblings.

Alain

Jun 8 '07 #9
ap*****@benchma rkconsulting.co m wrote:
uncovered found a bug in the list that iterateAxis() was returning for
following siblings.
Been there, done that, for a large portion of Xalan's internal DTM model
and adapters thereunto. <smile/>

(This is another reason we so often ask for runnable stand-alone
examples that will demonstrate the problem -- it's a good way to rule
out things other than the XPath/XSLT itself.)

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Jun 8 '07 #10

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

Similar topics

0
1375
by: johkar | last post by:
In the below example I am using the following to try to match only the unique MechanismText nodes within each Subscription node: select="DeliveryPreferences/DeliveryPreference" Right now, the 2nd select populates correctly, but the 1st select is empty. I know what is going on, but I don't know how to correct it. I would appreciate any ideas, solutions or pointers you can give me. Thanks, John
10
3415
by: Greener | last post by:
Hi, I need help badly. Can you do client-side programming instead of server-side to capture the Browser type info? If this is the case, what's wrong with the following? <script language="JavaScript"> function doWord(file) { if (navigator.userAgent.indexOf("MSIE")!=-1)
4
2077
by: Greener | last post by:
May I ask you the following? Two questions about the following block of code: 1) How to open the file in NON-ReadOnly mode? I tried many things, but none of them was working. 2) Any problems with the lines with document.write (...), as indicated below?
1
7745
by: timVerizon | last post by:
Hoping someone can help here.. Our application (C#.Net) was receiving IBM.Data.DB2.DB2Exceptions ERROR SQL0904N Unsuccessful execution caused by an unavailable resource. Reason code: '', type of resource: '', and resource name: ''. SQLSTATE=57011 . When looking in db2diag.log, we found the following that seemed to correspond to each exception: 2005-05-03-08.58.57.470000 Instance:DB2 Node:000
1
3212
by: ravi | last post by:
I have created the following interest to calculate the interest for the following currency pairs. I have tried to combine them in macros using conditions but the next query that is run in the macro ends up deleting the previous interest value that has been generated by the query. For example if query 1 is run on the table with currency pair USD/CHF then the interest will be updated without any problem but if there is another entry in the...
10
8721
by: Shawn | last post by:
JIT Debugging failed with the following error: Access is denied. JIT Debugging was initiated by the following account 'PLISKEN\ASPNET' I get this messag in a dialog window when I try to open an asp.net page. If I press OK then I get a page with this message: Server Application Unavailable The web application you are attempting to access on this web server is currently unavailable. Please hit the "Refresh" button in your web browser...
2
5533
by: mike_li | last post by:
On Window 2000 Professional Server DB2 UDB Level: DB2 code release "SQL07029" with level identifie "030A0105" and informational tokens "DB2 v7.1.0.98", "n040510" and "WR21337". In the db2diag.log, ---------------------------------------------------- 2005-12-20-10.05.43.278000 Instance:MC Node:000
7
1920
by: Martin Pritchard | last post by:
Hi, Sorry for my ignorance, but I'm a bit new to C++. I've been handed over a C++ app written in VS2002 which I have to convert to VS2005. Apparently it's been written in a C style, but cannot comment myself! Following the conversion I have numerous errors, which following some digging around turns out to be because _export is obsolete, and
0
4264
by: vaibhavsumant | last post by:
<project name="DBCreate" default="usage" basedir="."> <property name="user" value="db2admin"/> <property name="passwd" value="db2admin"/> <property name="dbprefix" value=""/> <property name="driver" value="COM.ibm.db2.jdbc.app.DB2Driver"/> <property name="starturl" value="jdbc:db2:temp"/> <property name="db2dir" location="${basedir}/../../../../.." /> <target name="CreateTestData" > <echo message="in mydbs db2dir = ${db2dir}" />
1
1241
by: antar2 | last post by:
Hello Suppose I have a textfile (text1.txt) with following four words: Apple balcony cartridge damned paper
0
9699
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
9562
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
10304
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...
1
7598
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
6838
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
5494
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...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3792
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2966
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.