[jdom-interest] entity references replacement

Sandro Böhme s.boehme at inovex.de
Thu Sep 20 02:54:20 PDT 2001


Hi,

after reading and writing a xml file the entity references are replaced by
their complete textual representation.
This is the origin xml file:

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 9.0, SVG Export Plug-In  -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000303 Stylable//EN"
"http://www.w3.org/TR/2000/03/WD-SVG-20000303/DTD/svg-20000303-stylable.dtd"
[

 <!ENTITY st113 "stroke:none;">
 <!ENTITY st111
"fill-rule:nonzero;clip-rule:nonzero;stroke:#000000;stroke-miterlimit:4;">
 <!ENTITY st51 "font-size:8.25;letter-spacing:-0.011em;">
 <!ENTITY st55 "font-family:'ArialMT';">
 <!ENTITY st25 "word-spacing:0.0492em;">
 <!ENTITY st14 "font-size:15.75;letter-spacing:0.006em;">
 <!ENTITY st40 "word-spacing:-0.0333em;">
 ...
]>
<svg width="798.75pt" height="1065.24pt" viewBox="0 0 798.75 1065.24"
xml:space="preserve">
 <g id="Layer_x0020_1" style="&st111; &st55; &st51;">
  <text transform="matrix(1 0 0 1 219.75 19.6348)">
   <tspan x="0" y="0" style="&st113; &st45; &st14;
&st25;">texttexttexttexttexttexttexttexttext</tspan>
  </text>
 </g>
</svg>

After writing it back it looks like this:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000303 Stylable//EN"
"http://www.w3.org/TR/2000/03/WD-SVG-20000303/DTD/svg-20000303-stylable.dtd"
>
<!-- Generator: Adobe Illustrator 9.0, SVG Export Plug-In  -->
<svg width="798.75pt" height="1065.24pt" viewBox="0 0 798.75 1065.24"
xml:space="preserve" contentScriptType="text/ecmascript"
contentStyleType="text/css" enableZoomAndPanControls="true"
preserveAspectRatio="xMidYMid meet">
 <g id="Layer_x0020_1"
style="fill-rule:nonzero;clip-rule:nonzero;stroke:#000000;stroke-miterlimit:
4; font-family:'ArialMT'; font-size:8.25;letter-spacing:-0.011em;">
  <text transform="matrix(1 0 0 1 219.75 19.6348)">
   <tspan x="0" y="0" style="stroke:none; font-family:'Arial-BoldMT';
font-size:15.75;letter-spacing:0.006em;
word-spacing:0.0492em;">texttexttexttexttexttexttexttexttext
   </tspan>
  </text>
 </g>
</svg>

For reading and writing I use these commands:

SAXBuilder builder = new SAXBuilder(false);
org.jdom.Document document = builder.build(filename);
// xmlOut.setExpandEmptyElements(false/true);

XMLOutputter xmlOut = new XMLOutputter();
xmlOut.setEncoding("iso-8859-1");
xmlOut.setOmitDeclaration(false);
xmlOut.setOmitEncoding(false);
xmlOut.output(document,new FileOutputStream(filename+".optimized.svg"));

I tried to use the setExpandEmptyElements() method but it seems to only
change the handing of the character entities / whitespaces.
How can I prevent the XMLOutputter from replacing the entity references in
the styles?
Any help is appreciated.

Thanks,

Sandro




More information about the jdom-interest mailing list