[jdom-interest] SAXBuilder inclusion of default attributes
Harry Evans
harry at tralfamadore.com
Mon Jan 19 18:32:34 PST 2004
I am working with a third party data source, that submits xml to me.
The DTD for this submission contains several elements that have
attributes with default values, ie if certain attributes for an element
are omitted, they have a default value, as defined by the DTD.
I am doing some manipulation of this file and then sending it on to a
new destination. However, when I use SAXBuilder to build the document
(even with validation off), it explicitly includes the default values
for omitted attributes in the Document.
For example:
<!DOCTYPE smil PUBLIC "-//W3C//DTD SMIL 2.0//EN"
"http://www.w3.org/2001/SMIL20/SMIL20.dtd">
<smil xmlns="http://www.w3.org/2001/SMIL20/Language">
<head>
<layout>
<root-layout/>
<region id="region1_1" top="0" left="0" height="100%" width="100%"/>
</layout>
</head>
<body>
<seq>
<par dur="5000ms">
<text src="slide3.txt" region="region1_1" />
</par>
</seq>
</body>
</smil>
after SAXBuilder parsing (new SAXBuilder(false)) it becomes:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE smil PUBLIC "-//W3C//DTD SMIL 2.0//EN"
"http://www.w3.org/2001/SMIL20/SMIL20.dtd">
<smil xmlns="http://www.w3.org/2001/SMIL20/Language">
<head>
<layout type="text/smil-basic-layout">
<root-layout skip-content="true" width="auto" height="auto" />
<region id="region1_1" top="0" left="0" height="100%" width="100%"
skip-content="true" right="auto" showBackground="always"
soundLevel="100%" bottom="auto" />
</layout>
</head>
<body syncBehavior="default" restartDefault="inherit"
fillDefault="inherit" max="indefinite" fill="default" restart="default"
syncBehaviorDefault="inherit" min="0" syncToleranceDefault="inherit"
syncTolerance="default">
<seq min="0" restart="default" syncTolerance="default"
restartDefault="inherit" max="indefinite" fill="default"
syncToleranceDefault="inherit" syncBehavior="default"
syncBehaviorDefault="inherit" fillDefault="inherit">
<par dur="5000ms" min="0" endsync="last" restart="default"
syncTolerance="default" restartDefault="inherit" max="indefinite"
fill="default" syncToleranceDefault="inherit" syncBehavior="default"
syncBehaviorDefault="inherit" fillDefault="inherit">
<text src="slide3.txt" region="region1_1" min="0"
endsync="media" restart="default" right="auto" syncTolerance="default"
mediaRepeat="preserve" restartDefault="inherit" max="indefinite"
erase="whenDone" fill="default" syncToleranceDefault="inherit"
syncBehavior="default" top="auto" left="auto"
syncBehaviorDefault="inherit" height="auto" bottom="auto" width="auto"
fillDefault="inherit" />
</par>
</seq>
</body>
</smil>
This is fine (in fact, they are actually equivalent documents), except
that I am sending this data to mobile phones (this is a simple smil for
an MMS message) and would prefer to omit the attributes with default
values (or at least attributes with default values that were omitted
from the original document). Is there any way to do this with a custom
SAXHandler or something? I don't need validation, but I do need to stop
swelling the document with attributes that are implied by the DTD, and
can be filled in by the end device. Any suggestions would be appreciated.
Harry Evans
More information about the jdom-interest
mailing list