Description
(Concerning marklogic-java-client in 6.1.0) The StructuredQueryBuilder currently only allows to serialize a given StructuredQueryDefinition into a String. In cases in which the query needs to be embedded into another XML this makes it necessary to parse the query again.
Here I would kindly request the following feature: Could you please create a public accessible method like:
StructuredQueryBuilder#serialize(XMLStreamWriter)
?
This would vastly improve the possibilities for serialization. For instance org.jdom2.input.StAXStreamWriter could be used to directly serialize a query into a JDOM.
Meanwhile to get access to the method
StructuredQueryBuilder
.By using org.jdom2.input.StAXStreamWriter we noticed, that the namespaces are wrong. What should look like
<query
xmlns="http://marklogic.com/appservices/search"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<word-query>
<field name="title"/><text>Test</text>
</word-query>
</query>
was created as:
<query xmlns="http://marklogic.com/appservices/search"
xmlns:search="http://marklogic.com/appservices/search">
<word-query xmlns="">
<field name="title"/><text>Test</text>
</word-query>
</query>
Notice how the default namespace on word-query
is reset.
If not mistaken I would believe this is due to the fact that the elements (like the word-query) are created with no namespaceUri. c.f.
serializer.writeStartElement(SEARCH_API_NS, "word-query");
Shouldn't it?