Newbie Question - DOCTYPE declarations
Friday, 2 November 2012 · 4 messages · last reply 6 Nov 2012
RM
Roy MacLean2 Nov 2012 19:39 #
Hi,
How (if at all) can I preserve the DOCTYPE declarations in the XML documents loaded into a database. I've read the documentation pages on Parsers and Catalogs, but I can't see what allows me to do this.
My editor accesses the files via WebDAV ok, but it needs the DOCTYPE for further processing.
Thanks
Roy MacLean| Technical Writer | T: +44 20 7562 7777 | M: +44 7956 474 911 | Dovetail | 51 Moorgate, London, EC2R 6BH, UK |
The information in this email is for the sole use of the intended recipients(s). It may be confidential and/or legally privileged. Any review, disclosure, copying, distribution, retention, or any other use by others is prohibited and may be unlawful. If you are not the intended recipient, please contact the sender and delete all copies. We reserve the right to monitor email content for the purposes of ensuring compliance with legal requirements and company policies and your sending to, or receiving from, us of any email constitutes your agreement to these terms.
CG
Christian Grün2 Nov 2012 20:58 #
Hi Roy,
if documents are parsed and stored as XML, they will be normalized and, in this process, some meta information, such as the doctype declaration, is lost. The same applies e.g. to text declarations (<?xml ...?> or entities.
With XQuery and other interfaces, it is possible to serialize documents with doctype declarations [1]. Unfortunately, there is no way to do so with WebDAV (or at least none of which I have heard so far) as WebDAV was designed to completely work out of the box.
There is a “dirty” trick, however: if you precede your XML documents with a whitespace, they will be stored as "raw" files in the database. This way, you won't be able to apply XQuery etc. to that documents, as BaseX builds no internal index representations for those resources, but you'll get a 100% lossless version back.
Hope that helps,
Christian
[1] http://docs.basex.org/wiki/Serialization
Quoted text · Roy MacLean · 32 lines
On Fri, Nov 2, 2012 at 7:39 PM, Roy MacLean <Roy.MacLean at dovetailsystems.com> wrote: > Hi, > How (if at all) can I preserve the DOCTYPE declarations in the XML documents > loaded into a database. > I've read the documentation pages on Parsers and Catalogs, but I can't see > what allows me to do this. > > My editor accesses the files via WebDAV ok, but it needs the DOCTYPE for > further processing. > > Thanks > > > Roy MacLean| Technical Writer | T: +44 20 7562 7777 | M: +44 7956 474 911 | > Dovetail | 51 Moorgate, London, EC2R 6BH, UK | > > The information in this email is for the sole use of the intended > recipients(s). It may be confidential and/or legally privileged. Any > review, disclosure, copying, distribution, retention, or any other use by > others is prohibited and may be unlawful. If you are not the intended > recipient, please contact the sender and delete all copies. We reserve the > right to monitor email content for the purposes of ensuring compliance with > legal requirements and company policies and your sending to, or receiving > from, us of any email constitutes your agreement to these terms. > > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
RM
Roy MacLean6 Nov 2012 14:39 #
Ok, so if I retrieve using an XQuery, with fn: serialize, I can plug in the doctypes - something like this: -------------------------------------------------------------------------- xquery version "3.0";
let $doc := fn:doc("db/doc.xml")
let $docpublic := $doc//othermeta[name='docpublic']/@value
let $docsystem := $doc//othermeta[name='docsystem']/@value
let $options :=
<output:serialization-parameters>
<output:doctype-public>{$docpublic}</output:doctype-public>
<output:doctype-system >{$docsystem}</output:doctype-system >
</output:serialization-parameters>
return
fn:serialize($doc,$options)
----------------------------------------------------------------------------
However, the output comes back with < and > instead of angle brackets, which raises a parse error. I've experimented with various options to serialize, but with no success.
What am I doing wrong?regards
Roy MacLean| Technical Writer | T: +44 20 7562 7777 | M: +44 7956 474 911 | Dovetail | 51 Moorgate, London, EC2R 6BH, UK |
The information in this email is for the sole use of the intended recipients(s). It may be confidential and/or legally privileged. Any review, disclosure, copying, distribution, retention, or any other use by others is prohibited and may be unlawful. If you are not the intended recipient, please contact the sender and delete all copies. We reserve the right to monitor email content for the purposes of ensuring compliance with legal requirements and company policies and your sending to, or receiving from, us of any email constitutes your agreement to these terms.
Quoted text · Christian Grün · 54 lines
From: Christian Grün [christian.gruen at gmail.com] Sent: 02 November 2012 19:58 To: Roy MacLean Cc: basex-talk at mailman.uni-konstanz.de Subject: Re: [basex-talk] Newbie Question - DOCTYPE declarations Hi Roy, if documents are parsed and stored as XML, they will be normalized and, in this process, some meta information, such as the doctype declaration, is lost. The same applies e.g. to text declarations (<?xml ...?> or entities. With XQuery and other interfaces, it is possible to serialize documents with doctype declarations [1]. Unfortunately, there is no way to do so with WebDAV (or at least none of which I have heard so far) as WebDAV was designed to completely work out of the box. There is a “dirty” trick, however: if you precede your XML documents with a whitespace, they will be stored as "raw" files in the database. This way, you won't be able to apply XQuery etc. to that documents, as BaseX builds no internal index representations for those resources, but you'll get a 100% lossless version back. Hope that helps, Christian [1] http://docs.basex.org/wiki/Serialization On Fri, Nov 2, 2012 at 7:39 PM, Roy MacLean <Roy.MacLean at dovetailsystems.com> wrote: > Hi, > How (if at all) can I preserve the DOCTYPE declarations in the XML documents > loaded into a database. > I've read the documentation pages on Parsers and Catalogs, but I can't see > what allows me to do this. > > My editor accesses the files via WebDAV ok, but it needs the DOCTYPE for > further processing. > > Thanks > > > Roy MacLean| Technical Writer | T: +44 20 7562 7777 | M: +44 7956 474 911 | > Dovetail | 51 Moorgate, London, EC2R 6BH, UK | > > The information in this email is for the sole use of the intended > recipients(s). It may be confidential and/or legally privileged. Any > review, disclosure, copying, distribution, retention, or any other use by > others is prohibited and may be unlawful. If you are not the intended > recipient, please contact the sender and delete all copies. We reserve the > right to monitor email content for the purposes of ensuring compliance with > legal requirements and company policies and your sending to, or receiving > from, us of any email constitutes your agreement to these terms. > > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
CG
Christian Grün6 Nov 2012 14:56 #
It may help to add the following line to the prolog (header) of your query:
declare option output:method "text";Hope this helps,
Christian
Quoted text · Roy MacLean · 91 lines
On Tue, Nov 6, 2012 at 2:39 PM, Roy MacLean <Roy.MacLean at dovetailsystems.com> wrote: > Ok, so if I retrieve using an XQuery, with fn: serialize, I can plug in the doctypes - something like this: > -------------------------------------------------------------------------- > xquery version "3.0"; > > let $doc := fn:doc("db/doc.xml") > > let $docpublic := $doc//othermeta[name='docpublic']/@value > let $docsystem := $doc//othermeta[name='docsystem']/@value > let $options := > <output:serialization-parameters> > <output:doctype-public>{$docpublic}</output:doctype-public> > <output:doctype-system >{$docsystem}</output:doctype-system > > </output:serialization-parameters> > return > fn:serialize($doc,$options) > ---------------------------------------------------------------------------- > However, the output comes back with < and > instead of angle brackets, which raises a parse error. I've experimented with various options to serialize, but with no success. > What am I doing wrong? > > regards > > Roy MacLean| Technical Writer | T: +44 20 7562 7777 | M: +44 7956 474 911 | Dovetail | 51 Moorgate, London, EC2R 6BH, UK | > > The information in this email is for the sole use of the intended recipients(s). It may be confidential and/or legally privileged. Any review, disclosure, copying, distribution, retention, or any other use by others is prohibited and may be unlawful. If you are not the intended recipient, please contact the sender and delete all copies. We reserve the right to monitor email content for the purposes of ensuring compliance with legal requirements and company policies and your sending to, or receiving from, us of any email constitutes your agreement to these terms. > > > ________________________________________ > From: Christian Grün [christian.gruen at gmail.com] > Sent: 02 November 2012 19:58 > To: Roy MacLean > Cc: basex-talk at mailman.uni-konstanz.de > Subject: Re: [basex-talk] Newbie Question - DOCTYPE declarations > > Hi Roy, > > if documents are parsed and stored as XML, they will be normalized > and, in this process, some meta information, such as the doctype > declaration, is lost. The same applies e.g. to text declarations > (<?xml ...?> or entities. > > With XQuery and other interfaces, it is possible to serialize > documents with doctype declarations [1]. Unfortunately, there is no > way to do so with WebDAV (or at least none of which I have heard so > far) as WebDAV was designed to completely work out of the box. > > There is a “dirty” trick, however: if you precede your XML documents > with a whitespace, they will be stored as "raw" files in the database. > This way, you won't be able to apply XQuery etc. to that documents, as > BaseX builds no internal index representations for those resources, > but you'll get a 100% lossless version back. > > Hope that helps, > Christian > > [1] http://docs.basex.org/wiki/Serialization > ___________________________ > > On Fri, Nov 2, 2012 at 7:39 PM, Roy MacLean > <Roy.MacLean at dovetailsystems.com> wrote: >> Hi, >> How (if at all) can I preserve the DOCTYPE declarations in the XML documents >> loaded into a database. >> I've read the documentation pages on Parsers and Catalogs, but I can't see >> what allows me to do this. >> >> My editor accesses the files via WebDAV ok, but it needs the DOCTYPE for >> further processing. >> >> Thanks >> >> >> Roy MacLean| Technical Writer | T: +44 20 7562 7777 | M: +44 7956 474 911 | >> Dovetail | 51 Moorgate, London, EC2R 6BH, UK | >> >> The information in this email is for the sole use of the intended >> recipients(s). It may be confidential and/or legally privileged. Any >> review, disclosure, copying, distribution, retention, or any other use by >> others is prohibited and may be unlawful. If you are not the intended >> recipient, please contact the sender and delete all copies. We reserve the >> right to monitor email content for the purposes of ensuring compliance with >> legal requirements and company policies and your sending to, or receiving >> from, us of any email constitutes your agreement to these terms. >> >> >> _______________________________________________ >> BaseX-Talk mailing list >> BaseX-Talk at mailman.uni-konstanz.de >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >>
Written for BaseX 7.3. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery