类org.w3c.dom.ls.LSParser源码实例Demo

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

源代码1 项目: openjdk-jdk9   文件: Bug6355326.java
@Test
public void testExternalEncoding() {

    try {
        LSInput src = null;
        LSParser dp = null;

        src = createLSInputEncoding();
        dp = createLSParser();

        src.setEncoding("UTF-16");
        Document doc = dp.parse(src);
        Assert.assertTrue("encodingXML".equals(doc.getDocumentElement().getNodeName()), "XML document is not parsed correctly");

    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail("Exception occured: " + e.getMessage());
    }
}
 
源代码2 项目: openjdk-jdk9   文件: DocumentLSTest.java
@Test
public void testLSInputParsingByteStream() throws Exception {
    DOMImplementationLS impl = (DOMImplementationLS) getDocumentBuilder().getDOMImplementation();
    LSParser domParser = impl.createLSParser(MODE_SYNCHRONOUS, null);
    LSInput src = impl.createLSInput();

    try (InputStream is = new FileInputStream(ASTROCAT)) {
        src.setByteStream(is);
        assertNotNull(src.getByteStream());
        // set certified accessor methods
        boolean origCertified = src.getCertifiedText();
        src.setCertifiedText(true);
        assertTrue(src.getCertifiedText());
        src.setCertifiedText(origCertified); // set back to orig

        src.setSystemId(filenameToURL(ASTROCAT));

        Document doc = domParser.parse(src);
        Element result = doc.getDocumentElement();
        assertEquals(result.getTagName(), "stardb");
    }
}
 
源代码3 项目: openjdk-jdk9   文件: DocumentLSTest.java
@Test
public void testLSInputParsingString() throws Exception {
    DOMImplementationLS impl = (DOMImplementationLS) getDocumentBuilder().getDOMImplementation();
    String xml = "<?xml version='1.0'?><test>runDocumentLS_Q6</test>";

    LSParser domParser = impl.createLSParser(MODE_SYNCHRONOUS, null);
    LSSerializer domSerializer = impl.createLSSerializer();
    // turn off xml decl in serialized string for comparison
    domSerializer.getDomConfig().setParameter("xml-declaration", Boolean.FALSE);
    LSInput src = impl.createLSInput();
    src.setStringData(xml);
    assertEquals(src.getStringData(), xml);

    Document doc = domParser.parse(src);
    String result = domSerializer.writeToString(doc);

    assertEquals(result, "<test>runDocumentLS_Q6</test>");
}
 
源代码4 项目: citrus-admin   文件: SpringBeanService.java
/**
 * Finds bean definition element by id and type in Spring application context and
 * performs unmarshalling in order to return JaxB object.
 * @param project
 * @param id
 * @param type
 * @return
 */
public <T> T getBeanDefinition(File configFile, Project project, String id, Class<T> type) {
    LSParser parser = XMLUtils.createLSParser();

    GetSpringBeanFilter filter = new GetSpringBeanFilter(id, type);
    parser.setFilter(filter);

    List<File> configFiles = new ArrayList<>();
    configFiles.add(configFile);
    configFiles.addAll(getConfigImports(configFile, project));

    for (File file : configFiles) {
        parser.parseURI(file.toURI().toString());

        if (filter.getBeanDefinition() != null) {
            return createJaxbObjectFromElement(filter.getBeanDefinition());
        }
    }

    return null;
}
 
源代码5 项目: citrus-admin   文件: SpringBeanService.java
/**
 * Finds all bean definition elements by type and attribute values in Spring application context and
 * performs unmarshalling in order to return a list of JaxB object.
 * @param project
 * @param type
 * @param attributes
 * @return
 */
public <T> List<T> getBeanDefinitions(File configFile, Project project, Class<T> type, Map<String, String> attributes) {
    List<T> beanDefinitions = new ArrayList<T>();

    List<File> importedFiles = getConfigImports(configFile, project);
    for (File importLocation : importedFiles) {
        beanDefinitions.addAll(getBeanDefinitions(importLocation, project, type, attributes));
    }

    LSParser parser = XMLUtils.createLSParser();

    GetSpringBeansFilter filter = new GetSpringBeansFilter(type, attributes);
    parser.setFilter(filter);
    parser.parseURI(configFile.toURI().toString());

    for (Element element : filter.getBeanDefinitions()) {
        beanDefinitions.add(createJaxbObjectFromElement(element));
    }

    return beanDefinitions;
}
 
private static String normalizeXML(String xml) throws Exception {
    // Remove all white space adjoining tags ("trim all elements")
    xml = xml.replaceAll("\\s*<", "<");
    xml = xml.replaceAll(">\\s*", ">");

    DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
    DOMImplementationLS domLS = (DOMImplementationLS) registry.getDOMImplementation("LS");
    LSParser lsParser = domLS.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null);

    LSInput input = domLS.createLSInput();
    input.setStringData(xml);
    Document document = lsParser.parse(input);

    LSSerializer lsSerializer = domLS.createLSSerializer();
    lsSerializer.getDomConfig().setParameter("comments", Boolean.FALSE);
    lsSerializer.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE);
    return lsSerializer.writeToString(document);
}
 
源代码7 项目: wildfly-core   文件: ModelTestUtils.java
/**
 * Normalize and pretty-print XML so that it can be compared using string
 * compare. The following code does the following: - Removes comments -
 * Makes sure attributes are ordered consistently - Trims every element -
 * Pretty print the document
 *
 * @param xml The XML to be normalized
 * @return The equivalent XML, but now normalized
 */
public static String normalizeXML(String xml) throws Exception {
    // Remove all white space adjoining tags ("trim all elements")
    xml = xml.replaceAll("\\s*<", "<");
    xml = xml.replaceAll(">\\s*", ">");

    DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
    DOMImplementationLS domLS = (DOMImplementationLS) registry.getDOMImplementation("LS");
    LSParser lsParser = domLS.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null);

    LSInput input = domLS.createLSInput();
    input.setStringData(xml);
    Document document = lsParser.parse(input);

    LSSerializer lsSerializer = domLS.createLSSerializer();
    lsSerializer.getDomConfig().setParameter("comments", Boolean.FALSE);
    lsSerializer.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE);
    return lsSerializer.writeToString(document);
}
 
源代码8 项目: wildfly-core   文件: XMLUtils.java
/**
 * Normalize and pretty-print XML so that it can be compared using string
 * compare. The following code does the following: - Removes comments -
 * Makes sure attributes are ordered consistently - Trims every element -
 * Pretty print the document
 *
 * @param xml The XML to be normalized
 * @return The equivalent XML, but now normalized
 */
public static String normalizeXML(String xml) throws Exception {
    // Remove all white space adjoining tags ("trim all elements")
    xml = xml.replaceAll("\\s*<", "<");
    xml = xml.replaceAll(">\\s*", ">");

    DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
    DOMImplementationLS domLS = (DOMImplementationLS) registry.getDOMImplementation("LS");
    LSParser lsParser = domLS.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null);

    LSInput input = domLS.createLSInput();
    input.setStringData(xml);
    Document document = lsParser.parse(input);

    LSSerializer lsSerializer = domLS.createLSSerializer();
    lsSerializer.getDomConfig().setParameter("comments", Boolean.FALSE);
    lsSerializer.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE);
    return lsSerializer.writeToString(document);
}
 
源代码9 项目: openjdk-jdk9   文件: LSParserTCKTest.java
/**
 * Equivalence class partitioning
 * with state, input and output values orientation
 * for public Document parse(LSInput is),
 * <br><b>pre-conditions</b>: set filter that REJECTs any CHILD* node,
 * <br><b>is</b>: xml1
 * <br><b>output</b>: XML document with ELEMNENT1 and ELEMENT2 only.
 */
@Test
public void testfilter0001() {
    LSParser parser = createLSParser();
    if (parser == null) {
        Assert.fail("Unable to create LSParser!");
    }
    // set filter
    parser.setFilter(new LSParserFilter() {
        public short startElement(Element elt) {
            return FILTER_ACCEPT;
        }

        public short acceptNode(Node enode) {
            if (enode.getNodeName().startsWith("CHILD")) {
                return FILTER_REJECT;
            }
            return FILTER_ACCEPT;
        }

        public int getWhatToShow() {
            return NodeFilter.SHOW_ALL;
        }
    });
    String expected = "<?xml version=\"1.0\"?><ROOT><ELEMENT1></ELEMENT1><ELEMENT2>test1</ELEMENT2></ROOT>";
    Document doc = parser.parse(getXmlSource(xml1));
    if (!match(expected, doc)) {
        Assert.fail("DOM structure after parsing is not equal to a structure of XML document, that being parsed");
    }

    System.out.println("OKAY");
}
 
源代码10 项目: openjdk-jdk9   文件: LSParserTCKTest.java
public boolean match(String template, Node source) {
    LSParser dp = createLSParser();
    if (dp == null) {
        System.out.println("Can not create LSParser.");
        return false;
    }
    LSInput src = getXmlSource(template);
    Document doc = dp.parse(src);
    return checkXMLs(doc, source);
}
 
源代码11 项目: openjdk-jdk9   文件: LSParserTCKTest.java
/**
 * Equivalence class partitioning with state, input and output values
 * orientation for public Document parse(LSInput is), <br>
 * <b>pre-conditions</b>: set filter that SKIPs ELEMENT1 node, <br>
 * <b>is</b>: xml1 <br>
 * <b>output</b>: XML document with CHILD1 and ELEMENT2 only.
 */
@Test
public void testFilter0002() {
    LSParser parser = createLSParser();
    if (parser == null) {
        Assert.fail("Unable to create LSParser!");
    }
    // set filter
    parser.setFilter(new LSParserFilter() {
        public short startElement(Element elt) {
            return FILTER_ACCEPT;
        }

        public short acceptNode(Node enode) {
            if (enode.getNodeName().startsWith("ELEMENT1")) {
                return FILTER_SKIP;
            }
            return FILTER_ACCEPT;
        }

        public int getWhatToShow() {
            return NodeFilter.SHOW_ALL;
        }
    });
    String expected = "<?xml version=\"1.0\"?><ROOT><CHILD1/><CHILD1><COC1/></CHILD1><ELEMENT2>test1<CHILD2/></ELEMENT2></ROOT>";
    Document doc = parser.parse(getXmlSource(xml1));
    if (!match(expected, doc)) {
        Assert.fail("DOM structure after parsing is not equal to a structure of XML document, that being parsed");
    }
    System.out.println("OKAY");
}
 
源代码12 项目: openjdk-jdk9   文件: LSParserTCKTest.java
/**
 * Equivalence class partitioning with state, input and output values
 * orientation for public Document parse(LSInput is), <br>
 * <b>pre-conditions</b>: set filter that SKIPs ELEMENT1 node, <br>
 * <b>is</b>: xml1 <br>
 * <b>output</b>: XML document with ELEMENT1 only.
 */
@Test
public void testFilter0003() {
    LSParser parser = createLSParser();
    if (parser == null) {
        Assert.fail("Unable to create LSParser!");
    }
    // set filter
    parser.setFilter(new LSParserFilter() {
        public short startElement(Element elt) {
            return FILTER_ACCEPT;
        }

        public short acceptNode(Node enode) {
            if (enode.getNodeName().startsWith("ELEMENT2")) {
                return FILTER_INTERRUPT;
            }
            return FILTER_ACCEPT;
        }

        public int getWhatToShow() {
            return NodeFilter.SHOW_ALL;
        }
    });
    String expected = "<ROOT><ELEMENT1><CHILD1/><CHILD1><COC1/></CHILD1></ELEMENT1></ROOT>";
    Document doc = parser.parse(getXmlSource(xml1));
    if (!match(expected, doc)) {
        Assert.fail("DOM structure after parsing is not equal to a structure of XML document, that being parsed");
    }
    System.out.println("OKAY");
}
 
源代码13 项目: openjdk-jdk9   文件: LSParserTCKTest.java
/**
 * Equivalence class partitioning with state, input and output values
 * orientation for public Document parse(LSInput is), <br>
 * <b>pre-conditions</b>: set filter that accepts all, <br>
 * <b>is</b>: xml1 <br>
 * <b>output</b>: full XML document.
 */
@Test
public void testFilter0004() {
    LSParser parser = createLSParser();
    if (parser == null) {
        Assert.fail("Unable to create LSParser!");
    }
    // set filter
    parser.setFilter(new LSParserFilter() {
        public short startElement(Element elt) {
            return FILTER_ACCEPT;
        }

        public short acceptNode(Node enode) {
            return FILTER_ACCEPT;
        }

        public int getWhatToShow() {
            return NodeFilter.SHOW_ALL;
        }
    });
    String expected = "<ROOT><ELEMENT1><CHILD1/><CHILD1><COC1/></CHILD1></ELEMENT1><ELEMENT2>test1<CHILD2/></ELEMENT2></ROOT>";
    Document doc = parser.parse(getXmlSource(xml1));
    if (!match(expected, doc)) {
        Assert.fail("DOM structure after parsing is not equal to a structure of XML document, that being parsed");
    }
    System.out.println("OKAY");
}
 
源代码14 项目: openjdk-jdk9   文件: LSParserTCKTest.java
/**
 * Equivalence class partitioning with state, input and output values
 * orientation for public Document parse(LSInput is), <br>
 * <b>pre-conditions</b>: set filter that REJECTs all, <br>
 * <b>is</b>: xml1 <br>
 * <b>output</b>: empty XML document.
 */
@Test
public void testFilter0005() {
    LSParser parser = createLSParser();
    if (parser == null) {
        Assert.fail("Unable to create LSParser!");
    }
    // set filter
    parser.setFilter(new LSParserFilter() {
        public short startElement(Element elt) {
            return FILTER_ACCEPT;
        }

        public short acceptNode(Node enode) {
            return FILTER_REJECT;
        }

        public int getWhatToShow() {
            return NodeFilter.SHOW_ALL;
        }
    });
    Document doc = parser.parse(getXmlSource(xml1));
    NodeList children = doc.getDocumentElement().getChildNodes();
    if (children.getLength() != 0) {
        Assert.fail("Not all children skipped");
    }
    System.out.println("OKAY");
}
 
源代码15 项目: openjdk-jdk9   文件: LSParserTCKTest.java
/**
 * Equivalence class partitioning with state, input and output values
 * orientation for public Document parse(LSInput is), <br>
 * <b>pre-conditions</b>: set filter that SKIPs all, <br>
 * <b>is</b>: xml1 <br>
 * <b>output</b>: empty XML document.
 */
@Test
public void testFilter0006() {
    LSParser parser = createLSParser();
    if (parser == null) {
        Assert.fail("Unable to create LSParser!");
    }
    // set filter
    parser.setFilter(new LSParserFilter() {
        public short startElement(Element elt) {
            return FILTER_ACCEPT;
        }

        public short acceptNode(Node enode) {
            return FILTER_SKIP;
        }

        public int getWhatToShow() {
            return NodeFilter.SHOW_ALL;
        }
    });
    Document doc = parser.parse(getXmlSource(xml1));
    NodeList children = doc.getDocumentElement().getChildNodes();
    if (children.getLength() != 0) {
        Assert.fail("Not all children skipped");
    }
    System.out.println("OKAY");
}
 
源代码16 项目: openjdk-jdk9   文件: LSParserTCKTest.java
/**
 * Equivalence class partitioning with state, input and output values
 * orientation for public Document parse(LSInput is), <br>
 * <b>pre-conditions</b>: set filter that REJECTs any CHILD* start element, <br>
 * <b>is</b>: xml1 <br>
 * <b>output</b>: XML document with ELEMENT1 and ELEMENT2 only.
 */
@Test
public void testFilter0007() {
    LSParser parser = createLSParser();
    if (parser == null) {
        Assert.fail("Unable to create LSParser!");
    }
    // set filter
    parser.setFilter(new LSParserFilter() {
        public short startElement(Element elt) {
            if (elt.getTagName().startsWith("CHILD")) {
                return FILTER_REJECT;
            }
            return FILTER_ACCEPT;
        }

        public short acceptNode(Node enode) {
            return FILTER_ACCEPT;
        }

        public int getWhatToShow() {
            return NodeFilter.SHOW_ALL;
        }
    });
    String expected = "<?xml version=\"1.0\"?><ROOT><ELEMENT1></ELEMENT1><ELEMENT2>test1</ELEMENT2></ROOT>";
    Document doc = parser.parse(getXmlSource(xml1));
    if (!match(expected, doc)) {
        Assert.fail("DOM structure after parsing is not equal to a structure of XML document, that being parsed");
    }
    System.out.println("OKAY");
}
 
源代码17 项目: openjdk-jdk9   文件: LSParserTCKTest.java
/**
 * Equivalence class partitioning with state, input and output values
 * orientation for public Document parse(LSInput is), <br>
 * <b>pre-conditions</b>: set filter that SKIPs ELEMENT1 start element, <br>
 * <b>is</b>: xml1 <br>
 * <b>output</b>: XML document with CHILD1 and ELEMENT2 only.
 */
@Test
public void testFilter0008() {
    LSParser parser = createLSParser();
    if (parser == null) {
        Assert.fail("Unable to create LSParser!");
    }
    // set filter
    parser.setFilter(new LSParserFilter() {
        public short startElement(Element elt) {
            if (elt.getTagName().equals("ELEMENT1")) {
                return FILTER_SKIP;
            }
            return FILTER_ACCEPT;
        }

        public short acceptNode(Node enode) {
            return FILTER_ACCEPT;
        }

        public int getWhatToShow() {
            return NodeFilter.SHOW_ALL;
        }
    });
    String expected = "<?xml version=\"1.0\"?><ROOT><CHILD1/><CHILD1><COC1/></CHILD1><ELEMENT2>test1<CHILD2/></ELEMENT2></ROOT>";
    Document doc = parser.parse(getXmlSource(xml1));
    if (!match(expected, doc)) {
        Assert.fail("DOM structure after parsing is not equal to a structure of XML document, that being parsed");
    }
    System.out.println("OKAY");
}
 
源代码18 项目: openjdk-jdk9   文件: LSParserTCKTest.java
/**
 * Equivalence class partitioning with state, input and output values
 * orientation for public Document parse(LSInput is), <br>
 * <b>pre-conditions</b>: set filter that SKIPs ELEMENT1 start element, <br>
 * <b>is</b>: xml1 <br>
 * <b>output</b>: XML document with ELEMENT1 only.
 */
@Test
public void testFilter0009() {
    LSParser parser = createLSParser();
    if (parser == null) {
        Assert.fail("Unable to create LSParser!");
    }
    // set filter
    parser.setFilter(new LSParserFilter() {
        public short startElement(Element elt) {
            if (elt.getTagName().startsWith("ELEMENT2")) {
                return FILTER_INTERRUPT;
            }
            return FILTER_ACCEPT;
        }

        public short acceptNode(Node enode) {
            return FILTER_ACCEPT;
        }

        public int getWhatToShow() {
            return NodeFilter.SHOW_ALL;
        }
    });
    String expected = "<ROOT><ELEMENT1><CHILD1/><CHILD1><COC1/></CHILD1></ELEMENT1></ROOT>";
    Document doc = parser.parse(getXmlSource(xml1));
    if (!match(expected, doc)) {
        Assert.fail("DOM structure after parsing is not equal to a structure of XML document, that being parsed");
    }
    System.out.println("OKAY");
}
 
源代码19 项目: openjdk-jdk9   文件: LSParserTCKTest.java
/**
 * Equivalence class partitioning with state, input and output values
 * orientation for public Document parse(LSInput is), <br>
 * <b>pre-conditions</b>: set filter that REJECTs all start element, <br>
 * <b>is</b>: xml1 <br>
 * <b>output</b>: empty XML document.
 */
@Test
public void testFilter0010() {
    LSParser parser = createLSParser();
    if (parser == null) {
        Assert.fail("Unable to create LSParser");
    }
    // set filter
    parser.setFilter(new LSParserFilter() {
        public short startElement(Element elt) {
            return FILTER_REJECT;
        }

        public short acceptNode(Node enode) {
            return FILTER_ACCEPT;
        }

        public int getWhatToShow() {
            return NodeFilter.SHOW_ALL;
        }
    });
    Document doc = parser.parse(getXmlSource(xml1));
    NodeList children = doc.getDocumentElement().getChildNodes();
    if (children.getLength() != 0) {
        Assert.fail("Not all children skipped");
    }
    System.out.println("OKAY");
}
 
源代码20 项目: openjdk-jdk9   文件: LSParserTCKTest.java
/**
 * Equivalence class partitioning with state, input and output values
 * orientation for public Document parse(LSInput is), <br>
 * <b>pre-conditions</b>: set filter that SKIPs all, <br>
 * <b>is</b>: xml1 <br>
 * <b>output</b>: empty XML document.
 */
@Test
public void testFilter0011() {
    LSParser parser = createLSParser();
    if (parser == null) {
        Assert.fail("Unable to create LSParser");
    }
    // set filter
    parser.setFilter(new LSParserFilter() {
        public short startElement(Element elt) {
            return FILTER_SKIP;
        }

        public short acceptNode(Node enode) {
            return FILTER_ACCEPT;
        }

        public int getWhatToShow() {
            return NodeFilter.SHOW_ALL;
        }
    });
    Document doc = parser.parse(getXmlSource(xml1));
    NodeList children = doc.getDocumentElement().getChildNodes();
    if (children.getLength() != 1) {
        Assert.fail("Not all Element nodes skipped");
    }
    System.out.println("OKAY");
}
 
源代码21 项目: openjdk-jdk9   文件: UserController.java
/**
 * Checking when creating an XML document using DOM Level 2 validating
 * it without having a schema source or a schema location It must throw a
 * sax parse exception.
 *
 * @throws Exception If any errors occur.
 */
@Test
public void testCreateNewUser() throws Exception {
    String resultFile = USER_DIR + "accountInfoOut.xml";
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    dbf.setValidating(true);

    DocumentBuilder docBuilder = dbf.newDocumentBuilder();
    MyErrorHandler eh = new MyErrorHandler();
    docBuilder.setErrorHandler(eh);

    Document document = docBuilder.newDocument();

    Element account = document.createElementNS(PORTAL_ACCOUNT_NS, "acc:Account");
    Attr accountID = document.createAttributeNS(PORTAL_ACCOUNT_NS, "acc:accountID");
    account.setAttributeNode(accountID);

    account.appendChild(document.createElement("FirstName"));
    account.appendChild(document.createElementNS(PORTAL_ACCOUNT_NS, "acc:LastName"));
    account.appendChild(document.createElement("UserID"));

    DOMImplementationLS impl
            = (DOMImplementationLS) DOMImplementationRegistry
                    .newInstance().getDOMImplementation("LS");
    LSSerializer writer = impl.createLSSerializer();
    LSParser builder = impl.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null);
    try(FileOutputStream output = new FileOutputStream(resultFile)) {
        MyDOMOutput domOutput = new MyDOMOutput();
        domOutput.setByteStream(output);
        writer.write(account, domOutput);
        docBuilder.parse(resultFile);
    }
    assertTrue(eh.isAnyError());
}
 
源代码22 项目: openjdk-jdk9   文件: UserController.java
/**
 * Checking for namespace normalization.
 * @see <a href="content/screenName.xml">screenName.xml</a> has prefix of
 * userName is bound to "http://hibid.com/user" namespace normalization
 * will create a namespace of prefix us and attach userEmail.
 *
 * @throws Exception If any errors occur.
 */
@Test
public void testCheckScreenNameExists() throws Exception {
    String resultFile = USER_DIR + "screenName.out";
    String xmlFile = XML_DIR + "screenName.xml";
    String goldFile = GOLDEN_DIR + "screenNameGold.xml";

    String nsTagName = "http://hibid.com/screenName";
    String userNs = "http://hibid.com/user";

    try (FileOutputStream output = new FileOutputStream(resultFile)) {
        DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
        DOMImplementationLS impl = (DOMImplementationLS) registry.getDOMImplementation("LS");
        LSSerializer writer = impl.createLSSerializer();
        LSParser builder = impl.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null);
        Document document = builder.parseURI(xmlFile);
        NodeList nl = document.getElementsByTagNameNS(nsTagName, "screen-name");
        assertEquals(nl.getLength(), 1);
        Element screenName = (Element)nl.item(0);
        Element userEmail = document.createElementNS(userNs, "userEmail");
        assertTrue(userEmail.isDefaultNamespace(userNs));

        Text email = document.createTextNode("[email protected]");
        userEmail.appendChild(email);
        screenName.appendChild(userEmail);
        document.normalizeDocument();

        MyDOMOutput domoutput = new MyDOMOutput();
        domoutput.setByteStream(output);
        writer.write(document, domoutput);
    }
    assertTrue(compareDocumentWithGold(goldFile, resultFile));
}
 
源代码23 项目: citrus-admin   文件: SpringBeanService.java
/**
 * Reads file import locations from Spring bean application context.
 * @param project
 * @return
 */
public List<File> getConfigImports(File configFile, Project project) {
    LSParser parser = XMLUtils.createLSParser();

    GetSpringImportsFilter filter = new GetSpringImportsFilter(configFile);
    parser.setFilter(filter);
    parser.parseURI(configFile.toURI().toString());

    return filter.getImportedFiles();
}
 
/**
    * DOM Level 3 LS CR - Experimental.
* Create a new <code>LSParser</code>. The newly constructed parser may
* then be configured by means of its <code>DOMConfiguration</code>
* object, and used to parse documents by means of its <code>parse</code>
*  method.
* @param mode  The <code>mode</code> argument is either
*   <code>MODE_SYNCHRONOUS</code> or <code>MODE_ASYNCHRONOUS</code>, if
*   <code>mode</code> is <code>MODE_SYNCHRONOUS</code> then the
*   <code>LSParser</code> that is created will operate in synchronous
*   mode, if it's <code>MODE_ASYNCHRONOUS</code> then the
*   <code>LSParser</code> that is created will operate in asynchronous
*   mode.
* @param schemaType  An absolute URI representing the type of the schema
*   language used during the load of a <code>Document</code> using the
*   newly created <code>LSParser</code>. Note that no lexical checking
*   is done on the absolute URI. In order to create a
*   <code>LSParser</code> for any kind of schema types (i.e. the
*   LSParser will be free to use any schema found), use the value
*   <code>null</code>.
* <p ><b>Note:</b>    For W3C XML Schema [<a href='http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/'>XML Schema Part 1</a>]
*   , applications must use the value
*   <code>"http://www.w3.org/2001/XMLSchema"</code>. For XML DTD [<a href='http://www.w3.org/TR/2000/REC-xml-20001006'>XML 1.0</a>],
*   applications must use the value
*   <code>"http://www.w3.org/TR/REC-xml"</code>. Other Schema languages
*   are outside the scope of the W3C and therefore should recommend an
*   absolute URI in order to use this method.
* @return  The newly created <code>LSParser</code> object. This
*   <code>LSParser</code> is either synchronous or asynchronous
*   depending on the value of the <code>mode</code> argument.
* <p ><b>Note:</b>    By default, the newly created <code>LSParser</code>
*    does not contain a <code>DOMErrorHandler</code>, i.e. the value of
*   the "<a href='http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030609/core.html#parameter-error-handler'>
*   error-handler</a>" configuration parameter is <code>null</code>. However, implementations
*   may provide a default error handler at creation time. In that case,
*   the initial value of the <code>"error-handler"</code> configuration
*   parameter on the new created <code>LSParser</code> contains a
*   reference to the default error handler.
* @exception DOMException
*    NOT_SUPPORTED_ERR: Raised if the requested mode or schema type is
*   not supported.
    */
   public LSParser createLSParser(short mode, String schemaType)
           throws DOMException {
           if (mode != DOMImplementationLS.MODE_SYNCHRONOUS || (schemaType !=null &&
              !"http://www.w3.org/2001/XMLSchema".equals(schemaType) &&
                   !"http://www.w3.org/TR/REC-xml".equals(schemaType))) {
                   String msg =
                           DOMMessageFormatter.formatMessage(
                                   DOMMessageFormatter.DOM_DOMAIN,
                                   "NOT_SUPPORTED_ERR",
                                   null);
                   throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
           }
           if (schemaType != null
                   && schemaType.equals("http://www.w3.org/TR/REC-xml")) {
                   return new DOMParserImpl(new DTDConfiguration(),
                           schemaType);
           }
           else {
                   // create default parser configuration validating against XMLSchemas
                   return new DOMParserImpl(new XIncludeAwareParserConfiguration(),
                           schemaType);
           }
   }
 
源代码25 项目: TencentKona-8   文件: CoreDOMImplementationImpl.java
/**
    * DOM Level 3 LS CR - Experimental.
* Create a new <code>LSParser</code>. The newly constructed parser may
* then be configured by means of its <code>DOMConfiguration</code>
* object, and used to parse documents by means of its <code>parse</code>
*  method.
* @param mode  The <code>mode</code> argument is either
*   <code>MODE_SYNCHRONOUS</code> or <code>MODE_ASYNCHRONOUS</code>, if
*   <code>mode</code> is <code>MODE_SYNCHRONOUS</code> then the
*   <code>LSParser</code> that is created will operate in synchronous
*   mode, if it's <code>MODE_ASYNCHRONOUS</code> then the
*   <code>LSParser</code> that is created will operate in asynchronous
*   mode.
* @param schemaType  An absolute URI representing the type of the schema
*   language used during the load of a <code>Document</code> using the
*   newly created <code>LSParser</code>. Note that no lexical checking
*   is done on the absolute URI. In order to create a
*   <code>LSParser</code> for any kind of schema types (i.e. the
*   LSParser will be free to use any schema found), use the value
*   <code>null</code>.
* <p ><b>Note:</b>    For W3C XML Schema [<a href='http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/'>XML Schema Part 1</a>]
*   , applications must use the value
*   <code>"http://www.w3.org/2001/XMLSchema"</code>. For XML DTD [<a href='http://www.w3.org/TR/2000/REC-xml-20001006'>XML 1.0</a>],
*   applications must use the value
*   <code>"http://www.w3.org/TR/REC-xml"</code>. Other Schema languages
*   are outside the scope of the W3C and therefore should recommend an
*   absolute URI in order to use this method.
* @return  The newly created <code>LSParser</code> object. This
*   <code>LSParser</code> is either synchronous or asynchronous
*   depending on the value of the <code>mode</code> argument.
* <p ><b>Note:</b>    By default, the newly created <code>LSParser</code>
*    does not contain a <code>DOMErrorHandler</code>, i.e. the value of
*   the "<a href='http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030609/core.html#parameter-error-handler'>
*   error-handler</a>" configuration parameter is <code>null</code>. However, implementations
*   may provide a default error handler at creation time. In that case,
*   the initial value of the <code>"error-handler"</code> configuration
*   parameter on the new created <code>LSParser</code> contains a
*   reference to the default error handler.
* @exception DOMException
*    NOT_SUPPORTED_ERR: Raised if the requested mode or schema type is
*   not supported.
    */
   public LSParser createLSParser(short mode, String schemaType)
           throws DOMException {
           if (mode != DOMImplementationLS.MODE_SYNCHRONOUS || (schemaType !=null &&
              !"http://www.w3.org/2001/XMLSchema".equals(schemaType) &&
                   !"http://www.w3.org/TR/REC-xml".equals(schemaType))) {
                   String msg =
                           DOMMessageFormatter.formatMessage(
                                   DOMMessageFormatter.DOM_DOMAIN,
                                   "NOT_SUPPORTED_ERR",
                                   null);
                   throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
           }
           if (schemaType != null
                   && schemaType.equals("http://www.w3.org/TR/REC-xml")) {
                   return new DOMParserImpl(new DTDConfiguration(),
                           schemaType);
           }
           else {
                   // create default parser configuration validating against XMLSchemas
                   return new DOMParserImpl(new XIncludeAwareParserConfiguration(),
                           schemaType);
           }
   }
 
源代码26 项目: jdk8u60   文件: CoreDOMImplementationImpl.java
/**
    * DOM Level 3 LS CR - Experimental.
* Create a new <code>LSParser</code>. The newly constructed parser may
* then be configured by means of its <code>DOMConfiguration</code>
* object, and used to parse documents by means of its <code>parse</code>
*  method.
* @param mode  The <code>mode</code> argument is either
*   <code>MODE_SYNCHRONOUS</code> or <code>MODE_ASYNCHRONOUS</code>, if
*   <code>mode</code> is <code>MODE_SYNCHRONOUS</code> then the
*   <code>LSParser</code> that is created will operate in synchronous
*   mode, if it's <code>MODE_ASYNCHRONOUS</code> then the
*   <code>LSParser</code> that is created will operate in asynchronous
*   mode.
* @param schemaType  An absolute URI representing the type of the schema
*   language used during the load of a <code>Document</code> using the
*   newly created <code>LSParser</code>. Note that no lexical checking
*   is done on the absolute URI. In order to create a
*   <code>LSParser</code> for any kind of schema types (i.e. the
*   LSParser will be free to use any schema found), use the value
*   <code>null</code>.
* <p ><b>Note:</b>    For W3C XML Schema [<a href='http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/'>XML Schema Part 1</a>]
*   , applications must use the value
*   <code>"http://www.w3.org/2001/XMLSchema"</code>. For XML DTD [<a href='http://www.w3.org/TR/2000/REC-xml-20001006'>XML 1.0</a>],
*   applications must use the value
*   <code>"http://www.w3.org/TR/REC-xml"</code>. Other Schema languages
*   are outside the scope of the W3C and therefore should recommend an
*   absolute URI in order to use this method.
* @return  The newly created <code>LSParser</code> object. This
*   <code>LSParser</code> is either synchronous or asynchronous
*   depending on the value of the <code>mode</code> argument.
* <p ><b>Note:</b>    By default, the newly created <code>LSParser</code>
*    does not contain a <code>DOMErrorHandler</code>, i.e. the value of
*   the "<a href='http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030609/core.html#parameter-error-handler'>
*   error-handler</a>" configuration parameter is <code>null</code>. However, implementations
*   may provide a default error handler at creation time. In that case,
*   the initial value of the <code>"error-handler"</code> configuration
*   parameter on the new created <code>LSParser</code> contains a
*   reference to the default error handler.
* @exception DOMException
*    NOT_SUPPORTED_ERR: Raised if the requested mode or schema type is
*   not supported.
    */
   public LSParser createLSParser(short mode, String schemaType)
           throws DOMException {
           if (mode != DOMImplementationLS.MODE_SYNCHRONOUS || (schemaType !=null &&
              !"http://www.w3.org/2001/XMLSchema".equals(schemaType) &&
                   !"http://www.w3.org/TR/REC-xml".equals(schemaType))) {
                   String msg =
                           DOMMessageFormatter.formatMessage(
                                   DOMMessageFormatter.DOM_DOMAIN,
                                   "NOT_SUPPORTED_ERR",
                                   null);
                   throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
           }
           if (schemaType != null
                   && schemaType.equals("http://www.w3.org/TR/REC-xml")) {
                   return new DOMParserImpl(new DTDConfiguration(),
                           schemaType);
           }
           else {
                   // create default parser configuration validating against XMLSchemas
                   return new DOMParserImpl(new XIncludeAwareParserConfiguration(),
                           schemaType);
           }
   }
 
/**
    * DOM Level 3 LS CR - Experimental.
* Create a new <code>LSParser</code>. The newly constructed parser may
* then be configured by means of its <code>DOMConfiguration</code>
* object, and used to parse documents by means of its <code>parse</code>
*  method.
* @param mode  The <code>mode</code> argument is either
*   <code>MODE_SYNCHRONOUS</code> or <code>MODE_ASYNCHRONOUS</code>, if
*   <code>mode</code> is <code>MODE_SYNCHRONOUS</code> then the
*   <code>LSParser</code> that is created will operate in synchronous
*   mode, if it's <code>MODE_ASYNCHRONOUS</code> then the
*   <code>LSParser</code> that is created will operate in asynchronous
*   mode.
* @param schemaType  An absolute URI representing the type of the schema
*   language used during the load of a <code>Document</code> using the
*   newly created <code>LSParser</code>. Note that no lexical checking
*   is done on the absolute URI. In order to create a
*   <code>LSParser</code> for any kind of schema types (i.e. the
*   LSParser will be free to use any schema found), use the value
*   <code>null</code>.
* <p ><b>Note:</b>    For W3C XML Schema [<a href='http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/'>XML Schema Part 1</a>]
*   , applications must use the value
*   <code>"http://www.w3.org/2001/XMLSchema"</code>. For XML DTD [<a href='http://www.w3.org/TR/2000/REC-xml-20001006'>XML 1.0</a>],
*   applications must use the value
*   <code>"http://www.w3.org/TR/REC-xml"</code>. Other Schema languages
*   are outside the scope of the W3C and therefore should recommend an
*   absolute URI in order to use this method.
* @return  The newly created <code>LSParser</code> object. This
*   <code>LSParser</code> is either synchronous or asynchronous
*   depending on the value of the <code>mode</code> argument.
* <p ><b>Note:</b>    By default, the newly created <code>LSParser</code>
*    does not contain a <code>DOMErrorHandler</code>, i.e. the value of
*   the "<a href='http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030609/core.html#parameter-error-handler'>
*   error-handler</a>" configuration parameter is <code>null</code>. However, implementations
*   may provide a default error handler at creation time. In that case,
*   the initial value of the <code>"error-handler"</code> configuration
*   parameter on the new created <code>LSParser</code> contains a
*   reference to the default error handler.
* @exception DOMException
*    NOT_SUPPORTED_ERR: Raised if the requested mode or schema type is
*   not supported.
    */
   public LSParser createLSParser(short mode, String schemaType)
           throws DOMException {
           if (mode != DOMImplementationLS.MODE_SYNCHRONOUS || (schemaType !=null &&
              !"http://www.w3.org/2001/XMLSchema".equals(schemaType) &&
                   !"http://www.w3.org/TR/REC-xml".equals(schemaType))) {
                   String msg =
                           DOMMessageFormatter.formatMessage(
                                   DOMMessageFormatter.DOM_DOMAIN,
                                   "NOT_SUPPORTED_ERR",
                                   null);
                   throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
           }
           if (schemaType != null
                   && schemaType.equals("http://www.w3.org/TR/REC-xml")) {
                   return new DOMParserImpl(new DTDConfiguration(),
                           schemaType);
           }
           else {
                   // create default parser configuration validating against XMLSchemas
                   return new DOMParserImpl(new XIncludeAwareParserConfiguration(),
                           schemaType);
           }
   }
 
源代码28 项目: openjdk-jdk8u   文件: CoreDOMImplementationImpl.java
/**
    * DOM Level 3 LS CR - Experimental.
* Create a new <code>LSParser</code>. The newly constructed parser may
* then be configured by means of its <code>DOMConfiguration</code>
* object, and used to parse documents by means of its <code>parse</code>
*  method.
* @param mode  The <code>mode</code> argument is either
*   <code>MODE_SYNCHRONOUS</code> or <code>MODE_ASYNCHRONOUS</code>, if
*   <code>mode</code> is <code>MODE_SYNCHRONOUS</code> then the
*   <code>LSParser</code> that is created will operate in synchronous
*   mode, if it's <code>MODE_ASYNCHRONOUS</code> then the
*   <code>LSParser</code> that is created will operate in asynchronous
*   mode.
* @param schemaType  An absolute URI representing the type of the schema
*   language used during the load of a <code>Document</code> using the
*   newly created <code>LSParser</code>. Note that no lexical checking
*   is done on the absolute URI. In order to create a
*   <code>LSParser</code> for any kind of schema types (i.e. the
*   LSParser will be free to use any schema found), use the value
*   <code>null</code>.
* <p ><b>Note:</b>    For W3C XML Schema [<a href='http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/'>XML Schema Part 1</a>]
*   , applications must use the value
*   <code>"http://www.w3.org/2001/XMLSchema"</code>. For XML DTD [<a href='http://www.w3.org/TR/2000/REC-xml-20001006'>XML 1.0</a>],
*   applications must use the value
*   <code>"http://www.w3.org/TR/REC-xml"</code>. Other Schema languages
*   are outside the scope of the W3C and therefore should recommend an
*   absolute URI in order to use this method.
* @return  The newly created <code>LSParser</code> object. This
*   <code>LSParser</code> is either synchronous or asynchronous
*   depending on the value of the <code>mode</code> argument.
* <p ><b>Note:</b>    By default, the newly created <code>LSParser</code>
*    does not contain a <code>DOMErrorHandler</code>, i.e. the value of
*   the "<a href='http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030609/core.html#parameter-error-handler'>
*   error-handler</a>" configuration parameter is <code>null</code>. However, implementations
*   may provide a default error handler at creation time. In that case,
*   the initial value of the <code>"error-handler"</code> configuration
*   parameter on the new created <code>LSParser</code> contains a
*   reference to the default error handler.
* @exception DOMException
*    NOT_SUPPORTED_ERR: Raised if the requested mode or schema type is
*   not supported.
    */
   public LSParser createLSParser(short mode, String schemaType)
           throws DOMException {
           if (mode != DOMImplementationLS.MODE_SYNCHRONOUS || (schemaType !=null &&
              !"http://www.w3.org/2001/XMLSchema".equals(schemaType) &&
                   !"http://www.w3.org/TR/REC-xml".equals(schemaType))) {
                   String msg =
                           DOMMessageFormatter.formatMessage(
                                   DOMMessageFormatter.DOM_DOMAIN,
                                   "NOT_SUPPORTED_ERR",
                                   null);
                   throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
           }
           if (schemaType != null
                   && schemaType.equals("http://www.w3.org/TR/REC-xml")) {
                   return new DOMParserImpl(new DTDConfiguration(),
                           schemaType);
           }
           else {
                   // create default parser configuration validating against XMLSchemas
                   return new DOMParserImpl(new XIncludeAwareParserConfiguration(),
                           schemaType);
           }
   }
 
/**
    * DOM Level 3 LS CR - Experimental.
* Create a new <code>LSParser</code>. The newly constructed parser may
* then be configured by means of its <code>DOMConfiguration</code>
* object, and used to parse documents by means of its <code>parse</code>
*  method.
* @param mode  The <code>mode</code> argument is either
*   <code>MODE_SYNCHRONOUS</code> or <code>MODE_ASYNCHRONOUS</code>, if
*   <code>mode</code> is <code>MODE_SYNCHRONOUS</code> then the
*   <code>LSParser</code> that is created will operate in synchronous
*   mode, if it's <code>MODE_ASYNCHRONOUS</code> then the
*   <code>LSParser</code> that is created will operate in asynchronous
*   mode.
* @param schemaType  An absolute URI representing the type of the schema
*   language used during the load of a <code>Document</code> using the
*   newly created <code>LSParser</code>. Note that no lexical checking
*   is done on the absolute URI. In order to create a
*   <code>LSParser</code> for any kind of schema types (i.e. the
*   LSParser will be free to use any schema found), use the value
*   <code>null</code>.
* <p ><b>Note:</b>    For W3C XML Schema [<a href='http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/'>XML Schema Part 1</a>]
*   , applications must use the value
*   <code>"http://www.w3.org/2001/XMLSchema"</code>. For XML DTD [<a href='http://www.w3.org/TR/2000/REC-xml-20001006'>XML 1.0</a>],
*   applications must use the value
*   <code>"http://www.w3.org/TR/REC-xml"</code>. Other Schema languages
*   are outside the scope of the W3C and therefore should recommend an
*   absolute URI in order to use this method.
* @return  The newly created <code>LSParser</code> object. This
*   <code>LSParser</code> is either synchronous or asynchronous
*   depending on the value of the <code>mode</code> argument.
* <p ><b>Note:</b>    By default, the newly created <code>LSParser</code>
*    does not contain a <code>DOMErrorHandler</code>, i.e. the value of
*   the "<a href='http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030609/core.html#parameter-error-handler'>
*   error-handler</a>" configuration parameter is <code>null</code>. However, implementations
*   may provide a default error handler at creation time. In that case,
*   the initial value of the <code>"error-handler"</code> configuration
*   parameter on the new created <code>LSParser</code> contains a
*   reference to the default error handler.
* @exception DOMException
*    NOT_SUPPORTED_ERR: Raised if the requested mode or schema type is
*   not supported.
    */
   public LSParser createLSParser(short mode, String schemaType)
           throws DOMException {
           if (mode != DOMImplementationLS.MODE_SYNCHRONOUS || (schemaType !=null &&
              !"http://www.w3.org/2001/XMLSchema".equals(schemaType) &&
                   !"http://www.w3.org/TR/REC-xml".equals(schemaType))) {
                   String msg =
                           DOMMessageFormatter.formatMessage(
                                   DOMMessageFormatter.DOM_DOMAIN,
                                   "NOT_SUPPORTED_ERR",
                                   null);
                   throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
           }
           if (schemaType != null
                   && schemaType.equals("http://www.w3.org/TR/REC-xml")) {
                   return new DOMParserImpl(new DTDConfiguration(),
                           schemaType);
           }
           else {
                   // create default parser configuration validating against XMLSchemas
                   return new DOMParserImpl(new XIncludeAwareParserConfiguration(),
                           schemaType);
           }
   }
 
源代码30 项目: Bytecoder   文件: CoreDOMImplementationImpl.java
/**
     * DOM Level 3 LS CR - Experimental.
 * Create a new <code>LSParser</code>. The newly constructed parser may
 * then be configured by means of its <code>DOMConfiguration</code>
 * object, and used to parse documents by means of its <code>parse</code>
 *  method.
 * @param mode  The <code>mode</code> argument is either
 *   <code>MODE_SYNCHRONOUS</code> or <code>MODE_ASYNCHRONOUS</code>, if
 *   <code>mode</code> is <code>MODE_SYNCHRONOUS</code> then the
 *   <code>LSParser</code> that is created will operate in synchronous
 *   mode, if it's <code>MODE_ASYNCHRONOUS</code> then the
 *   <code>LSParser</code> that is created will operate in asynchronous
 *   mode.
 * @param schemaType  An absolute URI representing the type of the schema
 *   language used during the load of a <code>Document</code> using the
 *   newly created <code>LSParser</code>. Note that no lexical checking
 *   is done on the absolute URI. In order to create a
 *   <code>LSParser</code> for any kind of schema types (i.e. the
 *   LSParser will be free to use any schema found), use the value
 *   <code>null</code>.
 * <p ><b>Note:</b>    For W3C XML Schema [<a href='http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/'>XML Schema Part 1</a>]
 *   , applications must use the value
 *   <code>"http://www.w3.org/2001/XMLSchema"</code>. For XML DTD [<a href='http://www.w3.org/TR/2000/REC-xml-20001006'>XML 1.0</a>],
 *   applications must use the value
 *   <code>"http://www.w3.org/TR/REC-xml"</code>. Other Schema languages
 *   are outside the scope of the W3C and therefore should recommend an
 *   absolute URI in order to use this method.
 * @return  The newly created <code>LSParser</code> object. This
 *   <code>LSParser</code> is either synchronous or asynchronous
 *   depending on the value of the <code>mode</code> argument.
 * <p ><b>Note:</b>    By default, the newly created <code>LSParser</code>
 *    does not contain a <code>DOMErrorHandler</code>, i.e. the value of
 *   the "<a href='http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030609/core.html#parameter-error-handler'>
 *   error-handler</a>" configuration parameter is <code>null</code>. However, implementations
 *   may provide a default error handler at creation time. In that case,
 *   the initial value of the <code>"error-handler"</code> configuration
 *   parameter on the new created <code>LSParser</code> contains a
 *   reference to the default error handler.
 * @exception DOMException
 *    NOT_SUPPORTED_ERR: Raised if the requested mode or schema type is
 *   not supported.
     */
public LSParser createLSParser(short mode, String schemaType)
            throws DOMException {
            if (mode != DOMImplementationLS.MODE_SYNCHRONOUS || (schemaType !=null &&
               !"http://www.w3.org/2001/XMLSchema".equals(schemaType) &&
                    !"http://www.w3.org/TR/REC-xml".equals(schemaType))) {
                    String msg =
                            DOMMessageFormatter.formatMessage(
                                    DOMMessageFormatter.DOM_DOMAIN,
                                    "NOT_SUPPORTED_ERR",
                                    null);
                    throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
            }
            if (schemaType != null
                    && schemaType.equals("http://www.w3.org/TR/REC-xml")) {
                    return new DOMParserImpl(new XML11DTDConfiguration(),
                            schemaType);
            }
            else {
                    // create default parser configuration validating against XMLSchemas
                    return new DOMParserImpl(new XIncludeAwareParserConfiguration(),
                            schemaType);
            }
    }
 
 类所在包
 同包方法