473,398 Members | 2,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

XQuery version of xpath different than xslt's?

Can anyone explain to me why the following XQuery expression (a simple
xpath expression) returns a different result than the same expression
in xslt?

document("document.xml")//a/@b

For the following sample document:

<root>
<a b="1" />
<a b="2" />
</root>

for XQuery (using 'java kawa.repl --xquery -e
'document("document.xml")//a/@b') I get:

b=1 b=2

for xslt (using <xsl:value-of select="document('document.xml')//a/@b"
/>) I get:

1

There seem to be two large descrepancies- first, XQuery includes the
attribute name as well as the value (b=1 instead of 1), and XQuery
lists all the attributes, while xslt only lists the first. Am I just
confused or is there some ambiguity with this?

thanks
-I
Jul 20 '05 #1
1 2026
inquirydog wrote:
Can anyone explain to me why the following XQuery expression (a simple
xpath expression) returns a different result than the same expression
in xslt?

document("document.xml")//a/@b

For the following sample document:

<root>
<a b="1" />
<a b="2" />
</root>

for XQuery (using 'java kawa.repl --xquery -e
'document("document.xml")//a/@b') I get:

b=1 b=2

for xslt (using <xsl:value-of select="document('document.xml')//a/@b"
/>) I get:

1

There seem to be two large descrepancies- first, XQuery includes the
attribute name as well as the value (b=1 instead of 1), and XQuery
lists all the attributes, while xslt only lists the first. Am I just
confused or is there some ambiguity with this?

thanks
-I


hi,

i guess that with xslt you displayed the result of the xpath query with
something like <xsl:value-of> don't you ?

in this case, the string() function is involved to convert the result to
the output tree

how does the string() function works ?
as explained here : http://www.w3.org/TR/xpath#function-string
a node-set is converted to a string by returning the string-value of the
node in the node-set that is first in document order.

apply this to your case :
node set of attr b=1 and attr b=2
keep the first node attr b=1
extract its value 1
1 is your result

now, try to browse your result with <xsl:for-each>, and use 2
<xsl:value-of> to display the name of each node, and its value

you should obtain the same result as xquery
--
Cordialement,

///
(. .)
-----ooO--(_)--Ooo-----
| Philippe Poulard |
-----------------------
Jul 20 '05 #2

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

Similar topics

2
by: Tom Corcoran | last post by:
I am working to ease updating of a html page by transforming 2 xml files. I was going to use xslt for this and had bought 2 unopened books, wrox xslt and o'reilly's xslt cookbook. But am now...
1
by: DV | last post by:
Hello, can anyone tell me or point me to somewhere what the exact differences (in terms of when would I use what) between XPath, XLink, XPointer and DOM are? Does it require special software...
4
by: Jeff Kish | last post by:
Hi. I see it appears that xquery is case senstitive for looking for particular attribute values etc. Is there a standard way around this? Say I want to see all nodes with an attribute valued...
1
by: Jeff Kish | last post by:
Hi. Can someone tell me when xslt, xpath, xquery are appropriate technologies to consider? I really know nothing about xslt except it is about transforming xml, (but I'm about to embark on a...
1
by: Philipp Schumann | last post by:
Hi .NET XML fans, does anyone know ad hoc whether support for the above standards is planned for .NET 2.0? I suppose this would be extremely valuable for many folks... Thanks, Phil
2
by: Manish | last post by:
I am new to XML. Initially I was saving all the settings in either PHP or text files or database tables and use to parse the config variables from files or query from the database. Now I want to...
5
by: CK | last post by:
I have the following XML in an XML column in a SQL 2005 Database. <DeliveryList xmlns="http://schemas.adventure-works.com/DeliverySchedule"> <Delivery SalesOrderID="43659"> <CustomerName>Steve...
3
by: Bloody Viking | last post by:
Namaste, Y'all! I've got a valid XQuery expression that I need to convert to XPath 2.0. This expression will be stored in a resource file and applied to XML by a Java program with saxon8.jar...
1
by: Christof Hoeke | last post by:
hi, I was wondering if there is any way to use XSLT2 or maybe even XQuery with "normal" CPython. Using Saxon/XSLT2 with Jython is no problem (I have not tried Saxon.NET with IronPython but suspect...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
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,...
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...
0
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,...
0
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...
0
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,...
0
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...

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.