[XQZone General] Saving an HTML file with DOCTYPE

Michael Blakeley michael.blakeley at marklogic.com
Wed Oct 27 14:26:47 PDT 2004


> Date: Tue, 26 Oct 2004 13:59:07 -0700
> From: raff at aromatic.org
> 
> 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 :)

Perhaps this?

let $e := <test/>
let $n := document {
'<?xml version="1.0"?>',
$e
}
return (
xdmp:save("/tmp/test", $n),
current-dateTime()
)

$ cat /tmp/test
<?xml version="1.0"?><test/>

This is basically the same as your XDBC option, but using xdmp:save(). 
The resulting document should have a root text node, rather than a root 
element: essentially, you've converted the xml in $e to text. You can do 
similar things with binary nodes, too.

-- Mike



More information about the General mailing list