Hi Yvonne,
The canonical solution is to store and retrieve your file as binary file [1]. Instead of fn:doc, you can use db:retrieve to access this resource [1].
Hope this helps, Christian
[1] http://docs.basex.org/wiki/Databases
On Thu, Jan 7, 2016 at 1:33 AM, Wang, Yvonne yvonne.wang@sap.com wrote:
Hi,
I have sample dtd file such as below, I want to add the dtd file as is in baseX.
Since the dtd file is not in xml format, there are currently two option I can thought about
Use TEXT as input format
When I add it using baseX client UI, I got following output. Since we just need store the dtd file and later get it back as is. So I can not use doc function to retrieve it back as is.
<text>
<line><dtd></line>
<line><!--</line>
<line><?xml encoding="UTF-8"?></line>
<line/>
<line> <tmpComment>Sample rng file comments</tmpComment></line>
<line/>
<line><!ELEMENT first (#PCDATA)></line>
<line/>
<line><!ELEMENT last (#PCDATA)></line>
<line/>
<line><!ELEMENT user (first,last)></line>
<line><!ATTLIST user</line>
<line> xmlns:xsi CDATA #FIXED 'http://www.w3.org/2001/XMLSchema-instance'</line>
<line> xsi:schemaLocation CDATA #FIXED 'http://ariba.com.com/Core_after_xsd.xsd%27%3E;</line>
<line>--></line>
</text>
Format it to xml using <dtd> <!—original data --> </dtd> when
add, and remove those dtd and comment tag when download using doc() function.
And there is extra handling required for nested xml comment.
Is there any other better approach for adding dtd file which can be retrieved as its original content?
Thanks
Yvonne
===========================================================================================================================
Sample.dtd
<?xml encoding="UTF-8"?>
<!-- Sample rng file comments -->
<!ELEMENT first (#PCDATA)>
<!ELEMENT last (#PCDATA)>
<!ELEMENT user (first,last)>
<!ATTLIST user xmlns:xsi CDATA #FIXED 'http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation CDATA #FIXED 'http://ariba.com.com/Core_after_xsd.xsd'>