Changeset 23340


Ignore:
Timestamp:
11/24/10 16:38:16 (11 years ago)
Author:
sjb48
Message:

I now have a button on the page that sends the format string back to the server via a new SystemAction subaction. The format string is parsed and a DOM tree generated. The system xslt will then transform the DOM tree into XML. It currently transforms templates and combo-based metadata.

Location:
main/trunk/greenstone3
Files:
3 edited

Legend:

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

    r23336 r23340  
    1818import javax.xml.parsers.DocumentBuilderFactory;
    1919
     20import java.io.*;
     21import org.xml.sax.*;
     22import javax.xml.parsers.SAXParserFactory;
     23import javax.xml.parsers.ParserConfigurationException;
     24import javax.xml.parsers.SAXParser;
     25
    2026import java.io.PrintWriter;
    2127import java.io.StringWriter;
     
    2632   
    2733      static Logger logger = Logger.getLogger(org.greenstone.gsdl3.action.SystemAction.class.getName());
     34
     35    String tempVal = "";
    2836
    2937    /** process a request */
     
    6876         String format_string = (String)params.get("data");
    6977         logger.error("data="+format_string);
     78
     79         //SamParser sam = new SamParser();
     80         //String format_statement = sam.parse(input);
     81         //logger.error("format string="+format_statement);
     82   
     83        Element page_response = this.doc.createElement(GSXML.RESPONSE_ELEM);
     84
    7085         Iterator it = params.keySet().iterator();
    7186         while(it.hasNext())
     
    7388            logger.error("Param: "+it.next());
    7489         } 
    75         Element page_response = this.doc.createElement(GSXML.RESPONSE_ELEM);
    76 
     90
     91        //Node text = this.doc.createTextNode(format_string);
     92        //page_response.appendChild(text);
     93   
     94       
    7795        try {
    7896            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    7997            DocumentBuilder builder = factory.newDocumentBuilder();
    80             String input = "<html><head><title></title></head><body>" + format_string + "</body></html>";
     98            //String input = "<html><head><title></title></head><body>" + format_string + "</body></html>";
     99            String input = format_string;
    81100            InputSource is = new InputSource( new StringReader( input ) );
    82101            Document d = builder.parse( is );
    83             page_response.appendChild(d);
     102            Element e = d.getDocumentElement();
     103           
     104            page_response.appendChild(this.doc.importNode(e, true));
    84105        }
    85106        catch( Exception ex ) {
     
    93114            logger.error(sw.toString());
    94115        }
    95 
     116       
     117   
    96118        //Element child = this.doc.createElement("div"); //format_string);
    97119        //Node text = this.doc.createTextNode(format_string); //"<h1>Hi there and greetings!</h1>");
     
    131153    }
    132154
     155    /*
     156    public void parse (String message) {
     157        //get a factory
     158        SAXParserFactory spf = SAXParserFactory.newInstance();
     159        try {
     160
     161            //get a new instance of parser
     162            SAXParser sp = spf.newSAXParser();
     163            InputSource is = new InputSource( new StringReader( message ) );
     164            //parse the file and also register this class for call backs
     165            sp.parse(is, new SamParser());
     166
     167        }catch(SAXException se) {
     168            se.printStackTrace();
     169        }catch(ParserConfigurationException pce) {
     170            pce.printStackTrace();
     171        }catch (IOException ie) {
     172            ie.printStackTrace();
     173        }
     174    }
     175    */
     176
     177    //Event Handlers
     178/*    public void startElement(String uri, String localName, String qName,
     179        Attributes attributes) throws SAXException {
     180        //reset
     181        logger.error("Start Element: "+qName);
     182        //if(qName.equalsIgnoreCase("Template")) {
     183            //create a new instance of employee
     184            //tempEmp = new Employee();
     185            //tempEmp.setType(attributes.getValue("type"));
     186           
     187        //}
     188    }
     189
     190
     191    public void characters(char[] ch, int start, int length) throws SAXException {
     192        tempVal = new String(ch,start,length);
     193    }
     194
     195    public void endElement(String uri, String localName,
     196        String qName) throws SAXException {
     197
     198        logger.error("Characters: "+tempVal);
     199        logger.error("End Element: "+qName);
     200        /*
     201        if(qName.equalsIgnoreCase("Employee")) {
     202            //add it to the list
     203            myEmpls.add(tempEmp);
     204
     205        }else if (qName.equalsIgnoreCase("Name")) {
     206            tempEmp.setName(tempVal);
     207        }else if (qName.equalsIgnoreCase("Id")) {
     208            tempEmp.setId(Integer.parseInt(tempVal));
     209        }else if (qName.equalsIgnoreCase("Age")) {
     210            tempEmp.setAge(Integer.parseInt(tempVal));
     211        } */
     212
     213    //}
     214
    133215}
  • main/trunk/greenstone3/web/interfaces/oran/js/gui_div.js

    r23336 r23340  
    99    var formatDiv = document.getElementById('formatStatement');
    1010    var formatStatement = innerXHTML(formatDiv);
    11     console.log(formatStatement);
     11    //console.log(formatStatement);
    1212
    1313
  • main/trunk/greenstone3/web/interfaces/oran/transform/layouts/xml-to-gui.xsl

    r23336 r23340  
    128128        <xsl:choose>
    129129            <xsl:when test="$current = $meta">
    130                 <xsl:text disable-output-escaping="yes">&lt;option value="</xsl:text><xsl:value-of select="$meta"/><xsl:text disable-output-escaping="yes">" selected&gt;</xsl:text><xsl:value-of select="$meta"/><xsl:text disable-output-escaping="yes">&lt;/option&gt;</xsl:text>
     130                <xsl:text disable-output-escaping="yes">&lt;option value="</xsl:text><xsl:value-of select="$meta"/><xsl:text disable-output-escaping="yes">" selected="selected"&gt;</xsl:text><xsl:value-of select="$meta"/><xsl:text disable-output-escaping="yes">&lt;/option&gt;</xsl:text>
    131131                <!-- <option value ="{$meta}" selected="selected"><xsl:value-of select="$meta"/></option> -->
    132132            </xsl:when>
Note: See TracChangeset for help on using the changeset viewer.