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/core/Receptionist.java

    r16648 r16688  
    130130    }
    131131
     132
     133
    132134    public String process(String xml_in) {
    133135
    134     Element message = this.converter.getDOM(xml_in).getDocumentElement();
    135     Node page = process(message);
    136     return this.converter.getString(page);
    137     }
    138 
    139     public Element process(Element message) {
    140     Node node = processToPage(message);
    141 
    142     short nodeType = node.getNodeType();
    143 
    144     if (nodeType == Node.DOCUMENT_NODE) {
    145         Document docNode = (Document)node;
    146         return docNode.getDocumentElement() ;
    147     }
    148     else if (nodeType == Node.ELEMENT_NODE) {
    149         return (Element)node;
    150     }
    151     else {
    152         System.err.println("Receptionist.process was not returned a document node");
    153         return null;
    154     }
    155     }
    156 
    157 
    158 
    159 
    160     /** process using strings - just calls process using Elements */
    161     public String processToPage(String xml_in) {
    162 
    163     Element message = this.converter.getDOM(xml_in).getDocumentElement();
    164     Node page = processToPage(message);
     136    Node message_node = this.converter.getDOM(xml_in);
     137    Node page = process(message_node);
    165138    return this.converter.getString(page);
    166139    }
     
    170143     * if something goes wrong, it returns null -
    171144     * TODO:  return a suitable message to the user */
    172     public Node processToPage(Element message) {
     145    public Node process(Node message_node) {
     146
     147    Element message = this.converter.nodeToElement(message_node);
    173148
    174149    // get the request out of the message - assume that there is only one
     
    225200    //logger.info(a+" mesa=" + this.converter.getPrettyString(message));
    226201    // get the page data from the action
    227     Element action_response = a.process(message);
     202    Node action_response = a.process(message);
    228203
    229204    boolean response_only=false;
Note: See TracChangeset for help on using the changeset viewer.