Package org.codehaus.stax2

Examples of org.codehaus.stax2.XMLStreamWriter2.writeStartElement()


            }

            // Invalid case: leaving the required attr out:
            StringWriter strw = new StringWriter();
            XMLStreamWriter2 sw = getDTDValidatingWriter(strw, REQUIRED_DTD_STR, nsAware, repairing);
            sw.writeStartElement("root");
            try {
                sw.writeEndElement();
                fail(modeDesc+" Expected a validation exception when omitting a #REQUIRED attribute");
            } catch (XMLValidationException vex) {
                // expected...
View Full Code Here


            /* Ok, as long as we use the right ns prefix... better also
             * output namespace declaration, in non-repairing mode.
             */
            XMLStreamWriter2 sw = getDTDValidatingWriter(strw, IMPLIED_NS_DTD_STR, true, repairing);
            sw.writeStartElement("root");
            if (!repairing) {
                sw.writeNamespace(NS_PREFIX, NS_URI);
            }
            // prefix, uri, localname (for attrs!)
            sw.writeAttribute(NS_PREFIX, NS_URI, "attr", "value");
View Full Code Here

            // Invalid case, trying to use "wrong" prefix:

            StringWriter strw = new StringWriter();
            XMLStreamWriter2 sw = getDTDValidatingWriter(strw, IMPLIED_NS_DTD_STR, true, repairing);
            sw.writeStartElement("root");
            if (!repairing) {
                sw.writeNamespace(NS_PREFIX, NS_URI);
            }
            // prefix, uri, localname (for attrs!)
            try {
View Full Code Here

        // let's use namespace-aware just because some impls might not support non-ns
        XMLOutputFactory of = getFactory(TYPE_NS);
        TypedXMLStreamWriter sw = (TypedXMLStreamWriter) of.createXMLStreamWriter(new DOMResult(doc));

        sw.writeStartDocument();
        sw.writeStartElement("root");
        sw.writeIntAttribute(null, null, "attr", -900);
        sw.writeInt(123);
        sw.writeEndElement();
        sw.writeEndDocument();
        sw.close();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.