Hello Rob,
no, this not a bug. replace() uses regex for its pattern and as the path
has {} and [] in them they will be interpreted as regex. You could write
your own replace function or something trivial (but quite limited) like
using substring and string-length, e.g.:
substring(path($b), string-length(path($a)) + 1)
Cheers,
Dirk
On 15/08/14 11:55, Rob Stapper wrote:
> Hi,
>
>
>
> How can I construct the relative path between two elements in an xml-file.
>
> Most probably overlooking the obvious I ended up with the solution below,
> which, unfortunately, triggers an runtime-error.
>
>
>
> My not-working solution:
>
>
>
> let $xml :=
>
> <xml>
>
> <A>
>
> <B/>
>
> </A>
>
> </xml>
>
> let $b := $xml//B
>
> let $a := $xml//A
>
>
>
> return replace( string( path( $b))
>
> , string( path( $a))
>
> , ''
>
> )
>
>
>
> Two questions:
>
> - How to retrieve the relative path between two element within a
> xml-file?
>
> - Why does the solution above trigger an error? Can it be a bug? (
> oops, three questions)
>
>
>
> Thnx in advance for the reply,
>
> Rob Stapper
>
>
>
> ---
> Dit e-mailbericht bevat geen virussen en malware omdat avast!
> Antivirus-bescherming actief is.
> http://www.avast.com
>
--
Dirk Kirsten, BaseX GmbH, http://basex.org
|-- Firmensitz: Blarerstrasse 56, 78462 Konstanz
|-- Registergericht Freiburg, HRB: 708285, Geschäftsführer:
| Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle
`-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22