[jdom-interest] Expanding <script> element.

Daniel Rubio markup at osmosislatina.com
Tue Mar 15 19:49:07 PST 2005


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 at osmosislatina.com



More information about the jdom-interest mailing list