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

XQuery - data($node + $xpath) ?

103 100+
Hi

I know the title's a bit odd. I'm trying to set up an XQuery for which the xpath is set previously according to input parameters.

If I was going to do this normally I'd do something like:

Expand|Select|Wrap|Line Numbers
  1. let $first := data($node//h2)
  2.  
And this would get the h2 tags from the node.

But I want to set $path= 'h2' before the xquery and then...

Expand|Select|Wrap|Line Numbers
  1. let $first := data($node$path)
  2.  
or I tried
Expand|Select|Wrap|Line Numbers
  1. let $first := data(concat($node,$path))
  2.  
Can anyone help? I think the problem is that $node is a node() type and $path is a string type so how can I join them in the same way as if I'd typed //h2?

Thanks in advance!
Dec 13 '07 #1
2 1717
jkmyoung
2,057 Expert 2GB
What this ends up being is an attempt to dynamically evaluate an xpath. Due to the way the majority of compilers for XQuery work, this isn't possible without the use of extension functions or other workarounds, which are often processor dependent.

What XQuery processor are you using?
Do you know the general structure of the xpath?
Dec 13 '07 #2
henryrhenryr
103 100+
Hi - thanks for your reply!

What XQuery processor are you using?
I'm using web harvest - (http://web-harvest.sourceforge.net). I've found most functions I've tried work - well they don't break it! Let me know which ones I should try and I'll give it a try.

Do you know the general structure of the xpath?
I'm not 100% sure what you mean here... I'm using XPath to read HTML sites. So the structure I'm trying to capture is pretty much standard (although normally messy) HTML.

I am using the software for a number of different sites and I want to have the same set of processors used for various tasks - I will input the XPath to identify particular parts of a node that I want but that varies between different tasks so I need a dynamic solution...

Hope that makes it clearer. Thanks for your help!
Dec 14 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

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...
7
by: Zaharije Pasalic | last post by:
I tried to implement multi-data list with a reference instead of pointer to data, but code compiled with gcc perform "segmentation fault". Generated code from other compilers: Borland C++ 5.0 and...
1
by: Omega375 | last post by:
Hello. I'll first start off by showing the structure of my xml-file. <root> <node path="X"> More nodes containing data </node> </root>
3
by: Dinesh_GR | last post by:
Hi all, I have many parent tags and many child tags under the respective parent.. in an XML file. On the click of a button the application should pick up the one parent and the corresponding...
1
by: lg2530 | last post by:
template<class T> struct NODE { T data; NODE<T> * next; }; template<typename T> NODE<T>* QuickSortList( NODE<T>* list ) {}
4
by: Steve Richter | last post by:
when I run the following code the leading spaces of the "data" node are removed. How do I retain whitespace? private void CreateBasicXmlDocument() { XmlWriterSettings writeSettings = new...
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: greg | last post by:
Hi All, In the following declaration of a node, do we need the second `struct': typedef struct Node { struct Elem* next; int data; } Node;
2
by: arunairs | last post by:
Hi, Is there a way of validating and XPath? In this case , I am accepting an XPath from the user and I need to validate the XPath syntax. Is there a regular expression available that anyone can...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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...

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.