Package org.xml.sax.helpers

Examples of org.xml.sax.helpers.XMLReaderAdapter


        try {
            try {
                parser = JAXPUtils.getParser();
            } catch (BuildException e) {
                parser = new XMLReaderAdapter(JAXPUtils.getXMLReader());
            }
            String uri = FILE_UTILS.toURI(bFile.getAbsolutePath());
            inputStream = new FileInputStream(bFile);
            inputSource = new InputSource(inputStream);
            inputSource.setSystemId(uri);
View Full Code Here


    }

    public Parser getParser() throws SAXException {
        if (parser == null) {
            // Adapt a SAX2 XMLReader into a SAX1 Parser
            parser = new XMLReaderAdapter(xmlReader);

            // Set a DocumentHandler that does nothing to avoid getting
            // exceptions if no DocumentHandler is set by the app
            parser.setDocumentHandler(new HandlerBase());
        }
View Full Code Here

   
        /** @deprecated */
    public org.xml.sax.Parser getParser() throws SAXException {
        // maybe we should throw an UnsupportedOperationException,
        // rather than doing a trick like this.
        return new XMLReaderAdapter(getXMLReader());
    }
View Full Code Here

            // polymorphic collection to insert artifical <menu-element>
            // tags enabling Castor XML binding; see JETSPEED-INF/castor/page-mapping.xml
            SAXParserFactory factory = SAXParserFactory.newInstance();
            SAXParser parser = factory.newSAXParser();
            XMLReader reader = parser.getXMLReader();
            final XMLReaderAdapter readerAdapter = new XMLReaderAdapter(reader);
            final InputSource readerInput = new InputSource(new InputStreamReader(new FileInputStream(f), PSML_DOCUMENT_ENCODING));
            Unmarshaller unmarshaller = new Unmarshaller(this.mapping);
            document = (Document) unmarshaller.unmarshal(new EventProducer()
                {
                    public void setDocumentHandler(final DocumentHandler handler)
                    {
                        readerAdapter.setDocumentHandler(new DocumentHandler()
                            {
                                private int menuDepth = 0;

                                public void characters(char[] ch, int start, int length) throws SAXException
                                {
                                    handler.characters(ch, start, length);
                                }

                                public void endDocument() throws SAXException
                                {
                                    handler.endDocument();
                                }

                                public void endElement(String name) throws SAXException
                                {
                                    // always include all elements
                                    handler.endElement(name);

                                    // track menu depth and insert menu-element nodes
                                    // to encapsulate menu elements to support collection
                                    // polymorphism in Castor
                                    if (name.equals("menu"))
                                    {
                                        menuDepth--;
                                        if (menuDepth > 0)
                                        {
                                            handler.endElement("menu-element");
                                        }
                                    }
                                    else if ((menuDepth > 0) &&
                                             (name.equals("options") || name.equals("separator") ||
                                              name.equals("include") || name.equals("exclude")))
                                    {
                                        handler.endElement("menu-element");
                                    }
                                }

                                public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
                                {
                                    handler.ignorableWhitespace(ch, start, length);
                                }

                                public void processingInstruction(String target, String data) throws SAXException
                                {
                                    handler.processingInstruction(target, data);
                                }

                                public void setDocumentLocator(Locator locator)
                                {
                                    handler.setDocumentLocator(locator);
                                }

                                public void startDocument() throws SAXException
                                {
                                    handler.startDocument();
                                }

                                public void startElement(String name, AttributeList atts) throws SAXException
                                {
                                    // track menu depth and insert menu-element nodes
                                    // to encapsulate menu elements to support collection
                                    // polymorphism in Castor
                                    if (name.equals("menu"))
                                    {
                                        if (menuDepth > 0)
                                        {
                                            handler.startElement("menu-element", null);
                                        }
                                        menuDepth++;
                                    }
                                    else if ((menuDepth > 0) &&
                                             (name.equals("options") || name.equals("separator") ||
                                              name.equals("include") || name.equals("exclude")))
                                    {
                                        handler.startElement("menu-element", null);
                                    }

                                    // always include all elements
                                    handler.startElement(name, atts);
                                }
                            });
                    }
                    public void start() throws SAXException
                    {
                        try
                        {
                            readerAdapter.parse(readerInput);
                        }
                        catch (IOException ioe)
                        {
                            throw new SAXException(ioe);
                        }
View Full Code Here

        try {
            try {
                parser = JAXPUtils.getParser();
            } catch (BuildException e) {
                parser = new XMLReaderAdapter(JAXPUtils.getXMLReader());
            }


            String uri = FILE_UTILS.toURI(bFile.getAbsolutePath());
            inputStream = new FileInputStream(bFile);
View Full Code Here

        try {
            try {
                parser = JAXPUtils.getParser();
            } catch (BuildException e) {
                parser = new XMLReaderAdapter(JAXPUtils.getXMLReader());
            }
            String uri = FILE_UTILS.toURI(bFile.getAbsolutePath());
            inputStream = new FileInputStream(bFile);
            inputSource = new InputSource(inputStream);
            inputSource.setSystemId(uri);
View Full Code Here

        try {
            try {
                parser = JAXPUtils.getParser();
            } catch (BuildException e) {
                parser = new XMLReaderAdapter(JAXPUtils.getXMLReader());
            }


            String uri = fu.toURI(buildFile.getAbsolutePath());
            inputStream = new FileInputStream(buildFile);
View Full Code Here

        /**
         * @deprecated
         */
        public org.xml.sax.Parser getParser() throws SAXException {
            return new XMLReaderAdapter(reader);
        }
View Full Code Here

        try {
            try {
                parser = JAXPUtils.getParser();
            } catch (BuildException e) {
                parser = new XMLReaderAdapter(JAXPUtils.getXMLReader());
            }
            String uri = FILE_UTILS.toURI(bFile.getAbsolutePath());
            inputStream = new FileInputStream(bFile);
            inputSource = new InputSource(inputStream);
            inputSource.setSystemId(uri);
View Full Code Here

                System.out.println("The default parser implementation (Xerces) was not found,\nthe JRE parser (Crimson) is being used instead.");
                System.setProperty("javax.xml.parsers.SAXParserFactory", "org.apache.crimson.jaxp.SAXParserFactoryImpl");
                factory = SAXParserFactory.newInstance();
            }
            XMLReader xmlReader = factory.newSAXParser().getXMLReader();
            xmlReaderAdapter = new XMLReaderAdapter(xmlReader);
            xmlReaderAdapter.setEntityResolver(new OOoDTDResolver());
            // preparing the original for the clones of the XSL Processor
            clonableXSLProcessor = new XSLProcessorImpl();
            clonableXSLProcessor.setParser(xmlReaderAdapter);
View Full Code Here

TOP

Related Classes of org.xml.sax.helpers.XMLReaderAdapter

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.