Re: [basex-talk] Setting base-dir for xquery:eval

2016-02-19 Thread Marc van Grootel
Wow. You guys don't stop to amaze. Chris's suggestion would've worked.
Andy's suggestion was what I actually had in mind when I wrote the
post.
So he reads my mind, Chris adds a new feature and all that before the
clock of 10 less than 12 hours after the post. And that, probably,
with a good night's sleep in between.

Of course I'll share what I have. I am creating it to better provide
testable documentation and examples for Origami (I'm still working on
it but work has kinda taken over the last few months).

Cheers,
--Marc


On Fri, Feb 19, 2016 at 9:51 AM, Christian Grün
 wrote:
>> a base-uri set. I wonder if there is a case for adding   base-uri  to the
>> xquery:eval options map to handle this in a cleaner way?
>
> …now there is [1,2]. New features in the documentation will be marked
> with 8.5, but they will already available in the snapshots and patch
> versions.
>
> [1] http://docs.basex.org/wiki/XQuery_Module#xquery:eval
> [2] http://files.basex.org/releases/latest/
>
>
>
>> On 19 Feb 2016 07:10, "Marc van Grootel"  wrote:
>>>
>>> Yes, exactly what I was after. Thanks and good night :)
>>>
>>> --Marc
>>>
>>> > On 18 feb. 2016, at 23:38, Christian Grün 
>>> > wrote:
>>> >
>>> > Hi Marc,
>>> >
>>> >> when running xquery:eval with a string it will try to resolve paths
>>> >> relative to the code module and not relative to the file the string
>>> >> came from.
>>> >
>>> > You could add a base-uri declaration in your query:
>>> >
>>> >  let $uri := 'a/b/c'
>>> >  let $query := '1'
>>> >  return xquery:eval(
>>> >'declare base-uri "' || $uri || '"; ' || $query
>>> >  )
>>> >
>>> > Does this help?
>>> > Christian
>>> >
>>> >
>>> >> Ideally I would like to be able to set the base-dir for
>>> >> xquery:eval. The asciidoc file isn't always in the correct path
>>> >> relative to the module that I need to import.
>>> >>
>>> >> Other options I'm considering but are less ideal.
>>> >>
>>> >> - Manipulate the module import paths in the query string using regexps
>>> >> - Writing out to a temp file and then use xquery:parse-uri (but this
>>> >> is tricky as I may not want to clutter existing directories with
>>> >> tempfiles only to have the imports work).
>>> >>
>>> >> Unless there are better options I think I'll opt for string massaging
>>> >> using regexps. But maybe someone has a better idea.
>>> >>
>>> >> --Marc



-- 
--Marc


Re: [basex-talk] Setting base-dir for xquery:eval

2016-02-19 Thread Christian Grün
> a base-uri set. I wonder if there is a case for adding   base-uri  to the
> xquery:eval options map to handle this in a cleaner way?

…now there is [1,2]. New features in the documentation will be marked
with 8.5, but they will already available in the snapshots and patch
versions.

[1] http://docs.basex.org/wiki/XQuery_Module#xquery:eval
[2] http://files.basex.org/releases/latest/



> On 19 Feb 2016 07:10, "Marc van Grootel"  wrote:
>>
>> Yes, exactly what I was after. Thanks and good night :)
>>
>> --Marc
>>
>> > On 18 feb. 2016, at 23:38, Christian Grün 
>> > wrote:
>> >
>> > Hi Marc,
>> >
>> >> when running xquery:eval with a string it will try to resolve paths
>> >> relative to the code module and not relative to the file the string
>> >> came from.
>> >
>> > You could add a base-uri declaration in your query:
>> >
>> >  let $uri := 'a/b/c'
>> >  let $query := '1'
>> >  return xquery:eval(
>> >'declare base-uri "' || $uri || '"; ' || $query
>> >  )
>> >
>> > Does this help?
>> > Christian
>> >
>> >
>> >> Ideally I would like to be able to set the base-dir for
>> >> xquery:eval. The asciidoc file isn't always in the correct path
>> >> relative to the module that I need to import.
>> >>
>> >> Other options I'm considering but are less ideal.
>> >>
>> >> - Manipulate the module import paths in the query string using regexps
>> >> - Writing out to a temp file and then use xquery:parse-uri (but this
>> >> is tricky as I may not want to clutter existing directories with
>> >> tempfiles only to have the imports work).
>> >>
>> >> Unless there are better options I think I'll opt for string massaging
>> >> using regexps. But maybe someone has a better idea.
>> >>
>> >> --Marc


Re: [basex-talk] Setting base-dir for xquery:eval

2016-02-18 Thread Andy Bunce
Hi Christian,
I have used this technique and it works unless the query string already has
a base-uri set. I wonder if there is a case for adding   base-uri  to the
xquery:eval options map to handle this in a cleaner way?
/Andy
On 19 Feb 2016 07:10, "Marc van Grootel"  wrote:

> Yes, exactly what I was after. Thanks and good night :)
>
> --Marc
>
> > On 18 feb. 2016, at 23:38, Christian Grün 
> wrote:
> >
> > Hi Marc,
> >
> >> when running xquery:eval with a string it will try to resolve paths
> >> relative to the code module and not relative to the file the string
> >> came from.
> >
> > You could add a base-uri declaration in your query:
> >
> >  let $uri := 'a/b/c'
> >  let $query := '1'
> >  return xquery:eval(
> >'declare base-uri "' || $uri || '"; ' || $query
> >  )
> >
> > Does this help?
> > Christian
> >
> >
> >> Ideally I would like to be able to set the base-dir for
> >> xquery:eval. The asciidoc file isn't always in the correct path
> >> relative to the module that I need to import.
> >>
> >> Other options I'm considering but are less ideal.
> >>
> >> - Manipulate the module import paths in the query string using regexps
> >> - Writing out to a temp file and then use xquery:parse-uri (but this
> >> is tricky as I may not want to clutter existing directories with
> >> tempfiles only to have the imports work).
> >>
> >> Unless there are better options I think I'll opt for string massaging
> >> using regexps. But maybe someone has a better idea.
> >>
> >> --Marc
>


Re: [basex-talk] Setting base-dir for xquery:eval

2016-02-18 Thread Marc van Grootel
Yes, exactly what I was after. Thanks and good night :)

--Marc

> On 18 feb. 2016, at 23:38, Christian Grün  wrote:
> 
> Hi Marc,
> 
>> when running xquery:eval with a string it will try to resolve paths
>> relative to the code module and not relative to the file the string
>> came from.
> 
> You could add a base-uri declaration in your query:
> 
>  let $uri := 'a/b/c'
>  let $query := '1'
>  return xquery:eval(
>'declare base-uri "' || $uri || '"; ' || $query
>  )
> 
> Does this help?
> Christian
> 
> 
>> Ideally I would like to be able to set the base-dir for
>> xquery:eval. The asciidoc file isn't always in the correct path
>> relative to the module that I need to import.
>> 
>> Other options I'm considering but are less ideal.
>> 
>> - Manipulate the module import paths in the query string using regexps
>> - Writing out to a temp file and then use xquery:parse-uri (but this
>> is tricky as I may not want to clutter existing directories with
>> tempfiles only to have the imports work).
>> 
>> Unless there are better options I think I'll opt for string massaging
>> using regexps. But maybe someone has a better idea.
>> 
>> --Marc


Re: [basex-talk] Setting base-dir for xquery:eval

2016-02-18 Thread Christian Grün
Hi Marc,

> when running xquery:eval with a string it will try to resolve paths
> relative to the code module and not relative to the file the string
> came from.

You could add a base-uri declaration in your query:

  let $uri := 'a/b/c'
  let $query := '1'
  return xquery:eval(
'declare base-uri "' || $uri || '"; ' || $query
  )

Does this help?
Christian


> Ideally I would like to be able to set the base-dir for
> xquery:eval. The asciidoc file isn't always in the correct path
> relative to the module that I need to import.
>
> Other options I'm considering but are less ideal.
>
> - Manipulate the module import paths in the query string using regexps
> - Writing out to a temp file and then use xquery:parse-uri (but this
> is tricky as I may not want to clutter existing directories with
> tempfiles only to have the imports work).
>
> Unless there are better options I think I'll opt for string massaging
> using regexps. But maybe someone has a better idea.
>
> --Marc


[basex-talk] Setting base-dir for xquery:eval

2016-02-18 Thread Marc van Grootel
Hi,

I am having quite some fun with xquery:eval. I am working on a little
module for executable documentation (similar to Python doctest). I
want to write documentation in asciidoc, parse it and execute source
code blocks inside the asciidoc. Parsing works by calling asciidocj
and so far I can run simple queries, evaluate them, compare them with
an expected outcome and write the result back as evaluated asciidoc.

Now I want to tackle more advanced queries that import modules. But
when running xquery:eval with a string it will try to resolve paths
relative to the code module and not relative to the file the string
came from. Ideally I would like to be able to set the base-dir for
xquery:eval. The asciidoc file isn't always in the correct path
relative to the module that I need to import.

Other options I'm considering but are less ideal.

- Manipulate the module import paths in the query string using regexps
- Writing out to a temp file and then use xquery:parse-uri (but this
is tricky as I may not want to clutter existing directories with
tempfiles only to have the imports work).

Unless there are better options I think I'll opt for string massaging
using regexps. But maybe someone has a better idea.

--Marc