[xquery-talk] Removing extra namespace declarations in generated output from Saxon (via XQuery)

David Carlisle davidc at nag.co.uk
Tue Apr 26 08:14:43 PDT 2011

On 26/04/2011 15:59, McBeath, Darin W (ELS-STL) wrote:
> I'm parsing an XML file using Saxon and then applying some XQuery
> against this to selectively get bits/pieces from the original document.
> This is all working fine and the generated document is correct. However,
> my generated document has a lot of extra namespace declarations all over
> the place ... many of them which existed and were needed in the original
> document but are not needed in my new document because there are no
> elements from that namespace contained in the new document. I assume
> there must be some sort of switch setting to disable this type of
> behavior or perhaps an XQuery pragma. I'm serializing the generated XML
> document to a string. I'm using Saxon 9.3 HE. Any insight/help would be
> appreciated.
> Thanks.
> Darin.

It depends if the namespaces are being copied from the source (most 
likely given your description) or generated in the query. In the former 
case then probably setting


to no-preserve will do something useful.


The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 

More information about the talk mailing list