Changeset 21779


Ignore:
Timestamp:
2010-03-15T10:47:54+13:00 (12 years ago)
Author:
kjdon
Message:

modify the output to use the nice stylesheet

File:
1 edited

Legend:

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

    r16688 r21779  
    7474  protected String site = "";
    7575 
     76  // do we output the stylesheet processing instruction?
     77  protected boolean use_oai_stylesheet = true;
     78  protected String oai_stylesheet = "interfaces/oai/oai2.xsl";
     79
    7680  static Logger logger = Logger.getLogger(org.greenstone.gsdl3.OAIServer.class.getName());
    7781 
     
    173177    this.recept.configure(oai_config);
    174178   
     179    // also, we have something we want to get from here - useOAIStylesheet
     180    this.configure(oai_config);
    175181  }//end of init()
    176182 
     183  private void configure(Element oai_config) {
     184    Element use_stylesheet_elem = (Element)GSXML.getChildByTagName(oai_config, OAIXML.USE_STYLESHEET);
     185    if (use_stylesheet_elem != null) {
     186      String value = GSXML.getNodeText(use_stylesheet_elem);
     187      if (value.equals("no")) {
     188    this.use_oai_stylesheet = false;
     189      }
     190    }
     191    if (this.use_oai_stylesheet) {
     192      // now see if there is a custom stylesheet specified
     193      Element stylesheet_elem = (Element)GSXML.getChildByTagName(oai_config, OAIXML.STYLESHEET);
     194      if (stylesheet_elem != null) {
     195    String value = GSXML.getNodeText(stylesheet_elem);
     196    if (!value.equals("")) {
     197      oai_stylesheet = value;
     198    }
     199      }
     200     
     201    }
     202  }
    177203  private void initVerbs() {
    178204    verb_set = new HashSet();
     
    266292      }
    267293      xml_response.appendChild(verb_elem);
    268       //this line never got displayed
    269       //out.println("<?xml version='1.0' encoding='UTF-8' ?>");
     294
     295      out.println("<?xml version='1.0' encoding='UTF-8' ?>");
     296      if (this.use_oai_stylesheet) {
     297    out.println("<?xml-stylesheet type='text/xsl' href='"+this.oai_stylesheet+"' ?>\n");
     298      }
    270299      out.println(this.converter.getPrettyString(xml_response));
    271300      return;
     
    319348      }
    320349    }
     350    out.println("<?xml version='1.0' encoding='UTF-8' ?>");
     351    if (this.use_oai_stylesheet) {
     352      out.println("<?xml-stylesheet type='text/xsl' href='"+this.oai_stylesheet+"' ?>\n");
     353    }
    321354    out.println (this.converter.getPrettyString (xml_response));
    322355    return;
Note: See TracChangeset for help on using the changeset viewer.