Ignore:
Timestamp:
2010-12-14T17:15:30+13:00 (13 years ago)
Author:
sjb48
Message:

Working on saving a format statement to the config file. This looks like it should work but changes in FormatAction have caused major issues with Document/Node violations. This is because saving required the format statement as a Document rather than a string (which did work). Added a check to GSXML for xmlNodeToString to check that attrs is not null (attrs will be null unless the node is an element).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/FormatAction.java

    r23405 r23489  
    5555   
    5656    String coll = (String)params.get(GSParams.COLLECTION); //SYSTEM_CLUSTER);
     57    //String subaction = (String)params.get(GSParams.SUBACTION);
    5758    String service = (String)params.get(GSParams.SERVICE);
    5859    String classifier = (String)params.get("cl");
     
    6061
    6162    logger.error("Collection="+coll);
     63    logger.error("Subaction="+subaction);
    6264    logger.error("Service="+service);
    6365    logger.error("Classifier="+classifier);
     
    7274    Element mr_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_FORMAT_STRING, to, lang, uid);
    7375
    74     request.setAttribute("service", service);
    75     if(classifier != null)
    76         request.setAttribute("classifier", classifier);
     76    mr_request.setAttribute("service", service);
     77    mr_request.setAttribute("subaction", subaction);
     78    //if(classifier != null)
     79    mr_request.setAttribute("classifier", classifier);
    7780
    7881    mr_request_message.appendChild(mr_request);
     
    98101            InputSource is = new InputSource( new StringReader( input ) );
    99102            Document d = (Document) builder.parse( is );
    100             //Element e = d.getDocumentElement();
    101             //Node d2 = this.doc.importNode(e,true);
     103            //Node n1 = d.getFirstChild();           
     104            //Document d2 = (Document) this.doc.importNode(e, true);
    102105
    103             //Document format_doc = this.converter.newDOM();
    104             //doc.appendChild(d2);
    105 
    106             //File interface_config_file = new File(GSFile.interfaceConfigFile(GSFile.interfaceHome(GlobalProperties.getGSDL3Home(), (String)this.config_params.get(GSConstants.INTERFACE_NAME))));
    107             //if (!interface_config_file.exists()) {
    108             //  logger.error(" interface config file: "+interface_config_file.getPath()+" not found!");
    109             //}
    110             //Document config_doc = this.converter.getDOM(interface_config_file, "utf-8");
    111             //if (config_doc == null) {
    112             //  logger.error(" could not parse interface config file: "+interface_config_file.getPath());
    113             //}
    114        
    115             //Element config_elem = config_doc.getDocumentElement();
    116             //String base_interface = config_elem.getAttribute("baseInterface");
    117 
     106            //Element format_statement = this.doc.importNode(d, true);
    118107
    119108            // Call XSLT to transform document to xml format string
    120109            XMLTransformer transformer = new XMLTransformer();
    121             //String stylesheet = GSFile.stylesheetFile(GlobalProperties.getGSDL3Home(), (String)this.config_params.get(GSConstants.SITE_NAME), coll, (String)this.config_params.get(GSConstants.INTERFACE_NAME), "oran", "FormatAction");
    122             //logger.error(stylesheet);
     110            // HOW DO I DO THIS PROPERLY?
    123111            Document style_doc = this.converter.getDOM(new File("/home/sam/greenstone3/web/interfaces/oran/transform/formatString.xsl"), "UTF-8");
    124112
     
    127115
    128116            // not sure what to do here - some code from Transforming Receptionist
    129             String transformed = transformer.transformToString(style_doc, d);
    130             //Node transformed = transformer.transform(style_doc, d);
    131            
     117            //String transformed = transformer.transformToString(style_doc, d);
     118            logger.error("About to transform");
     119            Node transformed = (Node) transformer.transform(style_doc, d);  // Failing org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted. ; SystemID: file:///home/sam/greenstone3/packages/tomcat/bin/dummy.xsl
     120
     121            logger.error("Transform successful?");
     122         
     123            if(transformed==null)  // not null
     124                logger.error("TRANSFORMED IS NULL");
     125
     126            logger.error("begin import");
     127            Node imported = this.doc.importNode(transformed, true); // There was an exception org.w3c.dom.DOMException: NOT_SUPPORTED_ERR: The implementation does not support the requested type of object or operation.
     128            logger.error("finished import");
     129
     130            String format_string2 = GSXML.xmlNodeToString(imported); // null pointer exception occuring here
     131            logger.error("format string="+format_string2);
     132 
    132133            Element format = this.doc.createElement(GSXML.FORMAT_STRING_ELEM);
    133             GSXML.setNodeText(format, transformed);
    134             //format.appendChild(this.doc.createTextNode(transformed));
     134            //GSXML.setNodeText(format, transformed);
     135            format.appendChild(transformed);
    135136            //format.setNodeValue(transformed);
    136137            mr_request.appendChild(format);
Note: See TracChangeset for help on using the changeset viewer.