473,385 Members | 1,919 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,385 software developers and data experts.

Trying to evaluate xpath myself sort-of

Hi;

In our program we will get an XPath statement such as:
${data}/SalesProject[customer/CUSTCAT=${series}/customer/CUSTCAT]

Where ${data} and ${series} both stand for a XPathNavigator so each is
basically a specific node in a list of nodes that another XPath statement is
returning.

To evaluate this we basically build from the right to the left, stripping
off ]) fromt he far right to keep it balanced. So we do:

string str = navSeries.SelectSingleNode("self::node()/customer/CUSTCAT");
object value =
navData.SelectSingleNode("self::node()/}/SalesProject[customer/CUSTCAT=" +
str);

And the above works great. But, the whle thing falls apart when the XPath
passed in is:
count(${data}/SalesProject[customer/CUSTCAT=${series}/customer/CUSTCAT])

because that becomes count("abc") - if the first node that matches the inner
part above is "abc".

So, any idea on how to handle this so that count will work?

We are iterating through navSeries and for each navSeries entry we create
and iterate through navData and for each of those iterations we need to run
the inner XPath and return it's value (to place in a report).

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm
Nov 16 '07 #1
2 1851
Hello Dave,

We need to perform more research on this issue . We will reply here as soon
as possible.
If you have any more concerns on it, please feel free to post here.

Thanks for your understanding!
Best regards,

Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 16 '07 #2
Hello Dave,
Thanks for your reply.
how do I know that count wants a list of nodes as opposed to the node
value?
We may check it by ourself. If eval_expression is "count", we need a list
of nodes instead of node.
>how do I get the xpath that represents the present node on for an
XPathNavigator object?
I'm afraid it is different to get XPath from current node. But we can
retrieve it from the Root element. For example:

static public string getXpath(XPathNavigator xpn)
{
StringBuilder sb = new StringBuilder();
do
{
if (xpn.NodeType == XPathNodeType.Root)
{
sb.Insert(0, "/");
break;
}

if (xpn.NodeType == XPathNodeType.Element)
{
int position = getPosition(xpn.Clone());

sb.Insert(0,
string.Format("/{0}[{1}]",xpn.Name,position));
continue;
}
}
while (xpn.MoveToParent());
return sb.ToString();
}

static public int getPosition(XPathNavigator xpn)
{
int position =1;
while (xpn.MoveToPrevious())
position++;
return position;
}
Hope this helps. Please feel free to update here again, if there is
anything we can help with. We are glad to assist you.

Have a great day,
Best regards,

Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '07 #3

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

Similar topics

3
by: Kevin | last post by:
I know this has probably been discussed many times before (I found answers when I searched yesterday), but I still can't get it to work... I have an attribute @OID that can contain any...
4
by: Son KwonNam | last post by:
In XSLT, is this possible to get value from xml using XPath which is in XSLT variable? I mean XPath strings can be dynamic while XSL Transforming. If possible, How?? Because I'm not a...
6
by: Scott Simpson | last post by:
What is a good tool for running XPath queries on Linux? I have the O'Reilly XPath book and I'm using XPath Visualizer on Windows and that seems to work fine, but I'm looking for something on Linux....
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...
4
by: Zeng | last post by:
Hello, I just wonder if there is a way to programmatically evaluate expression strings such as ( ( 3 + 5 ) / 2 ) > 4 --> this should return 0 or false ( ( 3 + 6 ) / 3 ) > ( ( 5 + 3 ) / 4 ) ...
2
by: smachin1000 | last post by:
Hi All, In the sample schema & document below, I'd like the attribute "name" to be unique for all function elements under function_list. The tools I'm using (XML Spy and xmllint) all validate...
3
by: ziggyware | last post by:
Hi All, I have updated my XPath Generator software: XPath Studio .NET. ( http://www.ziggyware.com/downloads.php?cat_id=2 ) Easily select nodes from an xml file to generate XPath statements ...
1
by: shellon | last post by:
Hi all: I met a problem when using document.evaluate() to get text content using XPath, my code is as follows: nodes = document.evaluate("/html/body/div/ul/li", document, null,XPathResult....
2
by: anetasalomonsen | last post by:
I am using xpath within a BizTalk 2006 orchestration. I get the following error "Expression must evaluate to a node-set". My xml: <EmailListResponse xmlns="http://BTTest"> <PersonContact...
1
by: =?Utf-8?B?d2VqaXY=?= | last post by:
When I use xslCompiledTransform() or xslCompiledTransform(false) I find that the XPath queries in my select query attributes do not recognize any attributes inthe xml document. But when I enable...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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
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...

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.