Skip to content


Subversion checkout URL

You can clone with
Download ZIP


AttAwareXMLOutputProcessor to core #66

rolfl opened this Issue · 0 comments

1 participant


contrib-to-core: You can tell this outputter about Attributes to not output, and it will skip those attributes.
Move this code from Contrib to Core

@rolfl rolfl closed this issue from a commit
@rolfl rolfl Fixes #66 Attribute/DTD-default aware output processor.
This fix goes far beyond moving the contrib code to core. Instead, adds a new flag property to Attribute, which indicates whether that Attribute is specified as part of the XML input document, or added as a default by the DTD. The JDOM SAXHandler respects the Attributes2.isSpecified() methods to in turn set the isSPecified flag on the Attribute. The end result is that the isSpecified flag is set on all Attributes unless the attribute was provided by a Default (or 'fixed') DTD declaration.

I cannot find comprehensive documentation for it, but it appears that at least the Xerces parser also manages the specified flag for XML Schema derived attributes.

Additionally, the Format class has been extended to support the isSpecifiedAttributesOnly() method. This can be set with Format.setSpecifiedAttributesOnly(boolean).

All the Outputters (XML, SAX, StAX, DOM) honour the Format.isSpecifiedAttributesOnly() flag. As a consequence, you can now easily exclude those attributes which are created only by DTD (XML Schema) devices when outputting your XML.

The Attribute class itself has been modified to set the specified flag to true if any change is direclty made to the Attribute. The logic being that, if you change the attribute, then it is not what was set in the DTD, and it is now 'specified'.
@rolfl rolfl closed this in a854727
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.