473,405 Members | 2,334 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,405 software developers and data experts.

Why doesn't this work with XPath 1.0?

I'm using .Net 2.0. I realize that this means XPath 1.0 (which is
ridiculous).

So here's a document that I have that's not on disk but held in a variable
(I queried an Exchange appointment calendar):

<?xml version="1.0"?>
<a:multistatus xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/"
xmlns:d="urn:schemas:httpmail:" xmlns:f="urn:schemas:mailheader:"
xmlns:c="xml:" xmlns:e="urn:schemas:calendar:" xmlns:a="DAV:">
<a:prop>
<a:parentname>http://mail.somewhere.com/davrdir/john.doe/Calendar/</a:parentname>
<d:subject>busy</d:subject>
<e:dtstart b:dt="dateTime.tz">2006-12-08T13:00:00.000Z</e:dtstart>
<e:dtend b:dt="dateTime.tz">2006-12-08T15:00:00.000Z</e:dtend>
<e:created b:dt="dateTime.tz">2006-09-13T19:26:18.000Z</e:created>
<e:lastmodified b:dt="dateTime.tz">2006-09-13T19:26:19.000Z</e:lastmodified>
<e:alldayevent b:dt="boolean">0</e:alldayevent>
<e:busystatus>BUSY</e:busystatus>
<e:recurrenceid b:dt="dateTime.tz">2006-12-08T13:00:00.000Z</e:recurrenceid>
<f:message-id>&lt;21************************************@dpex ch.Alarmo.net&gt;</f:message-id>
</a:prop>
</a:multistatus>

This is actually an exerpt from an entire document, so there are several
<a:propnodes.

I need to know the number of <a:propelements where the <e:dtstart>
element's value is between a date range and e:busystatus="BUSY".

The XPath expression that I'm trying to use is:
//a:prop[e:dtstart >= "2006-12-08T00:00:00.000Z" and e:dtstart <=
"2006-12-08T23:59:59.000Z" and e:busystatus="BUSY"]

This works great using XPath 2.0 but not with XPath 1.0. I know this because
I'm using XMLSpy to test my expressions.

Why is this? How can I do what I need to in .Net 20.?

Thanks in advance,

Mike
Dec 8 '06 #1
3 3283
I failed to mention that I'm using the "Select" method of the
DocumentElement attribute of the XMLDocument object.

Thanks.

"MikeL" <mi******@optonline.netwrote in message
news:uS**************@TK2MSFTNGP04.phx.gbl...
I'm using .Net 2.0. I realize that this means XPath 1.0 (which is
ridiculous).

So here's a document that I have that's not on disk but held in a variable
(I queried an Exchange appointment calendar):

<?xml version="1.0"?>
<a:multistatus xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/"
xmlns:d="urn:schemas:httpmail:" xmlns:f="urn:schemas:mailheader:"
xmlns:c="xml:" xmlns:e="urn:schemas:calendar:" xmlns:a="DAV:">
<a:prop>
<a:parentname>http://mail.somewhere.com/davrdir/john.doe/Calendar/</a:parentname>
<d:subject>busy</d:subject>
<e:dtstart b:dt="dateTime.tz">2006-12-08T13:00:00.000Z</e:dtstart>
<e:dtend b:dt="dateTime.tz">2006-12-08T15:00:00.000Z</e:dtend>
<e:created b:dt="dateTime.tz">2006-09-13T19:26:18.000Z</e:created>
<e:lastmodified
b:dt="dateTime.tz">2006-09-13T19:26:19.000Z</e:lastmodified>
<e:alldayevent b:dt="boolean">0</e:alldayevent>
<e:busystatus>BUSY</e:busystatus>
<e:recurrenceid
b:dt="dateTime.tz">2006-12-08T13:00:00.000Z</e:recurrenceid>
<f:message-id>&lt;21************************************@dpex ch.Alarmo.net&gt;</f:message-id>
</a:prop>
</a:multistatus>

This is actually an exerpt from an entire document, so there are several
<a:propnodes.

I need to know the number of <a:propelements where the <e:dtstart>
element's value is between a date range and e:busystatus="BUSY".

The XPath expression that I'm trying to use is:
//a:prop[e:dtstart >= "2006-12-08T00:00:00.000Z" and e:dtstart <=
"2006-12-08T23:59:59.000Z" and e:busystatus="BUSY"]

This works great using XPath 2.0 but not with XPath 1.0. I know this
because I'm using XMLSpy to test my expressions.

Why is this? How can I do what I need to in .Net 20.?

Thanks in advance,

Mike


Dec 8 '06 #2
MikeL wrote:
The XPath expression that I'm trying to use is:
//a:prop[e:dtstart >= "2006-12-08T00:00:00.000Z" and e:dtstart <=
"2006-12-08T23:59:59.000Z" and e:busystatus="BUSY"]

This works great using XPath 2.0 but not with XPath 1.0. I know this because
I'm using XMLSpy to test my expressions.

Why is this?
The reason is that the comparison operators <, >, <=, >= in XPath 1.0
operate only on XPath number values so they first convert the operands
to numbers and then compare them. And converting a string with e.g.
"2006-12-08T00:00:00.000Z" into a number does not give a number that can
be compared meaningfully as a date/time.
How can I do what I need to in .Net 20.?
With the format you have you might be able to use e.g.
//a:prop[translate(e:dtstart, '-T:Z', '') >=
translate('2006-12-08T00:00:00.000Z', '-T:Z', '') and
translate(e:dtstart, '-T:Z', '') <=
translate('2006-12-08T23:59:59.000Z', '-T:Z', '') and e:busystatus = "BUSY"]

That way the comparison happens on numbers like 20061208235959.000.

..NET 2.0 also has support for extension functions to do string
comparison. And EXSLT.NET might have more support for dealing with
date/time values.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Dec 9 '06 #3
Thanks, Martin.

"Martin Honnen" <ma*******@yahoo.dewrote in message
news:OE**************@TK2MSFTNGP04.phx.gbl...
MikeL wrote:
>The XPath expression that I'm trying to use is:
//a:prop[e:dtstart >= "2006-12-08T00:00:00.000Z" and e:dtstart <=
"2006-12-08T23:59:59.000Z" and e:busystatus="BUSY"]

This works great using XPath 2.0 but not with XPath 1.0. I know this
because I'm using XMLSpy to test my expressions.

Why is this?

The reason is that the comparison operators <, >, <=, >= in XPath 1.0
operate only on XPath number values so they first convert the operands to
numbers and then compare them. And converting a string with e.g.
"2006-12-08T00:00:00.000Z" into a number does not give a number that can
be compared meaningfully as a date/time.
>How can I do what I need to in .Net 20.?

With the format you have you might be able to use e.g.
//a:prop[translate(e:dtstart, '-T:Z', '') >=
translate('2006-12-08T00:00:00.000Z', '-T:Z', '') and translate(e:dtstart,
'-T:Z', '') <= translate('2006-12-08T23:59:59.000Z', '-T:Z', '') and
e:busystatus = "BUSY"]

That way the comparison happens on numbers like 20061208235959.000.

.NET 2.0 also has support for extension functions to do string comparison.
And EXSLT.NET might have more support for dealing with date/time values.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

Dec 11 '06 #4

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

Similar topics

4
by: Vitali Gontsharuk | last post by:
Hallo! When using the XPATH document() function to load a new XML document, we are coming across problems, because XALAN seems to have problems with absolute paths. XALAN always assumes that the...
2
by: Alistair Bayley | last post by:
(.Net framework version 1.1.4322) The following XSL test case is rejected by System.Xml.Xsl.XslTransform, with an XsltException: "($dummy)+0 is an invalid XPath expression." If you remove the...
0
by: Tim Adler | last post by:
Hi all, I am trying to figure out why my simple example to try out datasets, xml, schemas and .NET doesn't work. The example is a small variation of the MS Purchase Order example. The...
5
by: laks | last post by:
Hi I have the following xsl stmt. <xsl:for-each select="JOB_POSTINGS/JOB_POSTING \"> <xsl:sort select="JOB_TITLE" order="ascending"/> This works fine when I use it. But when using multiple...
3
by: Sébastien Ros | last post by:
I tries to migrate an existing application from 1.1 to 2.0 but it seems that one of my XPath expressions no more works on this version. I tried a SelectNodes().Count. The result is 1 in v1.1 and...
19
by: David Thielen | last post by:
Hi; If there are no namespaces this works fine for me. But if the xml has namespaces, then I get either no node back or an exception. Here is the sample xml: <root xmlns="http://www.test.org"...
5
by: Gnic | last post by:
Hi , I have an XmlDocument instance, I want to find a node in the xml, but I don't know it's path until runtime, for example <aaa> <bbb name="x"/> <aaa attr="y"> <ccc>sometext</ccc> </aaa>
2
by: Coaster | last post by:
I'm reading a csproj file trying to extract info via xpath and this first one works fine xmlNode = xmlDoc.SelectSingleNode("/def:Project/def:PropertyGroup/def:OutputType/text()",nsMgr); ...
4
by: =?Utf-8?B?a2FydXpv?= | last post by:
Hi, I cannot guess, why some XPath expressions in my code returns false and some even errors, while the others returne true as I expected. I'am workin with VS 2008 Express Edition. Dim xEl As...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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...
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...

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.