[jdom-interest] Expanding <script> element.

Jason Hunter jhunter at xquery.com
Wed Mar 16 10:33:19 PST 2005


As Brad said, something funky's going on if xml:space="preserve" is 
being added because JDOM doesn't ever add that.

What can help you figure it out (and will help us figure it out if you 
can't) is to write up a small sample program that demonstrates the bug. 
  Make the program as trivial as possible, removing ALL unnecessary 
complexity.  For example, create the document content in a String. 
Build it on line one, print it on line two.  That kind of thing.  Make 
it as simple as possible while still showing the problem.  If you 
simplify in some fashion and the problem goes away, that's probably the 
thing responsible.  If the test program can't be simplified any further, 
then it's a JDOM bug and if you send in the sample program we'll fix it.

-jh-

Daniel Rubio wrote:
> 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
> 
> _______________________________________________
> To control your jdom-interest membership:
> http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com
> 


More information about the jdom-interest mailing list