W3C home > Mailing lists > Public > html-tidy@w3.org > January to March 2003

Manipulating jTidy DOM

From: Terry Luedtke <LuedtkT@mail.nlm.nih.gov>
Date: Wed, 26 Mar 2003 17:47:23 -0500
Message-Id: <se81e7c5.041@mail.nlm.nih.gov>
To: <html-tidy@w3.org>

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 3 April 2012 06:13:53 GMT