Generating XHTML from a Sausalito 2.2 application

13 views
Skip to first unread message

Gunther Rademacher

unread,
Aug 2, 2012, 5:49:25 PM8/2/12
to sausali...@googlegroups.com
Some Sausalito application that used to work on 1.4.4 generates XHTML. Here is a small sample of what it did:

    module namespace def="http://www.example.com/Test/default";
    import module namespace http="http://www.28msec.com/modules/http";
    declare sequential function def:index()
    {
      http:set-content-type("application/xhtml+xml"),
      <html xmlns="http://www.w3.org/1999/xhtml">
        <body>ok</body>
      </html>
    };

Above is the 1.4.4 version. For converting it to 2.2, I changed the 'sequential' annotation and switched to using the 'response' module:

    module namespace def="http://www.example.com/Test/default";
    import module namespace resp="http://www.28msec.com/modules/http/response";
    declare %an:sequential function def:index()
    {
      resp:set-content-type("application/xhtml+xml"),
      <html xmlns="http://www.w3.org/1999/xhtml">
        <body>ok</body>
      </html>
    };

However I have problems getting that to work, because it results in this error message:

    SEPM0009 - omit-xml-declaration parameter is "yes" and the version parameter has a value other than "1.0" and the doctype-system parameter is specified

Now I am fine with XQuery 1.0, so I tried to specify

    xquery version "1.0"

But no success - now it does not let me import the response module:

    XQST0031 - "3.0": XQuery library version can not be imported by a 1.0 version module

Some documentation research led me to the assumption that I would have to use

    resp:set-serialization-parameters(resp:serializer-defaults-xhtml())

instead of just setting the content type. But this did not make a difference.

What can I do to convert my application to 2.2?

Thanks
Gunther

Matthias Brantner

unread,
Aug 2, 2012, 6:46:36 PM8/2/12
to sausali...@googlegroups.com
Thanks Gunther. That's definitely a bug in the system but I'm not sure where exactly, yet.

Could you please try with the following line and let me know if this works?

http:set-content-type("APPLICATION/XHTML+XML"),

Best regards

Matthias

Matthias Brantner

unread,
Aug 2, 2012, 11:34:37 PM8/2/12
to sausali...@googlegroups.com
Gunther

We found and fixed the problem. A fix will be contained in the next release.
In the meantime, you can workaround the problem by explicitly setting
the serialization parameters after setting the content-type. This will overwrite
the default xhtml serialization parameters.

Specifically, you can use the following snippet:

declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";

declare %an:sequential function def:index()
{
resp:set-content-type("application/xhtml+xml"),
resp:set-serialization-parameters(
<output:serialization-parameters xmlns:output="http://www.w3.org/2010/xslt-xquery-serialization">
<output:encoding value="UTF-8"/>
<output:indent value="yes"/>
<output:method value="xhtml"/>
<output:omit-xml-declaration value="no"/>
<output:version value="1.1"/>
<output:doctype-system value="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"/>
<output:doctype-public value="-//W3C//DTD XHTML 1.1//EN"/>
</output:serialization-parameters>
),
<html xmlns="http://www.w3.org/1999/xhtml">
<body>ok</body>
</html>
};

HTH

Best regards

Matthias

On Aug 2, 2012, at 2:49 PM, Gunther Rademacher <g...@gmx.de> wrote:

Gunther Rademacher

unread,
Aug 3, 2012, 6:45:50 AM8/3/12
to sausali...@googlegroups.com
Hi Matthias,

thanks - that helped. But I have modified some of the parameters, to make the browsers happy.

Thanks again
Gunther
Reply all
Reply to author
Forward
0 new messages