You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Starter.java 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
  3. * For details on use and redistribution please refer to the
  4. * LICENSE file included with these sources."
  5. */
  6. package org.apache.fop.apps;
  7. // SAX
  8. import org.xml.sax.XMLReader;
  9. import org.xml.sax.SAXException;
  10. // Java
  11. import java.io.*;
  12. import java.net.URL;
  13. // FOP
  14. import org.apache.fop.messaging.MessageHandler;
  15. /**
  16. *
  17. * abstract super class
  18. * Creates a SAX Parser (defaulting to Xerces).
  19. *
  20. */
  21. public abstract class Starter {
  22. Options options;
  23. InputHandler inputHandler;
  24. public Starter() {
  25. options = new Options ();
  26. }
  27. public void setInputHandler(InputHandler inputHandler) {
  28. this.inputHandler = inputHandler;
  29. }
  30. abstract public void run();
  31. // setting the parser features
  32. public void setParserFeatures (XMLReader parser) {
  33. setParserFeatures (parser,true);
  34. }
  35. public void setParserFeatures (XMLReader parser,boolean errorDump) {
  36. try {
  37. parser.setFeature("http://xml.org/sax/features/namespace-prefixes",true);
  38. } catch (SAXException e) {
  39. MessageHandler.errorln("Error in setting up parser feature namespace-prefixes");
  40. MessageHandler.errorln("You need a parser which supports SAX version 2");
  41. if (errorDump) {
  42. e.printStackTrace();
  43. }
  44. System.exit(1);
  45. }
  46. }
  47. }