XQuery - data($node + $xpath) ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • henryrhenryr
    New Member
    • Jun 2007
    • 103

    #1

    XQuery - data($node + $xpath) ?

    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:

    Code:
    let $first := data($node//h2)
    And this would get the h2 tags from the node.

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

    Code:
    let $first := data($node$path)
    or I tried
    Code:
    let $first := data(concat($node,$path))
    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!
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    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?

    Comment

    • henryrhenryr
      New Member
      • Jun 2007
      • 103

      #3
      Hi - thanks for your reply!

      Originally posted by jkmyoung
      What XQuery processor are you using?
      I'm using web harvest - (http://web-harvest.sourcef orge.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!

      Comment

      Working...