Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JDOM User »

[jdom-interest] Expanding <script> element.

Daniel Rubio

2005-03-15

Replies:

Hi Guys,
     
       New to the list, but I think I discovered a bug, check it
out :
        * I used the nigthly build (15 Mar 2005)

         Here is a sample of my original content (to be processed
) :  
          <link href="css/sheets.css type="text/css"
rel="stylesheet"></link>
          <script src="jscript/mylibrary.js"
type="text/javascript"></script>

         I am using the following options in my XMLOutputter:
           Format documentFormat = Format.getPrettyFormat();
           documentFormat.setExpandedEmptyElements(true);
           XMLOutputter outputter = new XMLOutputter
(documentFormat);

          The final result is the following :              
                                               
                                               
                   <link href="css/sheets.css type="text/css"
rel="stylesheet"></link>
            <script src="jscript/mylibrary.js"
type="text/javascript" xml:space="preserve"/>

          You will notice the <script> is closed shorthandad like
<script/>, this effect takes place only on the script tag (STRANGE...).
          I have tested using other tags which dont require
content like <img> <meta> etc.etc..and they are all outputted as
expected, expanded : <img></img> <meta></meta> .

          The curious thing is that if my input file opens and
closes the script tag on two lines :
             *Line1  <script src="jscript/mylibrary.js"
type="text/javascript">
             *Line2 </script>

          The output comes out as expected, expanded. Trivial for
one document, unfortunatly I have close to 200 pages with the one-liner
script tag :(

          I browsed through the source code trying to look for
clues but with no luck.
          HINT : Notice that the output format for the script tag
adds the xml:space"preserve" attribute,
                  does anyone know where in the source this
logic is ? I believe the solution might be in that function.


Thanks,
Daniel Rubio
markup@(protected)

_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
©2008 junlu.com - Jax Systems, LLC, U.S.A.