Ignore:
Timestamp:
2008-08-08T13:23:59+12:00 (16 years ago)
Author:
davidb
Message:

Changed 'Element process(Element)' in ModuleInterface to 'Node process(Node)'. After some deliberation is was decided this is a more useful (generic) layer of the DOM to pass information around in. Helps with the DocType problem when producing XSL Transformed pages, for example. When this was an Element, it would loose track of its DocType. Supporting method provided in XMLConverter 'Element nodeToElement(Node)' which checks a nodes docType and casts to Element if appropriate, or if a Document, typecasts to that and then extracts the top-level Element. With this fundamental change in ModuleInterface, around 20 files needed to be updated (Actions, Services, etc) that build on top of 'process()' to reflect this change, and use nodeToElement where necessary.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/util/XMLConverter.java

    r16374 r16688  
    2222import org.w3c.dom.Document;
    2323import org.w3c.dom.DocumentType;
     24import org.w3c.dom.Element;
    2425import org.w3c.dom.Node;
    2526import org.w3c.dom.NodeList;
     
    8182    this.parser.setEntityResolver(er);
    8283    }
    83    
     84
     85
     86    public Element nodeToElement(Node node)
     87    {
     88    short nodeType = node.getNodeType();
     89
     90    if (nodeType == Node.DOCUMENT_NODE) {
     91        Document docNode = (Document)node;
     92        return docNode.getDocumentElement() ;
     93    }
     94    else if (nodeType == Node.ELEMENT_NODE) {
     95        return (Element)node;
     96    }
     97    else {
     98        System.err.println("Expecting Document or Element node type but got " + node.getNodeName());
     99        System.err.println("Returning null");
     100        return null;
     101    }
     102    }
     103
    84104    /** returns a DOM Document */
    85105    public Document getDOM(String in) {
Note: See TracChangeset for help on using the changeset viewer.