Manipulating jTidy DOM

Hello,

I'm trying to use jTidy to manipulate a collection of HTML files via the DOM that jTidy creates. I've been able to set attributes for existing tags just fine (i.e. Javascript handlers on anchor tags). What I haven't been able to do is add <script> tags to the <head> section. If I use createElement("script") I get a partial output from pprint.

  <!-- start insertion -->  

  <script language="javascript" type="text/javascript">

  <script src="/accent/code/accent.js">

  <!-- end insertion -->  

Note there's no code under the first script, and no closing tags for either tag. 

As an experiment, I inserted a script tag into the HTML I'm loading, and then clone that tag rather than using createElement. Then my newly cloned script tags print fine.

  <!-- start insertion -->

  <script language="javascript" type="text/javascript">

      var accent_repository = "__REPOSITORY__";
      var accent_codebase = "__CODEBASE__";
    
  </script>

  <script language="Javascript" type="text/javascript" src=
  "/accent/code/accent.js">
  </script>

  <!-- end insertion -->  

Obviously there's something different between the node createElement creates and what pprint expects for scripts. I haven't been able to find it in the code though. Can anyone tell me what I'm missing, and how to add scripts without cloning an existing script tag (not all of the pages I'm manipulating have existing scripts)?

Thank you,
Terry Luedtke
National Library of Medicine

Received on Wednesday, 26 March 2003 18:22:27 UTC