Package org.cyberneko.pull

Examples of org.cyberneko.pull.XMLEvent


        } catch (IOException e) {
            throw new ParsingException("failed to bind XML input source");
        }
        parser = parserTemp;

        XMLEvent event = getNextXMLEvent();
        if (event.type != XMLEvent.DOCUMENT) throw new ParsingException("XML document event expected, but was type = " + event.type);
    }
View Full Code Here


     * @throws ParsingException
     */
    public Stanza getNextStanza() throws ParsingException {
        if (parser == null) open();

        XMLEvent event = null;
        while(true) {
            event = getNextXMLEvent();
            if (event == null) return null; // end of stream
            if (event.type == XMLEvent.DOCUMENT && !((DocumentEvent) event).start) return null; // end of stream

View Full Code Here

        return new Stanza(null, name, null, stanzaAttributes, xmlFragments);
    }

    private boolean fillDeep(String name, List<XMLFragment> xmlFragments) throws ParsingException {
        XMLEvent event;
        while (true) {
            event = getNextXMLEvent();
            if (event == null) return false;

            if (event.type == XMLEvent.ELEMENT) {
                ElementEvent elementEvent = (ElementEvent) event;
                if (elementEvent.start) {
                    // collect element basics
                    String namespaceURI = resolveNamespace(elementEvent);
                    String innerName = elementEvent.element.localpart;

                    // collect detail data
                    List<Attribute> stanzaAttributes = fillAttributesFromXML(elementEvent);
                    List<XMLFragment> xmlInnerFragments = new ArrayList<XMLFragment>();
                    fillDeep(elementEvent.element.rawname, xmlInnerFragments); // (return value can be savely ignored)

                    // create element with all collected data
                    XMLElement xmlInnerElement = new XMLElement(namespaceURI, innerName, null, stanzaAttributes, xmlInnerFragments);
                    xmlFragments.add(xmlInnerElement);
                } else {
                    return name.equals(elementEvent.element.rawname); // succeed if exact end element found and all is balanced
                }
            } else if (event.type == XMLEvent.CDATA) {
                xmlFragments.add(new XMLText(event.toString()));
            } else if (event.type == XMLEvent.CHARACTERS) {
                XMLString xmlString = ((CharactersEvent) event).text;
                xmlFragments.add(new XMLText(xmlString.toString()));
            } else {
                // ignore other types, as of XMPP spec
View Full Code Here

        }
        return attributes;
    }

    private XMLEvent getNextXMLEvent() throws ParsingException {
        XMLEvent event = null;
        try {
            event = parser.nextEvent();
        } catch (ArrayIndexOutOfBoundsException e) {
            throw new ParsingException("internal xerces error", e);
        } catch (IOException e) {
View Full Code Here

        SourceInfo sourceInfo = new SourceInfo();
        // pull-parse the document until we reach the document element and put the collected information
        // into the sourceInfo object
        try
        {
            XMLEvent event;
            while ((event = parser.nextEvent()) != null)
            {
                if (event.type == XMLEvent.DOCTYPE_DECL)
                {
                    DoctypeDeclEvent doctypeDeclEvent = (DoctypeDeclEvent)event;
View Full Code Here

        SourceInfo sourceInfo = new SourceInfo();
        // pull-parse the document until we reach the document element and put the collected information
        // into the sourceInfo object
        try
        {
            XMLEvent event;
            while ((event = parser.nextEvent()) != null)
            {
                if (event.type == XMLEvent.DOCTYPE_DECL)
                {
                    DoctypeDeclEvent doctypeDeclEvent = (DoctypeDeclEvent)event;
View Full Code Here

        SourceInfo sourceInfo = new SourceInfo();
        // pull-parse the document until we reach the document element and put the collected information
        // into the sourceInfo object
        try
        {
            XMLEvent event;
            while ((event = parser.nextEvent()) != null)
            {
                if (event.type == XMLEvent.DOCTYPE_DECL)
                {
                    DoctypeDeclEvent doctypeDeclEvent = (DoctypeDeclEvent)event;
View Full Code Here

        SourceInfo sourceInfo = new SourceInfo();
        // pull-parse the document until we reach the document element and put the collected information
        // into the sourceInfo object
        try
        {
            XMLEvent event;
            while ((event = parser.nextEvent()) != null)
            {
                if (event.type == XMLEvent.DOCTYPE_DECL)
                {
                    DoctypeDeclEvent doctypeDeclEvent = (DoctypeDeclEvent)event;
View Full Code Here

        SourceInfo sourceInfo = new SourceInfo();
        // pull-parse the document until we reach the document element and put the collected information
        // into the sourceInfo object
        try
        {
            XMLEvent event;
            while ((event = parser.nextEvent()) != null)
            {
                if (event.type == XMLEvent.DOCTYPE_DECL)
                {
                    DoctypeDeclEvent doctypeDeclEvent = (DoctypeDeclEvent)event;
View Full Code Here

        SourceInfo sourceInfo = new SourceInfo();
        // pull-parse the document until we reach the document element and put the collected information
        // into the sourceInfo object
        try
        {
            XMLEvent event;
            while ((event = parser.nextEvent()) != null)
            {
                if (event.type == XMLEvent.DOCTYPE_DECL)
                {
                    DoctypeDeclEvent doctypeDeclEvent = (DoctypeDeclEvent)event;
View Full Code Here

TOP

Related Classes of org.cyberneko.pull.XMLEvent

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.