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

G. Ken Holman gkholman at CraneSoftwrights.com
Tue Apr 26 08:07:11 PDT 2011


At 2011-04-26 10:59 -0400, 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.

It is difficult (impossible) to advise you without seeing your code 
to tell you where you have the opportunity to make changes.  Unused 
namespaces in the result are innocuous, but I recognize many people 
would like to clean up declarations not in active use.

It depends on what you have declared for your namespace usage for 
XPath, and how you have written your literal results elements.

It may be that you are copying an element from the source to the 
result, which carries with it its attached namespaces, when you need 
to reconstitute the element in order to prevent that from happening.

Can you reduce your code to a short example that illustrates the problem?

I hope this helps.

. . . . . . . . . . Ken

--
Contact us for world-wide XML consulting & instructor-led training
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/q/
G. Ken Holman                 mailto:gkholman at CraneSoftwrights.com
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal



More information about the talk mailing list