Package org.codehaus.stax2

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


        sw.writeStartDocument();
        sw.writeStartElement(URI1, "root");
        sw.writeNamespace("foo2", URI2);
        sw.writeDefaultNamespace(URI3);
        sw.writeStartElement(URI3, "leaf");
        sw.writeAttribute(URI2, "ns-attr", "1");
        sw.writeAttribute(null, "ns-attr", "2");
        sw.writeAttribute("otherprefix", URI2, "lastAttr", "x");
        sw.writeEndElement();
        sw.writeEndElement();
View Full Code Here


        for (int i = 0; i < 3; ++i) {
            boolean nsAware = (i >= 1);
            boolean repairing = (i == 2);
            StringWriter strw = new StringWriter();
            XMLStreamWriter2 sw = getDTDValidatingWriter(strw, dtdStr, nsAware, repairing);
            sw.writeStartElement("root");
            // Should be fine now
            sw.writeCharacters("Text that should be ok");
            sw.writeStartElement("branch");
            // Also, all-whitespace is ok in non-mixed too
            sw.writeCharacters("\t \t   \r   \n");
View Full Code Here

            StringWriter strw = new StringWriter();
            XMLStreamWriter2 sw = getDTDValidatingWriter(strw, dtdStr, nsAware, repairing);
            sw.writeStartElement("root");
            // Should be fine now
            sw.writeCharacters("Text that should be ok");
            sw.writeStartElement("branch");
            // Also, all-whitespace is ok in non-mixed too
            sw.writeCharacters("\t \t   \r   \n");
            sw.writeEndElement();
            sw.writeEndElement();
            sw.writeEndDocument();
View Full Code Here

        for (int i = 0; i < 3; ++i) {
            boolean nsAware = (i >= 1);
            boolean repairing = (i == 2);
            StringWriter strw = new StringWriter();
            XMLStreamWriter2 sw = getDTDValidatingWriter(strw, dtdStr, nsAware, repairing);
            sw.writeStartElement("root");
            // Should get validation exception here:
            try {
                sw.writeCharacters("Illegal text!");
                fail("Expected a validation exception for non-whitespace text output on non-mixed element content");
            } catch (XMLValidationException vex) {
View Full Code Here

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

            XMLStreamWriter2 sw = getDTDValidatingWriter(strw, dtdStr, nsAware, repairing);

            sw.writeStartElement("root");
            // No content whatsoever is allowed...
            sw.writeEndElement();
            sw.writeEndDocument();
            sw.close();
View Full Code Here

            sw.close();

            // Next; same but with an attribute
            sw = getDTDValidatingWriter(strw, dtdStr, nsAware, repairing);

            sw.writeStartElement("root");
            // no content, but attribute is fine
            sw.writeAttribute("attr", "value");

            sw.writeEndElement();
            sw.writeEndDocument();
View Full Code Here

            // No content whatsoever is allowed with EMPTY.
            // Let's first test with a regualr child element:

            XMLStreamWriter2 sw = getDTDValidatingWriter(strw, dtdStr, nsAware, repairing);
            sw.writeStartElement("root");
            try {
                sw.writeStartElement("leaf");
                fail(modeDesc+" Expected a validation exception when trying to add an element into EMPTY content model");
            } catch (XMLValidationException vex) {
                // expected...
View Full Code Here

            // Let's first test with a regualr child element:

            XMLStreamWriter2 sw = getDTDValidatingWriter(strw, dtdStr, nsAware, repairing);
            sw.writeStartElement("root");
            try {
                sw.writeStartElement("leaf");
                fail(modeDesc+" Expected a validation exception when trying to add an element into EMPTY content model");
            } catch (XMLValidationException vex) {
                // expected...
            }
            sw.close();
View Full Code Here

            }
            sw.close();

            // Then with an empty child
            sw = getDTDValidatingWriter(strw, dtdStr, nsAware, repairing);
            sw.writeStartElement("root");
            try {
                sw.writeEmptyElement("leaf");
                fail(modeDesc+" Expected a validation exception when trying to add an element into EMPTY content model");
            } catch (XMLValidationException vex) {
                // expected...
View Full Code Here

            }
            sw.close();

            // Then with any text (even just white space):
            sw = getDTDValidatingWriter(strw, dtdStr, nsAware, repairing);
            sw.writeStartElement("root");
            try {
                sw.writeCharacters(" ");
                fail(modeDesc+" Expected a validation exception when trying to any text into EMPTY content model");
            } catch (XMLValidationException vex) { }
            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.