Package javax.xml.stream.events

Examples of javax.xml.stream.events.StartElement


                writer.writeNamespace(ns.getPrefix(), ns.getNamespaceURI());
                break;
            }
           
            case XMLEvent.START_ELEMENT: {
                StartElement se = event.asStartElement();
                QName n = se.getName();
                writer.writeStartElement(n.getPrefix(), n.getLocalPart(),
                                          n.getNamespaceURI());
                Iterator<?> it = se.getNamespaces();
                while (it.hasNext()) {
                    Namespace ns = (Namespace) it.next();
                    writer.writeNamespace(ns.getPrefix(), ns.getNamespaceURI());
                }
                it = se.getAttributes();
                while (it.hasNext()) {
                    Attribute attr = (Attribute) it.next();
                    QName name = attr.getName();
                    writer.writeAttribute(name.getPrefix(), name.getNamespaceURI(),
                                           name.getLocalPart(), attr.getValue());
View Full Code Here


    }
   
   
    private static void writeStartElementEvent(XMLEvent event, XMLStreamWriter writer)
        throws XMLStreamException {
        StartElement start = event.asStartElement();
        QName name = start.getName();
        String nsURI = name.getNamespaceURI();
        String localName = name.getLocalPart();
        String prefix = name.getPrefix();
       
        if (prefix != null) {
            writer.writeStartElement(prefix, localName, nsURI);
        } else if (nsURI != null) {
            writer.writeStartElement(localName, nsURI);
        } else {
            writer.writeStartElement(localName);
        }
        Iterator it = start.getNamespaces();
        while (it != null && it.hasNext()) {
            writeEvent((XMLEvent)it.next(), writer);
        }
       
        it = start.getAttributes();
        while (it != null && it.hasNext()) {
            writeAttributeEvent((Attribute)it.next(), writer);           
        }
    }
View Full Code Here

    }
   
   
    private static void writeStartElementEvent(XMLEvent event, XMLStreamWriter writer)
        throws XMLStreamException {
        StartElement start = event.asStartElement();
        QName name = start.getName();
        String nsURI = name.getNamespaceURI();
        String localName = name.getLocalPart();
        String prefix = name.getPrefix();
       
        if (prefix != null) {
            writer.writeStartElement(prefix, localName, nsURI);
        } else if (nsURI != null) {
            writer.writeStartElement(localName, nsURI);
        } else {
            writer.writeStartElement(localName);
        }
        Iterator<XMLEvent> it = CastUtils.cast(start.getNamespaces());
        while (it != null && it.hasNext()) {
            writeEvent(it.next(), writer);
        }
       
        it = CastUtils.cast(start.getAttributes());
        while (it != null && it.hasNext()) {
            writeAttributeEvent(it.next(), writer);           
        }
    }
View Full Code Here

    }
   
   
    private static void writeStartElementEvent(XMLEvent event, XMLStreamWriter writer)
        throws XMLStreamException {
        StartElement start = event.asStartElement();
        QName name = start.getName();
        String nsURI = name.getNamespaceURI();
        String localName = name.getLocalPart();
        String prefix = name.getPrefix();
       
        if (prefix != null) {
            writer.writeStartElement(prefix, localName, nsURI);
        } else if (nsURI != null) {
            writer.writeStartElement(localName, nsURI);
        } else {
            writer.writeStartElement(localName);
        }
        Iterator it = start.getNamespaces();
        while (it != null && it.hasNext()) {
            writeEvent((XMLEvent)it.next(), writer);
        }
       
        it = start.getAttributes();
        while (it != null && it.hasNext()) {
            writeAttributeEvent((Attribute)it.next(), writer);           
        }
    }
View Full Code Here

    }
   
   
    private static void writeStartElementEvent(XMLEvent event, XMLStreamWriter writer)
        throws XMLStreamException {
        StartElement start = event.asStartElement();
        QName name = start.getName();
        String nsURI = name.getNamespaceURI();
        String localName = name.getLocalPart();
        String prefix = name.getPrefix();
       
        if (prefix != null) {
            writer.writeStartElement(prefix, localName, nsURI);
        } else if (nsURI != null) {
            writer.writeStartElement(localName, nsURI);
        } else {
            writer.writeStartElement(localName);
        }
        Iterator it = start.getNamespaces();
        while (it != null && it.hasNext()) {
            writeEvent((XMLEvent)it.next(), writer);
        }
       
        it = start.getAttributes();
        while (it != null && it.hasNext()) {
            writeAttributeEvent((Attribute)it.next(), writer);           
        }
    }
View Full Code Here

            int eType = xmlEvent.getEventType();
            if (eType != XMLStreamConstants.START_ELEMENT){
                continue;
            }

            StartElement startElement = xmlEvent.asStartElement();
            if(startElement
                    .getName()
                    .getLocalPart()
                    .equals(elementName)){
                return xmlEvent;
            }
View Full Code Here

            switch (eType) {
                case XMLStreamConstants.START_ELEMENT:
                    if (level++ > 0){
                        break;
                    }
                    StartElement startElement = xmlEvent.asStartElement();
                    if (startElement
                            .getName()
                            .getLocalPart()
                            .equals(elementName)) {
                        xmlReader.nextEvent();
                        return xmlEvent;
View Full Code Here

        while (xmlReader.hasNext()) {
            xmlEvent = xmlReader.nextEvent();
            eType = xmlEvent.getEventType();
            switch (eType) {
                case XMLStreamConstants.START_ELEMENT:
                    final StartElement startElement = xmlEvent.asStartElement();
                    @SuppressWarnings("unchecked")
                    Iterator<Attribute> attrIttr =
                        startElement.getAttributes();
                    if (level == 0) {
                        if (attrIttr.hasNext())
                            key =  attrIttr.next().getValue();
                    } else if (level == 1 &&
                            key.equals("_raw") &&
                            startElement
                                .getName()
                                .getLocalPart()
                                .equals("v")) {
                        StringBuilder asString = new StringBuilder();
                        StringWriter asXml = new StringWriter();
View Full Code Here

            Attribute attribute = (Attribute) iterator.next();
            if (!name.equals(attribute.getName())) {
                newAttributes.add(attribute);
            }
        }
        StartElement oldStartElement = getStartElement();
        this.startElement = getEventFactory().createStartElement(oldStartElement.getName(), newAttributes.iterator(),
                oldStartElement.getNamespaces());
    }
View Full Code Here

            Attribute attribute = (Attribute) iterator.next();
            newAttributes.add(attribute);
        }
        Attribute newAttribute = getEventFactory().createAttribute(name, value);
        newAttributes.add(newAttribute);
        StartElement oldStartElement = getStartElement();
        this.startElement = getEventFactory().createStartElement(oldStartElement.getName(), newAttributes.iterator(),
                oldStartElement.getNamespaces());
    }
View Full Code Here

TOP

Related Classes of javax.xml.stream.events.StartElement

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.