类org.w3c.dom.DOMConfiguration源码实例Demo

下面列出了怎么用org.w3c.dom.DOMConfiguration的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: mdw   文件: DomHelper.java
public static String toXml(Document domDoc) throws TransformerException {
    DOMImplementation domImplementation = domDoc.getImplementation();
    if (domImplementation.hasFeature("LS", "3.0") && domImplementation.hasFeature("Core", "2.0")) {
        DOMImplementationLS domImplementationLS = (DOMImplementationLS) domImplementation.getFeature("LS", "3.0");
        LSSerializer lsSerializer = domImplementationLS.createLSSerializer();
        DOMConfiguration domConfiguration = lsSerializer.getDomConfig();
        if (domConfiguration.canSetParameter("xml-declaration", Boolean.TRUE))
            lsSerializer.getDomConfig().setParameter("xml-declaration", Boolean.FALSE);
        if (domConfiguration.canSetParameter("format-pretty-print", Boolean.TRUE)) {
            lsSerializer.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE);
            LSOutput lsOutput = domImplementationLS.createLSOutput();
            lsOutput.setEncoding("UTF-8");
            StringWriter stringWriter = new StringWriter();
            lsOutput.setCharacterStream(stringWriter);
            lsSerializer.write(domDoc, lsOutput);
            return stringWriter.toString();
        }
    }
    return toXml((Node) domDoc);
}
 
源代码2 项目: jlibs   文件: XSParser.java
public XSParser(LSResourceResolver entityResolver, DOMErrorHandler errorHandler){
    System.setProperty(DOMImplementationRegistry.PROPERTY, DOMXSImplementationSourceImpl.class.getName());
    DOMImplementationRegistry registry;
    try{
        registry = DOMImplementationRegistry.newInstance();
    }catch(Exception ex){
        throw new ImpossibleException(ex);
    }
    XSImplementationImpl xsImpl = (XSImplementationImpl)registry.getDOMImplementation("XS-Loader");

    xsLoader = xsImpl.createXSLoader(null);
    DOMConfiguration config = xsLoader.getConfig();

    config.setParameter(Constants.DOM_VALIDATE, Boolean.TRUE);

    if(entityResolver!=null)
        config.setParameter(Constants.DOM_RESOURCE_RESOLVER, entityResolver);

    if(errorHandler!=null)
        config.setParameter(Constants.DOM_ERROR_HANDLER, errorHandler);
}
 
源代码3 项目: openjdk-jdk9   文件: DOMConfigurationTest.java
/**
 * Equivalence class partitioning with state and input values orientation
 * for public void setParameter(String name, Object value) throws
 * DOMException, <br>
 * <b>pre-conditions</b>: the attribute has EntityReference to '&lt;', <br>
 * <b>name</b>: well-formed <br>
 * <b>value</b>: false. <br>
 * <b>Expected results</b>: No error is reported
 */
@Test
public void testWellFormed002() {
    Document doc = null;
    try {
        doc = loadDocument(null, test2_xml);
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }

    DOMConfiguration config = doc.getDomConfig();
    if (!config.canSetParameter("well-formed", Boolean.FALSE)) {
        System.out.println("OK, setting 'well-formed' to false is not supported");
        return;
    }
    config.setParameter("well-formed", Boolean.FALSE);

    Element root = doc.getDocumentElement();

    Attr attr = doc.createAttributeNS(null, "attr");
    attr.appendChild(doc.createEntityReference("x"));

    root.setAttributeNode(attr);

    TestHandler testHandler = new TestHandler();
    config.setParameter("error-handler", testHandler);

    doc.normalizeDocument();

    if (testHandler.getError() != null || null != testHandler.getFatalError()) {
        Assert.fail("unexpected error: " + testHandler.getFatalError() + "; " + testHandler.getError());
    }

    return; // Status.passed("OK");

}
 
源代码4 项目: openjdk-jdk9   文件: DOMConfigurationTest.java
/**
 * Equivalence class partitioning with state and input values orientation
 * for public void setParameter(String name, Object value) throws
 * DOMException, <br>
 * <b>pre-conditions</b>: The root contains a CDATASection with the
 * termination marker ']]&gt;', <br>
 * <b>name</b>: split-cdata-sections <br>
 * <b>value</b>: false. <br>
 * <b>Expected results</b>: No warning is reported
 */
@Test
public void testSplitCDATA002() {
    DOMImplementation domImpl = null;
    try {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setNamespaceAware(true);
        dbf.setValidating(true);
        domImpl = dbf.newDocumentBuilder().getDOMImplementation();
    } catch (ParserConfigurationException pce) {
        Assert.fail(pce.toString());
    } catch (FactoryConfigurationError fce) {
        Assert.fail(fce.toString());
    }

    Document doc = domImpl.createDocument("namespaceURI", "ns:root", null);

    DOMConfiguration config = doc.getDomConfig();
    CDATASection cdata = doc.createCDATASection("text]" + "]>text");
    doc.getDocumentElement().appendChild(cdata);

    TestHandler testHandler = new TestHandler();
    config.setParameter("error-handler", testHandler);

    if (!config.canSetParameter("split-cdata-sections", Boolean.FALSE)) {
        Assert.fail("cannot set the parameters 'split-cdata-sections' to false");
    }
    config.setParameter("split-cdata-sections", Boolean.FALSE);

    doc.normalizeDocument();
    if (null == testHandler.getError()) {
        Assert.fail("no error is reported");
    }

    return; // Status.passed("OK");

}
 
源代码5 项目: openjdk-jdk9   文件: DOMConfigurationTest.java
/**
 * Equivalence class partitioning with state and input values orientation
 * for public void setParameter(String name, Object value) throws
 * DOMException, <br>
 * <b>pre-conditions</b>: the document root element has a text node with
 * four white space characters, <br>
 * <b>name</b>: element-content-whitespace <br>
 * <b>value</b>: true. <br>
 * <b>Expected results</b>: the text node is preserved
 */
@Test
public void testECWhitespace001() {
    Document doc = null;
    try {
        doc = loadDocument(null, test3_xml);
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }

    Element root = doc.getDocumentElement();
    Text text = doc.createTextNode("\t\n\r ");
    root.appendChild(text);

    DOMConfiguration config = doc.getDomConfig();
    if (!config.canSetParameter("element-content-whitespace", Boolean.TRUE)) {
        Assert.fail("setting 'element-content-whitespace' to true is not supported");
    }
    config.setParameter("element-content-whitespace", Boolean.TRUE);

    if (!config.canSetParameter("validate", Boolean.TRUE)) {
        System.out.println("OK, setting 'validate' to true is not supported");
        return;
    }
    config.setParameter("validate", Boolean.TRUE);

    setHandler(doc);
    doc.normalizeDocument();

    Node firstChild = root.getFirstChild();
    if (firstChild == null || firstChild.getNodeType() != Node.TEXT_NODE || !((Text) firstChild).isElementContentWhitespace()) {
        Assert.fail("the first child is " + firstChild + ", expected a text node with the four whitespace characters");
    }

    return; // Status.passed("OK");

}
 
源代码6 项目: openjdk-jdk9   文件: DOMConfigurationTest.java
/**
 * Equivalence class partitioning with state and input values orientation
 * for public void setParameter(String name, Object value) throws
 * DOMException, <br>
 * <b>pre-conditions</b>: the doc's root element contains superfluous
 * namespace declarations, <br>
 * <b>name</b>: canonical-form <br>
 * <b>value</b>: true. <br>
 * <b>Expected results</b>: the superfluous namespace declarations are
 * removed
 */
@Test
public void testCanonicalForm003() {
    DOMImplementation domImpl = null;
    try {
        domImpl = DocumentBuilderFactory.newInstance().newDocumentBuilder().getDOMImplementation();
    } catch (ParserConfigurationException pce) {
        Assert.fail(pce.toString());
    } catch (FactoryConfigurationError fce) {
        Assert.fail(fce.toString());
    }

    Document doc = domImpl.createDocument("namespaceURI", "ns:root", null);

    DOMConfiguration config = doc.getDomConfig();

    Element root = doc.getDocumentElement();
    String XMLNS = "http://www.w3.org/2000/xmlns/";
    root.setAttributeNS(XMLNS, "xmlns:extra1", "ExtraNS1");
    root.setAttributeNS(XMLNS, "xmlns:extra2", "ExtraNS2");

    if (!config.canSetParameter("canonical-form", Boolean.TRUE)) {
        System.out.println("OK, setting 'canonical-form' to true is not supported");
        return;
    }
    config.setParameter("canonical-form", Boolean.TRUE);
    setHandler(doc);
    doc.normalizeDocument();

    String xmlns2 = root.getAttributeNS(XMLNS, "extra1");
    if (xmlns2 == null || xmlns2.length() != 0) {
        Assert.fail("superfluous namespace declarations is not removed: xmlns:extra2 = " + xmlns2);
    }

    return; // Status.passed("OK");
}
 
源代码7 项目: openjdk-jdk9   文件: DOMConfigurationTest.java
/**
 * Equivalence class partitioning with state and input values orientation
 * for public void setParameter(String name, Object value) throws
 * DOMException, <br>
 * <b>pre-conditions</b>: the root element has one CDATASection followed by
 * one Text node, <br>
 * <b>name</b>: cdata-sections <br>
 * <b>value</b>: true. <br>
 * <b>Expected results</b>: the CDATASection is left intact
 */
@Test
public void testCdataSections001() {
    DOMImplementation domImpl = null;
    try {
        domImpl = DocumentBuilderFactory.newInstance().newDocumentBuilder().getDOMImplementation();
    } catch (ParserConfigurationException pce) {
        Assert.fail(pce.toString());
    } catch (FactoryConfigurationError fce) {
        Assert.fail(fce.toString());
    }

    Document doc = domImpl.createDocument("namespaceURI", "ns:root", null);

    String cdataText = "CDATA CDATA CDATA";
    String textText = "text text text";

    CDATASection cdata = doc.createCDATASection(cdataText);
    Text text = doc.createTextNode(textText);

    DOMConfiguration config = doc.getDomConfig();
    config.setParameter("cdata-sections", Boolean.TRUE);

    Element root = doc.getDocumentElement();
    root.appendChild(cdata);
    root.appendChild(text);

    setHandler(doc);
    doc.normalizeDocument();

    Node returned = root.getFirstChild();

    if (returned.getNodeType() != Node.CDATA_SECTION_NODE) {
        Assert.fail("reurned: " + returned + ", expected: CDATASection");
    }

    return; // Status.passed("OK");

}
 
源代码8 项目: openjdk-jdk9   文件: DOMConfigurationTest.java
/**
 * Equivalence class partitioning with state and input values orientation
 * for public void setParameter(String name, Object value) throws
 * DOMException, <br>
 * <b>pre-conditions</b>: the root element has two Comment nodes, <br>
 * <b>name</b>: comments <br>
 * <b>value</b>: true. <br>
 * <b>Expected results</b>: the Comment nodes belong to the root element
 */
@Test
public void testComments001() {
    DOMImplementation domImpl = null;
    try {
        domImpl = DocumentBuilderFactory.newInstance().newDocumentBuilder().getDOMImplementation();
    } catch (ParserConfigurationException pce) {
        Assert.fail(pce.toString());
    } catch (FactoryConfigurationError fce) {
        Assert.fail(fce.toString());
    }

    Document doc = domImpl.createDocument("namespaceURI", "ns:root", null);

    Comment comment1 = doc.createComment("comment1");
    Comment comment2 = doc.createComment("comment2");

    DOMConfiguration config = doc.getDomConfig();
    config.setParameter("comments", Boolean.TRUE);

    Element root = doc.getDocumentElement();
    root.appendChild(comment1);
    root.appendChild(comment2);

    setHandler(doc);
    doc.normalizeDocument();

    if (comment1.getParentNode() != root) {
        Assert.fail("comment1 is attached to " + comment1.getParentNode() + ", but expected to be a child of root");
    }

    if (comment2.getParentNode() != root) {
        Assert.fail("comment1 is attached to " + comment2.getParentNode() + ", but expected to be a child of root");
    }

    return; // Status.passed("OK");

}
 
源代码9 项目: openjdk-jdk9   文件: DOMConfigurationTest.java
/**
 * Equivalence class partitioning with state and input values orientation
 * for public void setParameter(String name, Object value) throws
 * DOMException, <br>
 * <b>pre-conditions</b>: the attribute has EntityReference to '&lt;', <br>
 * <b>name</b>: well-formed <br>
 * <b>value</b>: true. <br>
 * <b>Expected results</b>: An error is reported
 */
@Test
public void testWellFormed001() {
    Document doc = null;
    try {
        doc = loadDocument(null, test2_xml);
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }

    DOMConfiguration config = doc.getDomConfig();
    if (!config.canSetParameter("well-formed", Boolean.TRUE)) {
        Assert.fail("setting 'well-formed' to true is not supported");
    }
    config.setParameter("well-formed", Boolean.TRUE);

    Element root = doc.getDocumentElement();

    Attr attr = doc.createAttributeNS(null, "attr");

    try {
        attr.appendChild(doc.createEntityReference("<"));
    } catch (DOMException domException) {
        System.out.println("testWellFormed001: Expected DOMException for Attribute value = '<'" + domException.toString());
        return; // OK
    }

    root.setAttributeNode(attr);

    TestHandler testHandler = new TestHandler();
    config.setParameter("error-handler", testHandler);

    doc.normalizeDocument();

    if (testHandler.getError() == null && null == testHandler.getFatalError()) {
        Assert.fail("no error was reported when attribute has <");
    }

    return; // Status.passed("OK");
}
 
源代码10 项目: openjdk-jdk9   文件: DOMConfigurationTest.java
/**
 * Equivalence class partitioning with state and input values orientation
 * for public void setParameter(String name, Object value) throws
 * DOMException, <br>
 * <b>pre-conditions</b>: the document root element has a text node with
 * four white space characters, <br>
 * <b>name</b>: element-content-whitespace <br>
 * <b>value</b>: false. <br>
 * <b>Expected results</b>: the text node is discarded
 */
@Test
public void testECWhitespace002() {
    Document doc = null;
    try {
        doc = loadDocument(null, test3_xml);
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }

    Element root = doc.getDocumentElement();
    Text text = doc.createTextNode("\t\n\r ");
    root.appendChild(text);

    DOMConfiguration config = doc.getDomConfig();
    if (!config.canSetParameter("element-content-whitespace", Boolean.FALSE)) {
        System.out.println("OK, setting 'element-content-whitespace' to false is not supported");
        return;
    }
    config.setParameter("element-content-whitespace", Boolean.FALSE);

    if (!config.canSetParameter("validate", Boolean.TRUE)) {
        System.out.println("OK, setting 'validate' to true is not supported");
        return;
    }
    config.setParameter("validate", Boolean.TRUE);

    setHandler(doc);
    doc.normalizeDocument();

    Node firstChild = root.getFirstChild();
    if (firstChild != null) {
        Assert.fail("the first child is " + firstChild + ", but no child is expected");
    }

    return; // Status.passed("OK");

}
 
源代码11 项目: openjdk-jdk9   文件: DOMConfigurationTest.java
/**
 * Equivalence class partitioning with state and input values orientation
 * for public void setParameter(String name, Object value) throws
 * DOMException, <br>
 * <b>pre-conditions</b>: The root contains a CDATASection with the
 * termination marker ']]&gt;', <br>
 * <b>name</b>: split-cdata-sections <br>
 * <b>value</b>: true. <br>
 * <b>Expected results</b>: A warning is reported when the section is
 * splitted
 */
@Test
public void testSplitCDATA001() {
    DOMImplementation domImpl = null;
    try {
        domImpl = DocumentBuilderFactory.newInstance().newDocumentBuilder().getDOMImplementation();
    } catch (ParserConfigurationException pce) {
        Assert.fail(pce.toString());
    } catch (FactoryConfigurationError fce) {
        Assert.fail(fce.toString());
    }

    Document doc = domImpl.createDocument("namespaceURI", "ns:root", null);

    DOMConfiguration config = doc.getDomConfig();
    CDATASection cdata = doc.createCDATASection("text]" + "]>text");
    doc.getDocumentElement().appendChild(cdata);

    TestHandler testHandler = new TestHandler();
    config.setParameter("error-handler", testHandler);

    if (!config.canSetParameter("split-cdata-sections", Boolean.TRUE)) {
        Assert.fail("cannot set the parameters 'split-cdata-sections' to true");
    }
    config.setParameter("split-cdata-sections", Boolean.TRUE);

    doc.normalizeDocument();
    if (null == testHandler.getWarning()) {
        Assert.fail("no warning is reported");
    }

    return; // Status.passed("OK");

}
 
源代码12 项目: jdk1.8-source-analysis   文件: DOMParserImpl.java
public DOMConfiguration getDomConfig (){
    return this;
}
 
源代码13 项目: jdk1.8-source-analysis   文件: XMLSchemaLoader.java
public DOMConfiguration getConfig() {
    return this;
}
 
源代码14 项目: openjdk-jdk9   文件: DOMConfigurationTest.java
/**
 * Equivalence class partitioning with state and input values orientation
 * for public void setParameter(String name, Object value) throws
 * DOMException, <br>
 * <b>pre-conditions</b>: the doc contains two subsequent processing
 * instrictions, <br>
 * <b>name</b>: canonical-form <br>
 * <b>value</b>: true. <br>
 * <b>Expected results</b>: the subsequent processing instrictions are
 * separated with a single line break
 */
@Test
public void testCanonicalForm001() {
    DOMImplementation domImpl = null;
    try {
        domImpl = DocumentBuilderFactory.newInstance().newDocumentBuilder().getDOMImplementation();
    } catch (ParserConfigurationException pce) {
        Assert.fail(pce.toString());
    } catch (FactoryConfigurationError fce) {
        Assert.fail(fce.toString());
    }

    Document doc = domImpl.createDocument("namespaceURI", "ns:root", null);

    DOMConfiguration config = doc.getDomConfig();

    Element root = doc.getDocumentElement();
    ProcessingInstruction pi1 = doc.createProcessingInstruction("target1", "data1");
    ProcessingInstruction pi2 = doc.createProcessingInstruction("target2", "data2");

    root.appendChild(pi1);
    root.appendChild(pi2);

    if (!config.canSetParameter("canonical-form", Boolean.TRUE)) {
        System.out.println("OK, setting 'canonical-form' to true is not supported");
        return;
    }

    config.setParameter("canonical-form", Boolean.TRUE);
    setHandler(doc);
    doc.normalizeDocument();

    Node child1 = root.getFirstChild();
    Node child2 = child1.getNextSibling();

    if (child2.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) {
        Assert.fail("the second child is expected to be a" + "single line break, returned: " + child2);
    }

    // return Status.passed("OK");
}
 
源代码15 项目: jdk1.8-source-analysis   文件: DOMSerializerImpl.java
public DOMConfiguration getDomConfig(){
    return this;
}
 
源代码16 项目: TencentKona-8   文件: XMLSchemaLoader.java
public DOMConfiguration getConfig() {
    return this;
}
 
源代码17 项目: openjdk-8-source   文件: DOMParserImpl.java
public DOMConfiguration getDomConfig (){
    return this;
}
 
源代码18 项目: openjdk-jdk9   文件: DOMConfigurationTest.java
/**
 * Equivalence class partitioning with state and input values orientation
 * for public void setParameter(String name, Object value) throws
 * DOMException, <br>
 * <b>pre-conditions</b>: the root element contains a fully-normalized text, <br>
 * <b>name</b>: check-character-normalization <br>
 * <b>value</b>: false. <br>
 * <b>Expected results</b>: LSParser reports no errors
 */
@Test
public void testCheckCharNorm002() {
    DOMImplementation domImpl = null;
    try {
        domImpl = DocumentBuilderFactory.newInstance().newDocumentBuilder().getDOMImplementation();
    } catch (ParserConfigurationException pce) {
        Assert.fail(pce.toString());
    } catch (FactoryConfigurationError fce) {
        Assert.fail(fce.toString());
    }

    DOMImplementationLS lsImpl = (DOMImplementationLS) domImpl.getFeature("LS", "3.0");

    if (lsImpl == null) {
        System.out.println("OK, the DOM implementation does not support the LS 3.0");
        return;
    }

    LSParser lsParser = lsImpl.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null);

    DOMConfiguration config = lsParser.getDomConfig();

    if (!config.canSetParameter("check-character-normalization", Boolean.FALSE)) {
        Assert.fail("setting 'check-character-normalization' to false is not supported");
    }

    config.setParameter("check-character-normalization", Boolean.FALSE);

    TestHandler testHandler = new TestHandler();
    config.setParameter("error-handler", testHandler);

    LSInput lsInput = lsImpl.createLSInput();
    lsInput.setStringData("<root>fully-normalized</root>");
    Document doc = lsParser.parse(lsInput);

    if (null != testHandler.getError()) {
        Assert.fail("no error is expected, but reported: " + testHandler.getError());

    }

    return; // Status.passed("OK");

}
 
源代码19 项目: openjdk-jdk9   文件: DOMConfigurationTest.java
/**
 * Equivalence class partitioning with state and input values orientation
 * for public void setParameter(String name, Object value) throws
 * DOMException, <br>
 * <b>pre-conditions</b>: The root element is not declared in the schema
 * specified by setting the 'schema-location' and the 'schema-type'
 * parameters., <br>
 * <b>name</b>: validate-if-schema <br>
 * <b>value</b>: true. <br>
 * <b>Expected results</b>: No error is reported
 */
@Test
public void testValidateIfSchema002() {
    DOMImplementation domImpl = null;
    try {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setNamespaceAware(true);
        dbf.setValidating(true);
        domImpl = dbf.newDocumentBuilder().getDOMImplementation();
    } catch (ParserConfigurationException pce) {
        Assert.fail(pce.toString());
    } catch (FactoryConfigurationError fce) {
        Assert.fail(fce.toString());
    }

    Document doc = domImpl.createDocument("test", "ns:undeclared_root", null);

    Element root = doc.getDocumentElement();
    root.appendChild(doc.createTextNode("xxx"));

    DOMConfiguration config = doc.getDomConfig();

    if (!config.canSetParameter("schema-location", test1_xsd_url) || !config.canSetParameter("schema-type", XMLConstants.W3C_XML_SCHEMA_NS_URI)) {
        System.out.println("cannot set the parameters 'schema-location' and 'schema-type'" + " to 'DOMConfigurationTest.xsd' and '"
                + XMLConstants.W3C_XML_SCHEMA_NS_URI + "' respectively");
        return;
    }
    config.setParameter("schema-type", XMLConstants.W3C_XML_SCHEMA_NS_URI);
    config.setParameter("schema-location", test1_xsd_url);

    if (!config.canSetParameter("validate-if-schema", Boolean.TRUE)) {
        System.out.println("OK, setting the parameter 'validate-if-schema'" + " to true is not supported");
        return;
    }

    config.setParameter("validate-if-schema", Boolean.TRUE);
    TestHandler testHandler = new TestHandler();
    config.setParameter("error-handler", testHandler);
    doc.normalizeDocument();
    if (testHandler.getError() != null || null != testHandler.getFatalError()) {
        Assert.fail("unexpected error: " + testHandler.getFatalError() + "; " + testHandler.getError());
    }
    return; // Status.passed("OK");

}
 
源代码20 项目: cxf   文件: XercesSchemaValidationUtils.java
void tryToParseSchemas(XmlSchemaCollection collection, DOMErrorHandler handler)
    throws Exception {

    final List<DOMLSInput> inputs = new ArrayList<>();
    final Map<String, LSInput> resolverMap = new HashMap<>();

    for (XmlSchema schema : collection.getXmlSchemas()) {
        if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(schema.getTargetNamespace())) {
            continue;
        }
        Document document = new XmlSchemaSerializer().serializeSchema(schema, false)[0];
        DOMLSInput input = new DOMLSInput(document, schema.getTargetNamespace());
        resolverMap.put(schema.getTargetNamespace(), input);
        inputs.add(input);
    }

    try {

        Object schemaLoader = findMethod(impl, "createXSLoader").invoke(impl, new Object[1]);
        DOMConfiguration config = (DOMConfiguration)findMethod(schemaLoader, "getConfig").invoke(schemaLoader);

        config.setParameter("validate", Boolean.TRUE);
        config.setParameter("error-handler", handler);
        config.setParameter("resource-resolver", new LSResourceResolver() {
            public LSInput resolveResource(String type, String namespaceURI, String publicId,
                                           String systemId, String baseURI) {
                return resolverMap.get(namespaceURI);
            }
        });


        Method m = findMethod(schemaLoader, "loadInputList");
        String name = m.getParameterTypes()[0].getName() + "Impl";
        name = name.replace("xs.LS", "impl.xs.util.LS");
        Class<?> c = Class.forName(name);
        Object inputList = c.getConstructor(LSInput[].class, Integer.TYPE)
            .newInstance(inputs.toArray(new LSInput[0]), inputs.size());
        m.invoke(schemaLoader, inputList);
    } catch (InvocationTargetException e) {
        throw (Exception)e.getTargetException();
    }
}
 
源代码21 项目: openjdk-jdk9   文件: DOMParserImpl.java
public DOMConfiguration getDomConfig (){
    return this;
}
 
源代码22 项目: jdk8u60   文件: DOMSerializerImpl.java
public DOMConfiguration getDomConfig(){
    return this;
}
 
源代码23 项目: JDKSourceCode1.8   文件: XMLSchemaLoader.java
public DOMConfiguration getConfig() {
    return this;
}
 
源代码24 项目: openjdk-jdk9   文件: SOAPDocumentImpl.java
@Override
public DOMConfiguration getDomConfig() {
    return document.getDomConfig();
}
 
源代码25 项目: htmlunit   文件: XmlPage.java
/**
 * {@inheritDoc}
 * Not yet implemented.
 */
@Override
public DOMConfiguration getDomConfig() {
    throw new UnsupportedOperationException("XmlPage.getDomConfig is not yet implemented.");
}
 
源代码26 项目: htmlunit   文件: HtmlPage.java
/**
 * {@inheritDoc}
 * Not yet implemented.
 */
@Override
public DOMConfiguration getDomConfig() {
    throw new UnsupportedOperationException("HtmlPage.getDomConfig is not yet implemented.");
}
 
源代码27 项目: openjdk-jdk9   文件: DOMConfigurationTest.java
/**
 * Equivalence class partitioning with state and input values orientation
 * for public void setParameter(String name, Object value) throws
 * DOMException, <br>
 * <b>pre-conditions</b>: setting the "canonical-form" to true is supported, <br>
 * <b>name</b>: canonical-form <br>
 * <b>value</b>: true. <br>
 * <b>Expected results</b>: one of the following parameters is changed:
 * "namespaces", "namespace-declarations", "well-formed",
 * "element-content-whitespace", "entities", "normalize-characters",
 * "cdata-sections" then "canonical-form" becomes false
 */
@Test
public void testCanonicalForm004() {
    Object[][] params = { { "namespaces", Boolean.TRUE }, { "namespace-declarations", Boolean.TRUE }, { "well-formed", Boolean.TRUE },
            { "element-content-whitespace", Boolean.TRUE },

            { "entities", Boolean.FALSE }, { "normalize-characters", Boolean.FALSE }, { "cdata-sections", Boolean.FALSE }, };

    DOMImplementation domImpl = null;
    try {
        domImpl = DocumentBuilderFactory.newInstance().newDocumentBuilder().getDOMImplementation();
    } catch (ParserConfigurationException pce) {
        Assert.fail(pce.toString());
    } catch (FactoryConfigurationError fce) {
        Assert.fail(fce.toString());
    }

    Document doc = domImpl.createDocument("namespaceURI", "ns:root", null);

    DOMConfiguration config = doc.getDomConfig();

    if (!config.canSetParameter("canonical-form", Boolean.TRUE)) {
        System.out.println("OK, setting 'canonical-form' to true is not supported");
        return;
    }

    StringBuffer result = new StringBuffer();

    for (int i = params.length; --i >= 0;) {
        config.setParameter("canonical-form", Boolean.TRUE);
        Boolean changedValue = (params[i][1].equals(Boolean.TRUE)) ? Boolean.FALSE : Boolean.TRUE;
        if (config.canSetParameter(params[i][0].toString(), changedValue)) {
            config.setParameter(params[i][0].toString(), changedValue);
            Object param = config.getParameter("canonical-form");
            if (!Boolean.FALSE.equals(param)) {
                result.append("; setting the parameter '" + params[i][0] + "' to " + changedValue + " does not change 'canonical-form' to false");
            }
        }
    }

    if (result.length() > 0) {
        Assert.fail(result.toString().substring(2));
    }

    return; // Status.passed("OK");
}
 
源代码28 项目: HtmlUnit-Android   文件: HtmlPage.java
/**
 * {@inheritDoc}
 * Not yet implemented.
 */
@Override
public DOMConfiguration getDomConfig() {
    throw new UnsupportedOperationException("HtmlPage.getDomConfig is not yet implemented.");
}
 
源代码29 项目: openjdk-jdk8u   文件: XMLSchemaLoader.java
public DOMConfiguration getConfig() {
    return this;
}
 
源代码30 项目: j2objc   文件: DocumentImpl.java
public DOMConfiguration getDomConfig() {
    if (domConfiguration == null) {
        domConfiguration = new DOMConfigurationImpl();
    }
    return domConfiguration;
}
 
 类所在包
 同包方法