Package org.codehaus.stax2.typed

Examples of org.codehaus.stax2.typed.TypedXMLStreamWriter.writeStartElement()


            XMLStreamWriter2 sw = getDTDValidatingWriter(strw, SIMPLE_DTD, nsAware, repairing);
            sw.writeStartElement("root");
            sw.writeCharacters("  "); // imitating indentation
            sw.writeStartElement("branch");
            sw.writeEndElement();
            sw.writeStartElement("branch");
            sw.writeCharacters("test");
            sw.writeComment("comment");
            sw.writeEndElement();
            sw.writeEmptyElement("branch");
            sw.writeCharacters("\n"); // imitating indentation
View Full Code Here


            }
            // should not continue after exception; state may not be valid

            // And then leaving out branch...
            sw = getDTDValidatingWriter(strw, SIMPLE_DTD, nsAware, repairing);
            sw.writeStartElement("root");
            sw.writeCharacters("  "); // imitating indentation
            sw.writeComment("comment");
            try {
                sw.writeEmptyElement("end");
                fail(modeDesc+" Expected a validation exception when omitting non-optional <branch> element");
View Full Code Here

            boolean repairing = (i == 2);
            StringWriter strw = new StringWriter();

            XMLStreamWriter2 sw = getDTDValidatingWriter(strw, SIMPLE_NS_DTD, true, repairing);
            // prefix, local name, uri (for elems)
            sw.writeStartElement(NS_PREFIX, "root", NS_URI);
            if (!repairing) {
                sw.writeNamespace(NS_PREFIX, NS_URI);
            }
            sw.writeEndElement();
            sw.writeEndDocument();
View Full Code Here

            // Let's try omitting the end element, first...

            XMLStreamWriter2 sw = getDTDValidatingWriter(strw, SIMPLE_NS_DTD, true, repairing);
            // prefix, local name, uri (for elems)
            try {
                sw.writeStartElement(NS_PREFIX2, "root", NS_URI);
                fail(modeDesc+" Expected a validation exception when passing wrong (unexpected) ns for element");
            } catch (XMLValidationException vex) {
                // expected...
            }
            // should not continue after exception; state may not be valid
View Full Code Here

            boolean repairing = (i == 2);
            StringWriter strw = new StringWriter();

            // Ok either without being added:
            XMLStreamWriter2 sw = getDTDValidatingWriter(strw, FIXED_DTD_STR, nsAware, repairing);
            sw.writeStartElement("root");
            sw.writeEndElement();
            sw.writeEndDocument();
            sw.close();

            sw = getDTDValidatingWriter(strw, FIXED_DTD_STR, nsAware, repairing);
View Full Code Here

            sw.writeEndDocument();
            sw.close();

            // or by using the exact same value
            sw = getDTDValidatingWriter(strw, FIXED_DTD_STR, nsAware, repairing);
            sw.writeStartElement("root");
            sw.writeAttribute("fixAttr", "fixedValue");
            sw.writeEndElement();
            sw.writeEndDocument();
            sw.close();
        }
View Full Code Here

            // Invalid case, trying to add some other value:

            // non-empty but not same
            StringWriter strw = new StringWriter();
            XMLStreamWriter2 sw = getDTDValidatingWriter(strw, FIXED_DTD_STR, nsAware, repairing);
            sw.writeStartElement("root");
            try {
                sw.writeAttribute("fixAttr", "otherValue");
                fail(modeDesc+" Expected a validation exception when trying to add a #FIXED attribute with 'wrong' value");
            } catch (XMLValidationException vex) {
                // expected...
View Full Code Here

            // Should not close, since stream is invalid now...

            // empty is not the same as leaving it out:
            strw = new StringWriter();
            sw = getDTDValidatingWriter(strw, FIXED_DTD_STR, nsAware, repairing);
            sw.writeStartElement("root");
            try {
                sw.writeAttribute("fixAttr", "");
                fail(modeDesc+" Expected a validation exception when trying to add a #FIXED attribute with an empty value");
            } catch (XMLValidationException vex) {
                // expected...
View Full Code Here

            boolean repairing = (i == 2);
            StringWriter strw = new StringWriter();

            // Ok if value is added:
            XMLStreamWriter2 sw = getDTDValidatingWriter(strw, REQUIRED_DTD_STR, nsAware, repairing);
            sw.writeStartElement("root");
            sw.writeAttribute("reqAttr", "value");
            sw.writeEndElement();
            sw.writeEndDocument();
            sw.close();
View Full Code Here

            sw.writeEndDocument();
            sw.close();

            // ... even if with empty value (for CDATA type, at least)
            sw = getDTDValidatingWriter(strw, REQUIRED_DTD_STR, nsAware, repairing);
            sw.writeStartElement("root");
            sw.writeAttribute("reqAttr", "");
            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.