Hi Guys,
How can I preserve whitespaces in XML document, when i'm using new CreateDB(..) object for creating new database from Java code. When I export data with new Export(..) I get document with choped whitespaces. I found out, that there is a possibility to preserve whitespaces when I create DB from BaseX gui. There is a possibility to uncheck option chop whitespaces which gives me required result. Is there any way how to do this from Java.
Thank you
Jiri
Hi Jiri,
you may set the properties for the given Context by simply calling:
// set CHOP to false CONTEXT.prop.set("CHOP",false);
If you are looking at the Example at [1] & [2]: http://www.inf.uni-konstanz.de/dbis/basex/code.php?code=DatabaseExample You would want to put the Prop change right before calling the CreateDB statement.
Hope this works out for you, don't hesitate to ask for more :-).
Kind Regards Michael
[1] http://www.inf.uni-konstanz.de/dbis/basex/code.php?code=DatabaseExample
[2] You may check your DB either via console, by open <dbname> and then info or in the GUI with help of the OPEN Dialog
Am 31.03.2010 um 16:38 schrieb Jiří Kadlec:
Hi Guys,
How can I preserve whitespaces in XML document, when i'm using new CreateDB(..) object for creating new database from Java code. When I export data with new Export(..) I get document with choped whitespaces. I found out, that there is a possibility to preserve whitespaces when I create DB from BaseX gui. There is a possibility to uncheck option chop whitespaces which gives me required result. Is there any way how to do this from Java.
Thank you
Jiri _______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
Thanks Michael
It works well. May I ask one more question. Is it possible to preserve doctype declaration in same way. For e.g I have documet which looks like this one:
<?xml version="1.0" standalone="no" ?>
<!--define the location of the external DTD using a relative URL address--> <!DOCTYPE document SYSTEM "subjects.dtd">
<document> <title>Subjects available in Mechanical Engineering.</title> <subjectID>2.303</subjectID> ... </document>
and when I export the document I loose information about DOCTYPE and connection to DTD, is there any way how to do this.
Thank you very much
Jiri
------------ Původní zpráva ------------ Od: Michael Seiferle michael.seiferle@uni-konstanz.de Předmět: Re: [basex-talk] Leave whitespaces in XML when loading XML file with new CreateDB Datum: 31.3.2010 18:02:29
Hi Jiri,
you may set the properties for the given Context by simply calling:
// set CHOP to false CONTEXT.prop.set("CHOP",false);
If you are looking at the Example at [1] & [2]: http://www.inf.uni-konstanz.de/dbis/basex/code.php?code=DatabaseExample You would want to put the Prop change right before calling the CreateDB statement.
Hope this works out for you, don't hesitate to ask for more :-).
Kind Regards Michael
[1] http://www.inf.uni-konstanz.de/dbis/basex/code.php?code=DatabaseExample
[2] You may check your DB either via console, by open <dbname> and then info or in the GUI with help of the OPEN Dialog
Am 31.03.2010 um 16:38 schrieb Jiří Kadlec:
Hi Guys,
How can I preserve whitespaces in XML document, when i'm using new
CreateDB(..) object for creating new database from Java code. When I export data with new Export(..) I get document with choped whitespaces. I found out, that there is a possibility to preserve whitespaces when I create DB from BaseX gui. There is a possibility to uncheck option chop whitespaces which gives me required result. Is there any way how to do this from Java.
Thank you
Jiri _______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
Dear Jiri,
after a quick look at the code I have to confirm that the doctype is not preserved by the parser. As Christian wrote it I am sure he will provide us with further information on this.
As a quick and rather dirty fix you might rewrite the Doctype declaration as a processing instruction
<?DOCTYPE document SYSTEM "subjects.dtd"?>
and take care of that prior to importing / after exporting. Sorry for not having a more convenient solution at the moment, we'll keep you updated.
Kind regards Michael
Am 01.04.2010 um 14:27 schrieb Jiří Kadlec:
Thanks Michael
It works well. May I ask one more question. Is it possible to preserve doctype declaration in same way. For e.g I have documet which looks like this one:
<?xml version="1.0" standalone="no" ?>
<!--define the location of the external DTD using a relative URL address-->
<!DOCTYPE document SYSTEM "subjects.dtd">
<document> <title>Subjects available in Mechanical Engineering.</title> <subjectID>2.303</subjectID> ... </document>
and when I export the document I loose information about DOCTYPE and connection to DTD, is there any way how to do this.
Thank you very much
Jiri
------------ Původní zpráva ------------ Od: Michael Seiferle michael.seiferle@uni-konstanz.de Předmět: Re: [basex-talk] Leave whitespaces in XML when loading XML file with new CreateDB Datum: 31.3.2010 18:02:29
Hi Jiri,
you may set the properties for the given Context by simply calling:
// set CHOP to false CONTEXT.prop.set("CHOP",false);
If you are looking at the Example at [1] & [2]: http://www.inf.uni-konstanz.de/dbis/basex/code.php?code=DatabaseExample You would want to put the Prop change right before calling the CreateDB statement.
Hope this works out for you, don't hesitate to ask for more :-).
Kind Regards Michael
[1] http://www.inf.uni-konstanz.de/dbis/basex/code.php?code=DatabaseExample
[2] You may check your DB either via console, by open <dbname> and then info or in the GUI with help of the OPEN Dialog
Am 31.03.2010 um 16:38 schrieb Jiří Kadlec:
Hi Guys,
How can I preserve whitespaces in XML document, when i'm using new
CreateDB(..) object for creating new database from Java code. When I export data with new Export(..) I get document with choped whitespaces. I found out, that there is a possibility to preserve whitespaces when I create DB from BaseX gui. There is a possibility to uncheck option chop whitespaces which gives me required result. Is there any way how to do this from Java.
Thank you
Jiri _______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
Jiří,
you can set serialization parameters to include doctypes in the query output:
$ basex -s doctype-system=subjects.dtd -q "<document/> <!DOCTYPE document SYSTEM "subjects.dtd">
or, using BaseX commands:
set serializer doctype-system=subjects.dtd xquery <document/>
The serialization features have been added after the official release; please compile the sources, or run the latest Maven build:
http://www.inf.uni-konstanz.de/dbis/basex/maven/org/basex/basex/6.0.6/
The official docs on serializing XSLT and XQuery can be found at: http://www.w3.org/TR/xslt-xquery-serialization/
Christian
2010/4/1 Michael Seiferle michael.seiferle@uni-konstanz.de:
Dear Jiri,
after a quick look at the code I have to confirm that the doctype is not preserved by the parser. As Christian wrote it I am sure he will provide us with further information on this.
As a quick and rather dirty fix you might rewrite the Doctype declaration as a processing instruction
<?DOCTYPE document SYSTEM "subjects.dtd"?>
and take care of that prior to importing / after exporting. Sorry for not having a more convenient solution at the moment, we'll keep you updated.
Kind regards Michael
Am 01.04.2010 um 14:27 schrieb Jiří Kadlec:
Thanks Michael
It works well. May I ask one more question. Is it possible to preserve doctype declaration in same way. For e.g I have documet which looks like this one:
<?xml version="1.0" standalone="no" ?>
<!--define the location of the external DTD using a relative URL address-->
<!DOCTYPE document SYSTEM "subjects.dtd">
<document> <title>Subjects available in Mechanical Engineering.</title> <subjectID>2.303</subjectID> ... </document>
and when I export the document I loose information about DOCTYPE and connection to DTD, is there any way how to do this.
Thank you very much
Jiri
------------ Původní zpráva ------------ Od: Michael Seiferle michael.seiferle@uni-konstanz.de Předmět: Re: [basex-talk] Leave whitespaces in XML when loading XML file with new CreateDB Datum: 31.3.2010 18:02:29
Hi Jiri,
you may set the properties for the given Context by simply calling:
// set CHOP to false CONTEXT.prop.set("CHOP",false);
If you are looking at the Example at [1] & [2]: http://www.inf.uni-konstanz.de/dbis/basex/code.php?code=DatabaseExample You would want to put the Prop change right before calling the CreateDB statement.
Hope this works out for you, don't hesitate to ask for more :-).
Kind Regards Michael
[1] http://www.inf.uni-konstanz.de/dbis/basex/code.php?code=DatabaseExample
[2] You may check your DB either via console, by open <dbname> and then info or in the GUI with help of the OPEN Dialog
Am 31.03.2010 um 16:38 schrieb Jiří Kadlec:
Hi Guys,
How can I preserve whitespaces in XML document, when i'm using new
CreateDB(..) object for creating new database from Java code. When I export data with new Export(..) I get document with choped whitespaces. I found out, that there is a possibility to preserve whitespaces when I create DB from BaseX gui. There is a possibility to uncheck option chop whitespaces which gives me required result. Is there any way how to do this from Java.
Thank you
Jiri _______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
___________________________
Christian Gruen Universitaet Konstanz Department of Computer & Information Science D-78457 Konstanz, Germany Tel: +49 (0)7531/88-4449, Fax: +49 (0)7531/88-3577 http://www.inf.uni-konstanz.de/~gruen
Hello,
I think I've found a possible bug. I've attached a source XML file. The following query returns 36 results in the most recent BaseX version (updated today and built from source):
/Region/Sections/Section[./V[@id='Section_ID']='"Maritime Environment Regions"']//RegionList/Region
However, I think it should be returning 10 results (and indeed it does in previous versions of BaseX as well as Saxon). The interesting part is that it does return a single result (as expected) for the first part of the query:
/Region/Sections/Section[./V[@id='Section_ID']='"Maritime Environment Regions"']
...so it appears as though the last part of the query (//RegionList/Region) is descending from the root and not from the single node returned in the first part as I would expect. Is this a bug in BaseX or a misunderstanding on my part of some subtlety of the standard?
Thanks,
Dave
Hello Dave,
thanks again for your helpful report. The obvious bug has been fixed; feel free to check out the latest sources.
All the best, Christian
On Fri, Apr 9, 2010 at 12:08 AM, Dave Glick dglick@dracorp.com wrote:
Hello,
I think I've found a possible bug. I've attached a source XML file. The following query returns 36 results in the most recent BaseX version (updated today and built from source):
/Region/Sections/Section[./V[@id='Section_ID']='"Maritime Environment Regions"']//RegionList/Region
However, I think it should be returning 10 results (and indeed it does in previous versions of BaseX as well as Saxon). The interesting part is that it does return a single result (as expected) for the first part of the query:
/Region/Sections/Section[./V[@id='Section_ID']='"Maritime Environment Regions"']
...so it appears as though the last part of the query (//RegionList/Region) is descending from the root and not from the single node returned in the first part as I would expect. Is this a bug in BaseX or a misunderstanding on my part of some subtlety of the standard?
Thanks,
Dave
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
I have discovered what appears to be a problem with recursive (or at least re-entering) XQuery functions. It doesn't happen all the time, in fact most of the simple test cases I could come up with seemed to work fine. However, the XQuery code below doesn't behave as expected or as it behaves in Stylus Studio. It is designed to report the number of weekdays between two dates. If the start date is less than the end date it works fine (you can check the answer in Excel using the NETWORKDAYS function). If the start date is greater, it should return the negative difference. Sure enough, the first number returned in the example case is 4 in both BaseX and Stylus Studio. However, the second number is -1 in BaseX when I was expecting -4.
Thanks for looking into this,
Dave
declare namespace functx = "http://www.functx.com"; declare function functx:day-of-week ( $date as xs:anyAtomicType? ) as xs:integer? { if (empty($date)) then () else xs:integer((xs:date($date) - xs:date('1901-01-06')) div xs:dayTimeDuration('P1D')) mod 7 }; declare function local:weekdays ($start as xs:anyAtomicType?, $end as xs:anyAtomicType?) as xs:integer? { if(empty($start) or empty($end)) then() else if($start > $end) then -local:weekdays($end, $start) else let $dayOfWeekStart := functx:day-of-week($start) let $dayOfWeekEnd := functx:day-of-week($end) let $adjDayOfWeekStart := if($dayOfWeekStart = 0) then 7 else $dayOfWeekStart let $adjDayOfWeekEnd := if($dayOfWeekEnd = 0) then 7 else $dayOfWeekEnd return if($adjDayOfWeekStart <= $adjDayOfWeekEnd) then xs:integer((xs:integer(days-from-duration(xs:date($end) - xs:date($start)) div 7) * 5) + max(((min((($adjDayOfWeekEnd + 1), 6)) - $adjDayOfWeekStart), 0))) else xs:integer((xs:integer(days-from-duration(xs:date($end) - xs:date($start)) div 7) * 5) + min((($adjDayOfWeekEnd + 6) - min(($adjDayOfWeekStart, 6)), 5))) }; (local:weekdays('2010-06-14', '2010-06-17'), local:weekdays('2010-06-17', '2010-06-14'))
Dave,
thanks for reporting. I could strip this down to the following example:
declare function local:f($a, $b) { if($a > $b) then local:f($b, $a) else $b - $a }; local:f(1, 0)
Fix is in progress, Christian
On Thu, Jun 17, 2010 at 9:35 PM, Dave Glick dglick@dracorp.com wrote:
I have discovered what appears to be a problem with recursive (or at least re-entering) XQuery functions. It doesn't happen all the time, in fact most of the simple test cases I could come up with seemed to work fine. However, the XQuery code below doesn't behave as expected or as it behaves in Stylus Studio. It is designed to report the number of weekdays between two dates. If the start date is less than the end date it works fine (you can check the answer in Excel using the NETWORKDAYS function). If the start date is greater, it should return the negative difference. Sure enough, the first number returned in the example case is 4 in both BaseX and Stylus Studio. However, the second number is -1 in BaseX when I was expecting -4.
Thanks for looking into this,
Dave
declare namespace functx = "http://www.functx.com"; declare function functx:day-of-week ( $date as xs:anyAtomicType? ) as xs:integer? { if (empty($date)) then () else xs:integer((xs:date($date) - xs:date('1901-01-06')) div xs:dayTimeDuration('P1D')) mod 7 }; declare function local:weekdays ($start as xs:anyAtomicType?, $end as xs:anyAtomicType?) as xs:integer? { if(empty($start) or empty($end)) then() else if($start > $end) then -local:weekdays($end, $start) else let $dayOfWeekStart := functx:day-of-week($start) let $dayOfWeekEnd := functx:day-of-week($end) let $adjDayOfWeekStart := if($dayOfWeekStart = 0) then 7 else $dayOfWeekStart let $adjDayOfWeekEnd := if($dayOfWeekEnd = 0) then 7 else $dayOfWeekEnd return if($adjDayOfWeekStart <= $adjDayOfWeekEnd) then xs:integer((xs:integer(days-from-duration(xs:date($end) - xs:date($start)) div 7) * 5) + max(((min((($adjDayOfWeekEnd + 1), 6)) - $adjDayOfWeekStart), 0))) else xs:integer((xs:integer(days-from-duration(xs:date($end) - xs:date($start)) div 7) * 5) + min((($adjDayOfWeekEnd + 6) - min(($adjDayOfWeekStart, 6)), 5))) }; (local:weekdays('2010-06-14', '2010-06-17'), local:weekdays('2010-06-17', '2010-06-14')) _______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
…fixed – as well as some other issues. This is new in 6.1.7:
- ADD: new "ALTER DB" command to rename databases - ADD: XQuery "file" module (inspired by EXPath) - FIX: XQuery, recursive functions - FIX: XQuery, index access on elements without leaf nodes - FIX: GUI text editor, mouse and keyboard actions synchronized - FIX: GUI text editor, shortcuts for font size (ctrl +/-) - FIX: GUI text view, bold/plain text switch
Link to jar file:
http://basex.org/maven/org/basex/basex/6.1.7
Thanks, Christian
On Thu, Jun 17, 2010 at 10:08 PM, Christian Grün christian.gruen@gmail.com wrote:
Dave,
thanks for reporting. I could strip this down to the following example:
declare function local:f($a, $b) { if($a > $b) then local:f($b, $a) else $b - $a }; local:f(1, 0)
Fix is in progress, Christian
On Thu, Jun 17, 2010 at 9:35 PM, Dave Glick dglick@dracorp.com wrote:
I have discovered what appears to be a problem with recursive (or at least re-entering) XQuery functions. It doesn't happen all the time, in fact most of the simple test cases I could come up with seemed to work fine. However, the XQuery code below doesn't behave as expected or as it behaves in Stylus Studio. It is designed to report the number of weekdays between two dates. If the start date is less than the end date it works fine (you can check the answer in Excel using the NETWORKDAYS function). If the start date is greater, it should return the negative difference. Sure enough, the first number returned in the example case is 4 in both BaseX and Stylus Studio. However, the second number is -1 in BaseX when I was expecting -4.
Thanks for looking into this,
Dave
declare namespace functx = "http://www.functx.com"; declare function functx:day-of-week ( $date as xs:anyAtomicType? ) as xs:integer? { if (empty($date)) then () else xs:integer((xs:date($date) - xs:date('1901-01-06')) div xs:dayTimeDuration('P1D')) mod 7 }; declare function local:weekdays ($start as xs:anyAtomicType?, $end as xs:anyAtomicType?) as xs:integer? { if(empty($start) or empty($end)) then() else if($start > $end) then -local:weekdays($end, $start) else let $dayOfWeekStart := functx:day-of-week($start) let $dayOfWeekEnd := functx:day-of-week($end) let $adjDayOfWeekStart := if($dayOfWeekStart = 0) then 7 else $dayOfWeekStart let $adjDayOfWeekEnd := if($dayOfWeekEnd = 0) then 7 else $dayOfWeekEnd return if($adjDayOfWeekStart <= $adjDayOfWeekEnd) then xs:integer((xs:integer(days-from-duration(xs:date($end) - xs:date($start)) div 7) * 5) + max(((min((($adjDayOfWeekEnd + 1), 6)) - $adjDayOfWeekStart), 0))) else xs:integer((xs:integer(days-from-duration(xs:date($end) - xs:date($start)) div 7) * 5) + min((($adjDayOfWeekEnd + 6) - min(($adjDayOfWeekStart, 6)), 5))) }; (local:weekdays('2010-06-14', '2010-06-17'), local:weekdays('2010-06-17', '2010-06-14')) _______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
basex-talk@mailman.uni-konstanz.de