Hi,
I'm getting extra spaces after a node replace.
Code:
*let **$original* := <div><p>I love flowers (<specify/>).</p> <p>I love flowers: <specify/>.</p></div>
*let* *$specify* := <b><i>red, yellow and white ones</i></b>
*let* *$new* := *copy* *$copy* := *$original* *modify*(*for **$prompt* *in **$copy*//*specify* *return **replace* *node* *$prompt* *with* * $specify*) *return **$copy*
I would expect $new to give:
I love flowers (*red, yellow and white ones*).
I love flowers: *red, yellow and white ones*.
But I get extra spaces inside the parenthesis of the first sentence and before the period of the second sentence:
I love flowers (* red, yellow and white ones** *).
I love flowers: *red, yellow and white ones** *.
You can try my .xqm on BaseX 7.7
1. Create a DB 'test' with chop white spaces to 'no'. 2. Run access http://*localhost:8984*/test-extra-spaces/test-1 from your browser. 3. Look at the .xml in the test DB. It has extra carriage return. It looks like the query assumed that <i> was a block and it felt compelled to add a carriage return and indent.
Hi France,
you should get the desired result by adding the following line to the beginning of your query:
declare option output:indent 'no';
Hope this helps, Christian
PS: I’ll try my best to answer your pending mail tomorrow. ___________________________
2013/10/5 France Baril france.baril@architextus.com:
Hi,
I'm getting extra spaces after a node replace.
Code:
let $original := <div><p>I love flowers (<specify/>).</p> <p>I love flowers: <specify/>.</p></div>
let $specify := <b><i>red, yellow and white ones</i></b>
let $new := copy $copy := $original modify(for $prompt in $copy//specify return replace node $prompt with $specify) return $copy
I would expect $new to give:
I love flowers (red, yellow and white ones).
I love flowers: red, yellow and white ones.
But I get extra spaces inside the parenthesis of the first sentence and before the period of the second sentence:
I love flowers ( red, yellow and white ones ).
I love flowers: red, yellow and white ones .
You can try my .xqm on BaseX 7.7
- Create a DB 'test' with chop white spaces to 'no'.
- Run access http://localhost:8984/test-extra-spaces/test-1 from your
browser. 3. Look at the .xml in the test DB. It has extra carriage return. It looks like the query assumed that <i> was a block and it felt compelled to add a carriage return and indent.
-- France Baril Architecte documentaire / Documentation architect france.baril@architextus.com (514) 572-0341
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
I tried that, I figured it was not supported: [XQST0108] No output declarations allowed in library modules.
I get the error even when declaring the namespace: *declare namespace **output* = " http://www.w3.org/2010/xslt-xquery-serialization";
After multiple tries, I was able to get it with this:
*declare* %rest:path("/test-extra-spaces/test-1") %rest:GET %output:method('html') %output:html-version('5.0') %output:indent('no')...
However, I'd still like to know what I am missing when I get the first error because a lot of update functions don't have a rest path. So the *declare option output:indent 'no'; *would be quite useful.
Big thanks!
On Sat, Oct 5, 2013 at 7:09 PM, Christian Grün christian.gruen@gmail.comwrote:
Hi France,
you should get the desired result by adding the following line to the beginning of your query:
declare option output:indent 'no';
Hope this helps, Christian
PS: I’ll try my best to answer your pending mail tomorrow. ___________________________
2013/10/5 France Baril france.baril@architextus.com:
Hi,
I'm getting extra spaces after a node replace.
Code:
let $original := <div><p>I love flowers (<specify/>).</p> <p>I love flowers: <specify/>.</p></div>
let $specify := <b><i>red, yellow and white ones</i></b>
let $new := copy $copy := $original modify(for $prompt in $copy//specify return replace node $prompt with $specify) return $copy
I would expect $new to give:
I love flowers (red, yellow and white ones).
I love flowers: red, yellow and white ones.
But I get extra spaces inside the parenthesis of the first sentence and before the period of the second sentence:
I love flowers ( red, yellow and white ones ).
I love flowers: red, yellow and white ones .
You can try my .xqm on BaseX 7.7
- Create a DB 'test' with chop white spaces to 'no'.
- Run access http://localhost:8984/test-extra-spaces/test-1 from your
browser. 3. Look at the .xml in the test DB. It has extra carriage return. It
looks
like the query assumed that <i> was a block and it felt compelled to add
a
carriage return and indent.
-- France Baril Architecte documentaire / Documentation architect france.baril@architextus.com (514) 572-0341
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
I tried that, I figured it was not supported: [XQST0108] No output declarations allowed in library modules.
True, this is a restriction of the XQuery 3.0 specification. However, output declarations are allowed in main modules, and since 7.7, you can specify your RESTXQ functions both in library and main modules [1].
Hope this helps, Christian
Hi France,
one more solution to your indentation issue: if you add an xml:space attribute to the root node of your updated element, no extra indentations wil be added to your output:
let $original := <div xml:space="preserve">...
And now I’ll finally have a look at your frequently cited mail, Christian ___________________________
2013/10/7 Christian Grün christian.gruen@gmail.com:
I tried that, I figured it was not supported: [XQST0108] No output declarations allowed in library modules.
True, this is a restriction of the XQuery 3.0 specification. However, output declarations are allowed in main modules, and since 7.7, you can specify your RESTXQ functions both in library and main modules [1].
Hope this helps, Christian
*I'm not sure that I get what we are trying to achieve with main modules here:*
- Should I create a main module in which I import all library modules so they inherit the output option? - Or should I convert all modules with functions that are not using rest path to main modules so I can declare the output option? - What are other consequences of using main modules? How will I import a main module to make its functions available to other modules?
*My scheme is:*
User comes in with one of:
- http://host:port/menu?id=x in menu.xqm - http://host:port/topic?id=y in topic.xqm
Both menu.xqm and topic.xqm import a module with common functions (contentrefs.xqm) that resolve content references, for example: contentref:fill-with-product-name(content as node(), product as xs:string)
contentref:fill-with-product-name is the one that makes the node replacement (similar to the flower example).
*My 'scheme'-related question is:*
Should contentrefs.xqm really be converted to a main module?
Or should I convert all modules with functions that are not using rest path to main modules so I can declare the output option?
Well, similar to that (I hope I got you right)... You can convert all of your modules, which include RESTXQ annotations, to main modules. A main module needs to end with a valid XQuery expression, which can e.g. be an empty sequence ().
It’s true that main modules can’t be imported from other modules. In our own projects, RESTXQ modules basically serve as entry points, and most of the application logic is stored in other modules (which we store in the repository).
basex-talk@mailman.uni-konstanz.de