Ignore:
Timestamp:
2010-11-16T17:12:05+13:00 (13 years ago)
Author:
sjb48
Message:

Working on saving the format statement. Currently have a button that calls the system action and returns some html. Working on system.xsl but need to get the format string from String to XML. I have found out that HTML is not necessarily valid XML.

File:
1 edited

Legend:

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

    r16688 r23333  
    1212import java.io.File;
    1313import java.util.HashMap;
     14import java.util.*;
     15import java.io.StringReader;
     16import org.xml.sax.InputSource;
     17import javax.xml.parsers.DocumentBuilder;
     18import javax.xml.parsers.DocumentBuilderFactory;
    1419
    1520import org.apache.log4j.*;
     
    5560        String info = (String)params.get(GSParams.SYSTEM_SUBSET);
    5661        system.setAttribute(GSXML.SYSTEM_SUBSET_ATT, info);
    57    
     62    }
     63    else if(subaction.equals("s")) { // save format statement
     64         logger.error("Initiate save");
     65         String format_string = (String)params.get("data");
     66         logger.error("data="+format_string);
     67         Iterator it = params.keySet().iterator();
     68         while(it.hasNext())
     69         {
     70            logger.error("Param: "+it.next());
     71         } 
     72        Element page_response = this.doc.createElement(GSXML.RESPONSE_ELEM);
     73
     74        try {
     75            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
     76            DocumentBuilder builder = factory.newDocumentBuilder();
     77            InputSource is = new InputSource( new StringReader( format_string ) );
     78            Document d = builder.parse( is );
     79            page_response.appendChild(d);
     80        }
     81        catch( Exception ex ) {
     82            logger.error("There was an exception "+ex);
     83        }
     84
     85        //Element child = this.doc.createElement("div"); //format_string);
     86        //Node text = this.doc.createTextNode(format_string); //"<h1>Hi there and greetings!</h1>");
     87        //child.innerHTML = "<h1>Hi there and greetings!</h1>";
     88        //child.setNodeValue(format_string);
     89        //child.appendChild(text);
     90        result.appendChild(page_response);
     91        return result;
    5892    } else {
    5993        String name = (String)params.get(GSParams.SYSTEM_MODULE_NAME);
Note: See TracChangeset for help on using the changeset viewer.