It is important to understand what your query is doing:
It is taking some XQuery direct element constructors to
create a data model instance, serializing that instance
to create a string, parsing that string to make another
data model instance, and then copying that data model
instance to create yet another data model instance.
Finally, that data model instance is serialized to produce
the final result. The exact form in which you happened
to have created that br element before the serialization,
parse, and copy, is long, long gone, and there is no
way to reconstruct it after the fact.
(I assume this is just a pared down example of some
more complex process, because you could side step
most of those steps by just constructing the final
data model instance directly without serializing and
parsing in the first place.)
When you parse XML (which is what the unquote is doing) we apply
any in scope schemas to ensure proper whitespace handling.
In the course of this, any defaulted attributes will be picked up.
When you copy those defaulted attributes into a new context
where it cannot be known whether they are defaulted or not
(as you do when you copy them into the element 'root') they
are reified.
So if you don't want to pick up the default XHTML attributes in
this context the thing to do is make sure that the in-scope
schema for this namespace doesn't have them.
The simplest way to do this is to create a dummy schema:
<xs:schema
targetNamespace="http://www.w3.org/1999/xhtml"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
</xs:schema>
Store it in your schemas database, at say "/empty-xhtml.xsd"
Then reference that in your query:
import schema namespace xhtml="http://www.w3.org/1999/xhtml"
at "/empty-xhtml.xsd";
Now this will be the in-scope schema, it has no default attributes,
and life is good. Downside: it also doesn't know anything about
XHTML whitespace rules so attribute values may not get
normalized properly.
A more complex approach would be to store a full version of the
XHTML schema that doesn't have those deprecated attributes
you don't want, and store and reference that instead.
Or, remove the defaulted attributes from your copy manually.
As for the form in which the <br/> comes out, I would suggest
that if you want HTML output, use the HTML or XHTML output
method for serialization rather than the XML output method
(which is the default), as this method knows special rules for
(X)HTML output. It doesn't know all the special rules for HTML5,
but it will be closer to what you want.
declare option xdmp:output "method=xhtml";
//Mary
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general