[XQZone General] Saving an HTML file with DOCTYPE declaration ?

raff at aromatic.org raff at aromatic.org
Tue Oct 26 13:59:07 PDT 2004


This doesn't really cover David's original request (to save the document on
the local filesystem).

Yes, xdmp:save() seems to be only able to save only XML files (the input
parameter is an element()). This means that actually there is no way through
the APIs to create non-XML files (text or binaries).

Having said that, here your options:

- write an .xqy page that return your HTML with DOCTYPE as downloadable
content

- write a script that fetches your file through an XDBC connection and saves
it (you can do that with a one-liner through my PHP command-line tool :)

I had a third option, but now I forgot :)

Note that CIS (or XQuery) doesn't really like DOCTYPE, so you'll have to
return that as a string, as in your example.

This means that if you say:

  '<!DOCTYPE...>', <HTML>....</HTML>

XDBC will return a list with 2 elements (a string for DOCTYPE and a node for
the HTML content).

I found out that you can say:

  document {
    '<!DOCTYPE...>',
    <HTML>....</HTML>
  }

And in this case XDBC returns a single entry (that very strangely is marked
as text/plain. I guess this is correct because the result is not a "valid"
XML document because of the initial string, but is it the correct behavior
for document {} to let me generate invalid XML ?

-- Raffaele

-----Original Message-----
From: general-bounces at xqzone.marklogic.com
[mailto:general-bounces at xqzone.marklogic.com] On Behalf Of McBeath, Darin W.
(ELS)
Sent: Tuesday, October 26, 2004 6:00 AM
To: General XQZone Discussion
Subject: RE: [XQZone General] Saving an HTML file with DOCTYPE declaration?

A 'hack' for your solution may be to store the DOCTYPE as a 'properties' of
the HTML document stored in CIS.

-----Original Message-----
From: general-bounces at xqzone.marklogic.com
[mailto:general-bounces at xqzone.marklogic.com] On Behalf Of David Sewell
Sent: Monday, October 25, 2004 9:00 PM
To: General XQZone Discussion
Subject: [XQZone General] Saving an HTML file with DOCTYPE declaration?

Using xdmp:save(), one can save a constructed <html> element to a file on
the filesystem. Is there a way, however, to save an HTML file preceded by
a <!DOCTYPE> declaration?

Within an XQuery script, this can be done by returning a sequence
consisting of

   '<!DOCTYPE html etc.>',
   <html> ... </html>

but xdmp:save() can only take a single element as its second argument.

-- 
David Sewell, Editorial and Technical Manager
Electronic Imprint, The University of Virginia Press
PO Box 400318, Charlottesville, VA 22904-4318 USA
Courier: 310 Old Ivy Way, Suite 302, Charlottesville VA 22903
Email: dsewell at virginia.edu   Tel: +1 434 924 9973
______________________________________________

General mailing list
General at xqzone.marklogic.com
http://xqzone.com/mailman/listinfo/general
_______________________________________________

General mailing list
General at xqzone.marklogic.com
http://xqzone.com/mailman/listinfo/general




More information about the General mailing list