Package org.w3c.dom.ls

Examples of org.w3c.dom.ls.LSParser


        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);
View Full Code Here


        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);
View Full Code Here

        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.TRUE);
        lsSerializer.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE);
        return lsSerializer.writeToString(document);
View Full Code Here

        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);
View Full Code Here

        this.parserPool = new ParserPool(domImplementationLS);
    }

    private LSParser getParser() throws Exception {
        //TODO: Use a cache for the parsers?
        LSParser parser = (LSParser)parserPool.get();
        return parser;
    }
View Full Code Here

        parserPool.recycle(parser);
    }
   
    public Document parse(InputStream is, boolean ignoreBlanks) throws XMLException {
        try {
            LSParser parser = getParser();
            try {
                if(ignoreBlanks) {
                    parser.setFilter(BLANK_FILTER);
                }
                LSInput ip = domImplementationLS.createLSInput();
                ip.setByteStream(is);
                Document doc = parser.parse(ip);
                return doc;
            } finally {
                recycleParser(parser);
            }
        } catch(Exception e) {
View Full Code Here

        }
    }

    public Document parse(Reader reader, boolean ignoreBlanks) throws XMLException {
        try {
            LSParser parser = getParser();
            try {
                if(ignoreBlanks) {
                    parser.setFilter(BLANK_FILTER);
                }
                LSInput ip = domImplementationLS.createLSInput();
                ip.setCharacterStream(reader);
                Document doc = parser.parse(ip);
                return doc;
            } finally {
                recycleParser(parser);
            }
        } catch(Exception e) {
View Full Code Here

        ParserPool(DOMImplementationLS domImplementationLS) {
            super(8); // Use a parameter here?
            this.domImplementationLS = domImplementationLS;
        }
        protected Object createObject() throws Exception {
            LSParser parser = domImplementationLS.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null);
            return parser;
        }
View Full Code Here

        } catch (Exception e) {
            throw new ServiceRuntimeException(e);
        }
        DOMImplementation impl = registry.getDOMImplementation("XML 3.0");
        DOMImplementationLS ls = (DOMImplementationLS)impl.getFeature("LS", "3.0");
        LSParser parser = ls.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, SCHEMA_NS);
        LSInput input = ls.createLSInput();
        input.setCharacterStream(new StringReader(schema));
        Document document = parser.parse(input);
        XSDefinition definition = factory.createXSDefinition();
        definition.setUnresolved(true);
        definition.setDocument(document);
        definition.setNamespace(ns);
        definitions.add(definition);
View Full Code Here

        } catch (Exception e) {
            throw new ServiceRuntimeException(e);
        }
        DOMImplementation impl = registry.getDOMImplementation("XML 3.0");
        DOMImplementationLS ls = (DOMImplementationLS)impl.getFeature("LS", "3.0");
        LSParser parser = ls.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, SCHEMA_NS);
        LSInput input = ls.createLSInput();
        input.setCharacterStream(new StringReader(schema));
        Document document = parser.parse(input);
        XSDefinition definition = factory.createXSDefinition();
        definition.setUnresolved(true);
        definition.setDocument(document);
        definition.setNamespace(ns);
        definitions.add(definition);
View Full Code Here

TOP

Related Classes of org.w3c.dom.ls.LSParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.