Feature request: output params for db:replace

Wednesday, 23 October 2013 · 3 messages · last reply 9 Nov 2013
FB
France Baril23 Oct 2013 22:50 #
Hi, I have a feature request. I have a nice file with just the correct indent, that I was able to create by adding the xml:space="preserve" attribute to the root before making my inserts. [From previous thread]
Ex. <block xml:space="preserve">
       <block>This is a <b><i>test</i></b> sentence.</block>
     </block>
Note: I can't use the output indent = no declaration at the top of my query because I'm in a library module, and I need this function to stay there for sharing. Now, I can't save the content like this (with @xml:space). My DTD doesn't allow for xml:space="preserve", and I don't want it to. Authors can't get the correct indent (based on our DTD) in the editor as long as the xml:space="preserve" remains. If I apply:
*let* *$clean-file* := *copy* *$copy* := *$new*
                               *modify* (*delete* *node* *$copy*/*/*
@xml:space*)
                               *return **$copy*

file:write('file.xml', $clean-file, $param), where param contains
indent="no". It saves correctly, indicating that removing the @xml:space
did not cause a the insertion of an indent space between <b> and <i>.
However, the db:replace('db', 'path', $clean-file) function forces an indent on the content between the <b> and the <i>. Since this is a BaseX function, and not an XQuery fonction, I'm hoping we could get db:replace('db', 'path', $clean-file, $param), where param can include output params such as indent=no. Thank you!
-- France Baril Architecte documentaire / Documentation architect france.baril at architextus.com (514) 572-0341
CG
Christian Grün25 Oct 2013 00:44 #
Hi France,
Quoted text · France Baril · 3 lines
> I have a nice file with just the correct indent, that I was able to create > by adding the xml:space="preserve" attribute to the root before making my > inserts. [From previous thread]
good to hear.
Quoted text · France Baril · 4 lines
> file:write('file.xml', $clean-file, $param), where param contains > indent="no". It saves correctly, indicating that removing the @xml:space did > not cause a the insertion of an indent space between <b> and <i>.
True; when files are written to disk, they are serialized, and serialization parameters can be applied to affect the way serialization works.
Quoted text · France Baril · 3 lines
> However, the db:replace('db', 'path', $clean-file) function forces an indent > on the content between the <b> and the <i>.
It looks like, but it doesn’t ;) In fact, your document will be stored without spaces, as the following example is supposed to show. If the following query is run on an empty database...
   db:replace("db", "x.xml", <xml><a> B </a></xml>)
..the resulting database will be stored as folows (you can view the internal structure with the "info storage" command ): PRE DIS SIZ ATS ID NS KIND CONTENT ----------------------------------------- 0 1 4 1 22 0 DOC x.xml 1 1 3 1 23 0 ELEM xml 2 1 2 1 24 0 ELEM a 3 1 1 1 25 0 TEXT B As soon as this document is serialized, however, and if indent is set to "true", the representation may change. If the problems occur with WebDAV and oXygen, it could help to add the "org.basex.serializer" option with the value "indent=no" and, possibly, "chop" with the value "no" in your web.xml file [1]. Hope this helps, Christian [1] http://docs.basex.org/wiki/Web_Application#Configuration
Quoted text · France Baril · 2 lines
Since this is a BaseX function, > and not an XQuery fonction, I'm hoping we could get db:replace('db',
'path',
Quoted text · France Baril · 17 lines
> $clean-file, $param), where param can include output params such as > indent=no. > > Thank you! > > > -- > France Baril > Architecte documentaire / Documentation architect > france.baril at architextus.com > (514) 572-0341 > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
FB
France Baril9 Nov 2013 20:43 #
Serializer option helped, thanks! On Thu, Oct 24, 2013 at 6:44 PM, Christian Grün <christian.gruen at gmail.com>wrote:
Quoted text · Christian Grün · 85 lines
> Hi France, > > > > I have a nice file with just the correct indent, that I was able to > create > > by adding the xml:space="preserve" attribute to the root before making my > > inserts. [From previous thread] > > good to hear. > > > > file:write('file.xml', $clean-file, $param), where param contains > > indent="no". It saves correctly, indicating that removing the @xml:space > did > > not cause a the insertion of an indent space between <b> and <i>. > > True; when files are written to disk, they are serialized, and > serialization parameters can be applied to affect the way serialization > works. > > > > However, the db:replace('db', 'path', $clean-file) function forces an > indent > > on the content between the <b> and the <i>. > > It looks like, but it doesn’t ;) In fact, your document will be stored > without spaces, as the following example is supposed to show. If the > following query is run on an empty database... > > db:replace("db", "x.xml", <xml><a> B </a></xml>) > > ..the resulting database > will be stored as folows (you can > view > the internal structure > with the "info storage" command > ): > > > PRE DIS SIZ ATS ID NS KIND CONTENT > ----------------------------------------- > 0 1 4 1 22 0 DOC x.xml > 1 1 3 1 23 0 ELEM xml > 2 1 2 1 24 0 ELEM a > 3 1 1 1 25 0 TEXT B > > As soon as this document is serialized, however, and if indent is set to > "true", the representation may change. > > > If the problems occur with WebDAV and oXygen, it could help to add the > "org.basex.serializer" option with the value "indent=no" and, possibly, > "chop" with the value "no" in your web.xml file [1]. > > Hope this helps, > Christian > > > [1] http://docs.basex.org/wiki/Web_Application#Configuration > > > > > Since this is a BaseX function, > > and not an XQuery fonction, I'm hoping we could get db:replace('db', > 'path', > > $clean-file, $param), where param can include output params such as > > indent=no. > > > > Thank you! > > > > > > -- > > France Baril > > Architecte documentaire / Documentation architect > > france.baril at architextus.com > > (514) 572-0341 > > > > _______________________________________________ > > BaseX-Talk mailing list > > BaseX-Talk at mailman.uni-konstanz.de > > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > > > >
-- France Baril Architecte documentaire / Documentation architect france.baril at architextus.com (514) 572-0341

⚡Generated with XQuery