Mike,

That's correct that the doctype ends up escaped, but after wrapping the doctype 
in document {}, it returns an error I don't understand: "RESTAPI-INVALIDRESULT: 
(err:FOER0000) Invalid result:  reason: GET extension produced 2 results and 1 
mime types: myrest"

Maybe the doctype-public/doctype-system options could be dynamically generated 
and then eval()-ed in a module that simply accepts the document as a parameter 
and outputs it. That might be we worth testing.

-Will


-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Michael Blakeley
Sent: Thursday, November 15, 2012 4:17 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] REST API doctype extension

That sounds like a browser-generated error. Did you try "view source" or curl 
or wget to see the actual response?

I think the immediate problem is that the DOCTYPE ends up XML-escaped. Since it 
wants document-node()*, you might try

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

I'm not sure if that will fix everything, though. You'll end up with something 
like:

<!DOCTYPE ... >
<?xml version="1.0" encoding="UTF-8"?>
<doc/>

That extra <?xml... might cause problems. If so, you'll also need to configure 
the app server to omit the declaration, or tell the module to do so. I think 
the module prolog would be:

    declare option xdmp:output "omit-xml-declaration=yes";

http://docs.marklogic.com/guide/xquery/langoverview#id_71572 also has options 
for setting the public and system doctype, but it seems like the syntax only 
supports literal strings. So it might be tricky to use those in a dynamic way.

-- Mike

On 15 Nov 2012, at 15:20 , Will Thompson <[email protected]> wrote:

> We are trying to extend the REST API to return doctypes for some documents.
> 
> Part of the problem seems to be with the required function signature for GET: 
> document-node()*. This obviously throws a coercion exception when the return 
> value is ('<!DOCTYPE ... >', document{ <doc/> }). So I tried returning 
> nesting the doctype under the document node: document { ('<!DOCTYPE ... 
> >',<doc/>) } - this doesn't throw the exception, but it looks like another 
> one gets caught somewhere, and the page renders a pretty error message:
> 
> "This page contains the following errors:
> 
> error on line 2 at column 1: Document is empty
> 
> Below is a rendering of the page up to the first error."
> 
> The rest of the page is empty. Any suggestions on a good way to do this?
> 
> Thanks,
> 
> Will
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
> 

_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to