[jdom-interest] entity references replacement

philip.nelson at omniresources.com philip.nelson at omniresources.com
Sun Sep 23 06:41:28 PDT 2001


I think most of what you want is available in the version in cvs now.  SVG
may pose some additional problems though in round tripping because of it's
heavy use of parameter entities and default values.  Give it a try and let
us know what happens.

> -----Original Message-----
> From: Sandro Böhme [mailto:s.boehme at inovex.de]
> Sent: Thursday, September 20, 2001 4:54 AM
> To: jdom-interest at jdom.org
> Subject: [jdom-interest] entity references replacement
> 
> 
> 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-mit
> erlimit: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

_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com



More information about the jdom-interest mailing list