[xquery-talk] Can I set the DOCTYPE through XQuery (using
mike at saxonica.com
Sat Mar 17 23:41:23 PST 2007
> For anyone who cares,
Your message was sent to me alone, but I'm going back on-list!
> here's what I used to get the XHTML 1.0 Strict DTD in DOCTYPE:
> declare namespace saxon="http://saxon.sf.net/"; declare option
saxon:output "method=xhtml"; declare option saxon:output
"doctype-public=-//W3C//DTD XHTML 1.0 Strict//EN"; declare option
> I just guessed on the doctype-public, but it did what I expected.
> (NOTE: It works with or without the 'declare namespace saxon...' line.
> I'm not sure if it's more correct with or without it)
It seems to be "the XQuery way" to have commonly-used namespace prefixes
predeclared by the processor, so I followed that tradition by predeclaring
the namespace xmlns:saxon="http://saxon.sf.net/". Certainly your query is a
bit more robust if you declare it explicitly, because you're then not
running the risk that a different process will bind the same prefix to some
> I looked at the extensions.html page you referenced before
> posting. I just looked at it again. I see no mention of
I should add to the description of declare option saxon:output some
reference to the serialization parameters that are available. You can use
all the serialization parameters defined in the serialization spec
together with the additional Saxon serialization parameters defined at
> I find it strange that setting the doctype requires an extension.
Architecturally, the query processor and the serializer are different
components, and there is some merit in retaining this separation, so that
your query is a pure "tree-to-tree" transformation without any assumptions
about how the results will be further processed. I think that's the
justification for the XQuery position.
Perhaps XProc will define a way of plugging the output of a query into a
> Are the doctype-public and -system shown somewhere else in
> the Saxon docs? Or, are they just so obvious that I'm the
> only one confused by them being missing?
All the standard serialization parameters in the W3C spec are available, I
just forgot to mention the fact.
More information about the talk