예제 #1
0
 protected static boolean setSupportDTD(XMLInputFactory f, boolean state)
     throws XMLStreamException {
   try {
     f.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.valueOf(state));
     return (willSupportDTD(f) == state);
   } catch (IllegalArgumentException e) {
     // Let's assume that the property (or specific value) is NOT supported...
     return false;
   }
 }
예제 #2
0
  /**
   * @param args
   * @throws Exception
   */
  public static void main(String[] args) throws Exception {

    if (args.length != 1) {
      printUsage();
    }

    filename = args[0];

    XMLInputFactory xmlif = null;
    try {
      xmlif = XMLInputFactory.newInstance();
      xmlif.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.TRUE);
      xmlif.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.FALSE);
      xmlif.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.TRUE);
      xmlif.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE);
    } catch (Exception ex) {
      ex.printStackTrace();
    }
    System.out.println("XMLInputFactory: " + xmlif);
    System.out.println("filename = " + filename);

    XMLStreamReader xmlr = null;
    try {

      FileInputStream fis = new FileInputStream(filename);

      xmlr = xmlif.createXMLStreamReader(fis);

    } catch (Exception ex) {
      ex.printStackTrace();
    }

    for (int event = xmlr.next(); event != XMLStreamConstants.END_DOCUMENT; event = xmlr.next()) {
      if (event == XMLStreamConstants.START_ELEMENT) {
        String element = xmlr.getLocalName();
      }
    }
  }
예제 #3
0
 protected static boolean setNamespaceAware(XMLInputFactory f, boolean state)
     throws XMLStreamException {
   /* Let's not assert, but see if it sticks. Some implementations
    * might choose to silently ignore setting, at least for 'false'?
    */
   try {
     f.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, state ? Boolean.TRUE : Boolean.FALSE);
     return (isNamespaceAware(f) == state);
   } catch (IllegalArgumentException e) {
     /* Let's assume, then, that the property (or specific value for it)
      * is NOT supported...
      */
     return false;
   }
 }
예제 #4
0
 protected XMLStreamReader getCoalescingReader(String content) throws XMLStreamException {
   XMLInputFactory f = XMLInputFactory.newInstance();
   f.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE);
   return f.createXMLStreamReader(new StringReader(content));
 }
예제 #5
0
 protected static void setLazyParsing(XMLInputFactory f, boolean state) throws XMLStreamException {
   f.setProperty(XMLInputFactory2.P_LAZY_PARSING, state ? Boolean.TRUE : Boolean.FALSE);
 }
예제 #6
0
 protected static void setSupportExternalEntities(XMLInputFactory f, boolean state)
     throws XMLStreamException {
   f.setProperty(
       XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, state ? Boolean.TRUE : Boolean.FALSE);
 }
예제 #7
0
 protected static void setReplaceEntities(XMLInputFactory f, boolean state)
     throws XMLStreamException {
   f.setProperty(
       XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, state ? Boolean.TRUE : Boolean.FALSE);
 }
예제 #8
0
 protected static void setValidating(XMLInputFactory f, boolean state) throws XMLStreamException {
   f.setProperty(XMLInputFactory.IS_VALIDATING, Boolean.valueOf(state));
 }
예제 #9
0
 protected static void setCoalescing(XMLInputFactory f, boolean state) throws XMLStreamException {
   f.setProperty(XMLInputFactory.IS_COALESCING, Boolean.valueOf(state));
 }