Hi guys,

 

Thank for the suggestions.

 

@Marco. Sorry, I’ll use Christians suggestion ;-) But thanx you any way.

 

@Christian. Too bad this is the only way. But hé, it works.

 

Rob

Van: basex-talk-bounces@mailman.uni-konstanz.de [mailto:basex-talk-bounces@mailman.uni-konstanz.de] Namens Christian Grün
Verzonden: woensdag 8 oktober 2014 14:18
Aan: Marco Lettere
CC: BaseX
Onderwerp: Re: [basex-talk] regex for xquery

 

Hi Rob,

 

here's yet another solution:

 

  let $path := "Q{http://www.w3.org/2005/xpath-functions}root()/Q{}A[1]/Q{}B[1]/Q{}C[1]/Q{}D[1]"

  return analyze-string($path, '(Q\{.*?\}.*?)(/|$)')/fn:match/fn:group[1]/string()

 

> @Christian: On the other hand I can imagine that within Basex the path-expression is built from these elementary steps.

> If so, is it in any way possibly to retrieve this elementary steps sequence instead of this path-expression?

 

Currently, there is no other way to retrieve paths, so you'll have to manually split the path as indicated above..

 

Christian

 

 

 

On Wed, Oct 8, 2014 at 2:10 PM, Marco Lettere <marco.lettere@dedalus.eu> wrote:

Hi Rob,
don't know whether your prefix is constant.

If it is then

let $prefix := "Q{http://www.w3.org/2005/xpath-functions}root()"
let $inpstr := "Q{http://www.w3.org/2005/xpath-functions}root()/Q{}A[1]/Q{}B[1]/Q{}C[1]/Q{}D[1]"
return ($prefix,
        tokenize(substring-after($inpstr, $prefix),"/"))


should do the job.
M.



On 08/10/2014 13:37, Rob Stapper wrote:

Hi,

 

Basically I want to break down the path-expression of a node in my XML into its elementary steps.

QName: “Q{http://www.w3.org/2005/xpath-functions}root()/Q{}A[1]/Q{}B[1]/Q{}C[1]/Q{}D[1]” must become QName-sequence: (“Q{http://www.w3.org/2005/xpath-functions}root()”, ”Q{}A[1] ”, ”Q{}B[1] ”, ”Q{}C[1] ”, ”Q{}D[1]”)

 

So I need to break the path-expression down on the “/”-characters which aren’t part of the namespace-uries.

 

I’m using the “fn:tokenize”-function for this. The function uses a “regular expression” for it’s separator.

Unfortunately my regex-experience is zero (well, two days by now). I came up with the next brilliant ;-) solution:  fn:tokenize( path( $node), “/(?=Q)”).

Again, unfortunately, this doesn’t work because the xquery-flavor of regex doesn’t support looking around.

Sure, I can use “/Q” as pattern and subsequently  stick a “Q” in front of every substring (except the first one) but I’m looking for  a solid solution.

 

I there anyone out there with enough “regex-for-xquery”- experience to help me with this?

Big thanx for that in advance.

 

@Christian: On the other hand I can imagine that within Basex the path-expression is built from these elementary steps.

If so, is it in any way possibly to retrieve this elementary steps sequence instead of this path-expression?

 

Thanx,

 

Rob Stapper

 


Dit e-mailbericht bevat geen virussen en malware omdat avast! Antivirus actief is.

 

 

 




Dit e-mailbericht bevat geen virussen en malware omdat avast! Antivirus actief is.