Using XQuery Update Modifies Whole Document

I suspect this is a limitation or unavoidable consequence of how XQuery update works, or at least how Saxon does things, but I wanted to check. If I have a DTD-based document, e.g., a DITA map or topic, and apply an XQuery update to it using Saxon EE, I noticed that the entire document is updated such that the DOCTYPE declaration is removed and all defaulted attributes are now explicit in the instance, which is obviously not to be desired. Is there any way to avoid this behavior? My alternative is to use XSLT of course but I was trying to use XQuery update as being more convenient for certain types of enhancements to existing documents, namely adding attributes to existing elements. Thanks, Eliot ————— Eliot Kimber, Owner Contrext, LLC http://contrext.com

Hi Eliot, AFAIK XSLT will have the same problem, it will not preserve the DOCTYPE declaration and it has no way to tell that an attribute was actually specified in the document or its value comes from the DTD/schema. There are some ways to workaround these but none is elegant. Best Regards, George -- George Cristian Bina <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger http://www.oxygenxml.com On 17/09/14 17:10, Eliot Kimber wrote:
I suspect this is a limitation or unavoidable consequence of how XQuery update works, or at least how Saxon does things, but I wanted to check.
If I have a DTD-based document, e.g., a DITA map or topic, and apply an XQuery update to it using Saxon EE, I noticed that the entire document is updated such that the DOCTYPE declaration is removed and all defaulted attributes are now explicit in the instance, which is obviously not to be desired.
Is there any way to avoid this behavior?
My alternative is to use XSLT of course but I was trying to use XQuery update as being more convenient for certain types of enhancements to existing documents, namely adding attributes to existing elements.
Thanks,
Eliot ————— Eliot Kimber, Owner Contrext, LLC http://contrext.com
_______________________________________________ oXygen-user mailing list oXygen-user@oxygenxml.com http://www.oxygenxml.com/mailman/listinfo/oxygen-user

The difference with XSLT is that I can implement it so that I get the result document I want: I can set the DOCTYPE details and filter out attributes I don't want in the instance. It's more implementation work but doable. With XQuery update, if I had to update every element simply to remove unwanted defaulted attributes then it would be no more convenient than the equivalent XSLT (and harder to write, at least for me). And I don't think XQuery has the equivalent of the <xsl:output> or <xsl:result-document> instructions. Cheers, E. ————— Eliot Kimber, Owner Contrext, LLC http://contrext.com On 9/17/14, 9:20 AM, "George Bina" <george@oxygenxml.com> wrote:
Hi Eliot,
AFAIK XSLT will have the same problem, it will not preserve the DOCTYPE declaration and it has no way to tell that an attribute was actually specified in the document or its value comes from the DTD/schema. There are some ways to workaround these but none is elegant.
Best Regards, George -- George Cristian Bina <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger http://www.oxygenxml.com
On 17/09/14 17:10, Eliot Kimber wrote:
I suspect this is a limitation or unavoidable consequence of how XQuery update works, or at least how Saxon does things, but I wanted to check.
If I have a DTD-based document, e.g., a DITA map or topic, and apply an XQuery update to it using Saxon EE, I noticed that the entire document is updated such that the DOCTYPE declaration is removed and all defaulted attributes are now explicit in the instance, which is obviously not to be desired.
Is there any way to avoid this behavior?
My alternative is to use XSLT of course but I was trying to use XQuery update as being more convenient for certain types of enhancements to existing documents, namely adding attributes to existing elements.
Thanks,
Eliot ————— Eliot Kimber, Owner Contrext, LLC http://contrext.com
_______________________________________________ oXygen-user mailing list oXygen-user@oxygenxml.com http://www.oxygenxml.com/mailman/listinfo/oxygen-user

On 17.9.2014 16:32, Eliot Kimber wrote:
And I don't think XQuery has the equivalent of the <xsl:output> or <xsl:result-document> instructions.
It does, at least in version 3.0. You can use something like: declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization"; declare option output:doctype-public "-//OASIS//DTD ....//EN"; Result document is not supported there. But if you want to strip class attributes, you can write your own serialization method. Jirka -- ------------------------------------------------------------------ Jirka Kosek e-mail: jirka@kosek.cz http://xmlguru.cz ------------------------------------------------------------------ Professional XML consulting and training services DocBook customization, custom XSLT/XSL-FO document processing ------------------------------------------------------------------ OASIS DocBook TC member, W3C Invited Expert, ISO JTC1/SC34 rep. ------------------------------------------------------------------ Bringing you XML Prague conference http://xmlprague.cz ------------------------------------------------------------------

Right, and if I'm going to write my own serialization method I might as well just use XSLT :-) But it's good to know that XQuery 3 has the ability to set DOCTYPE details. Cheers, E. ————— Eliot Kimber, Owner Contrext, LLC http://contrext.com On 9/17/14, 2:30 PM, "Jirka Kosek" <jirka@kosek.cz> wrote:
On 17.9.2014 16:32, Eliot Kimber wrote:
And I don't think XQuery has the equivalent of the <xsl:output> or <xsl:result-document> instructions.
It does, at least in version 3.0. You can use something like:
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization"; declare option output:doctype-public "-//OASIS//DTD ....//EN";
Result document is not supported there. But if you want to strip class attributes, you can write your own serialization method.
Jirka
-- ------------------------------------------------------------------ Jirka Kosek e-mail: jirka@kosek.cz http://xmlguru.cz ------------------------------------------------------------------ Professional XML consulting and training services DocBook customization, custom XSLT/XSL-FO document processing ------------------------------------------------------------------ OASIS DocBook TC member, W3C Invited Expert, ISO JTC1/SC34 rep. ------------------------------------------------------------------ Bringing you XML Prague conference http://xmlprague.cz ------------------------------------------------------------------
participants (3)
-
Eliot Kimber
-
George Bina
-
Jirka Kosek