/[classpath]/classpath/gnu/xml/dom/html2/DomHTMLDocument.java
ViewVC logotype

Diff of /classpath/gnu/xml/dom/html2/DomHTMLDocument.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by dog, Mon Mar 14 21:10:55 2005 UTC revision 1.4 by dog, Thu Mar 17 19:18:28 2005 UTC
# Line 44  import java.net.MalformedURLException; Line 44  import java.net.MalformedURLException;
44  import java.net.URL;  import java.net.URL;
45  import java.util.Collections;  import java.util.Collections;
46  import java.util.HashMap;  import java.util.HashMap;
47    import java.util.HashSet;
48  import java.util.Map;  import java.util.Map;
49    import java.util.Set;
50  import org.w3c.dom.DOMException;  import org.w3c.dom.DOMException;
51  import org.w3c.dom.Element;  import org.w3c.dom.Element;
52  import org.w3c.dom.Node;  import org.w3c.dom.Node;
# Line 139  public class DomHTMLDocument Line 141  public class DomHTMLDocument
141      ELEMENT_CLASSES = Collections.unmodifiableMap(map);      ELEMENT_CLASSES = Collections.unmodifiableMap(map);
142    }    }
143    
144      private static Set HTML_NS_URIS;
145      static
146      {
147        Set set = new HashSet();
148        set.add("http://www.w3.org/TR/html4/strict");
149        set.add("http://www.w3.org/TR/html4/loose");
150        set.add("http://www.w3.org/TR/html4/frameset");
151        set.add("http://www.w3.org/1999/xhtml");
152        set.add("http://www.w3.org/TR/xhtml1/strict");
153        set.add("http://www.w3.org/TR/xhtml1/loose");
154        set.add("http://www.w3.org/TR/xhtml1/frameset");
155        HTML_NS_URIS = Collections.unmodifiableSet(set);
156      }
157    
158      /**
159       * Convenience constructor.
160       */
161      public DomHTMLDocument()
162      {
163        this(new DomHTMLImpl());
164      }
165    
166    /**    /**
167     * Constructor.     * Constructor.
168     * This is called by the implementation.     * This is called by the DOMImplementation.
169     */     */
170    protected DomHTMLDocument(DomHTMLImpl impl)    public DomHTMLDocument(DomHTMLImpl impl)
171    {    {
172      super(impl);      super(impl);
173    }    }
# Line 366  public class DomHTMLDocument Line 390  public class DomHTMLDocument
390    
391    public Element createElementNS(String uri, String qName)    public Element createElementNS(String uri, String qName)
392    {    {
393        /* If a non-HTML element, use the default implementation. */
394        if (uri != null && !HTML_NS_URIS.contains(uri))
395          {
396            return super.createElementNS(uri, qName);
397          }
398      String localName = qName.toLowerCase();      String localName = qName.toLowerCase();
399      int ci = qName.indexOf(':');      int ci = qName.indexOf(':');
400      if (ci != -1)      if (ci != -1)
# Line 373  public class DomHTMLDocument Line 402  public class DomHTMLDocument
402          localName = qName.substring(ci + 1);          localName = qName.substring(ci + 1);
403        }        }
404      Class t = (Class) ELEMENT_CLASSES.get(localName);      Class t = (Class) ELEMENT_CLASSES.get(localName);
405        /* If a non-HTML element, use the default implementation. */
406      if (t == null)      if (t == null)
407        {        {
408          return super.createElementNS(uri, qName);          return super.createElementNS(uri, qName);
409        }        }
410      try      try
411        {        {
412          Constructor c = t.getConstructor(ELEMENT_PT);          Constructor c = t.getDeclaredConstructor(ELEMENT_PT);
413          Object[] args = new Object[] { this, uri, qName };          Object[] args = new Object[] { this, uri, qName };
414          return (Element) c.newInstance(args);          return (Element) c.newInstance(args);
415        }        }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26