com.sun.org.apache.xerces.internal.parsers.XMLGrammarPreparser

Here are the examples of the java api class com.sun.org.apache.xerces.internal.parsers.XMLGrammarPreparser taken from open source projects.

1. PreParseGrammarTest#main()

Project: openjdk
Source File: PreParseGrammarTest.java
View license
public static void main(String[] args) throws FileNotFoundException, XNIException, IOException {
    File xsdf = new File(System.getProperty("test.src", ".") + "/test.xsd");
    InputStream is = new BufferedInputStream(new FileInputStream(xsdf));
    XMLInputSource xis = new XMLInputSource(null, null, null, is, null);
    XMLGrammarPreparser gp = new XMLGrammarPreparser();
    gp.registerPreparser(XMLGrammarDescription.XML_SCHEMA, null);
    //The NullPointerException is observed on next call during ant task
    // execution
    Grammar res = gp.preparseGrammar(XMLGrammarDescription.XML_SCHEMA, xis);
    System.out.println("Grammar preparsed successfully:" + res);
    return;
}

2. DOMNormalizer#createGrammarPool()

Project: openjdk
Source File: DOMNormalizer.java
View license
//normalizeNode
private XMLGrammarPool createGrammarPool(DocumentTypeImpl docType) {
    XMLGrammarPoolImpl pool = new XMLGrammarPoolImpl();
    XMLGrammarPreparser preParser = new XMLGrammarPreparser(fSymbolTable);
    preParser.registerPreparser(XMLGrammarDescription.XML_DTD, null);
    preParser.setFeature(Constants.XERCES_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE, true);
    preParser.setFeature(Constants.XERCES_FEATURE_PREFIX + Constants.VALIDATION_FEATURE, true);
    preParser.setProperty(Constants.XERCES_PROPERTY_PREFIX + Constants.XMLGRAMMAR_POOL_PROPERTY, pool);
    String internalSubset = docType.getInternalSubset();
    XMLInputSource is = new XMLInputSource(docType.getPublicId(), docType.getSystemId(), null, false);
    if (internalSubset != null)
        is.setCharacterStream(new StringReader(internalSubset));
    try {
        DTDGrammar g = (DTDGrammar) preParser.preparseGrammar(XMLGrammarDescription.XML_DTD, is);
        ((XMLDTDDescription) g.getGrammarDescription()).setRootName(docType.getName());
        is.setCharacterStream(null);
        g = (DTDGrammar) preParser.preparseGrammar(XMLGrammarDescription.XML_DTD, is);
        ((XMLDTDDescription) g.getGrammarDescription()).setRootName(docType.getName());
    } catch (XNIException e) {
    } catch (IOException e) {
    }
    return pool;
}