Package org.codehaus.stax2

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


            sw.close();

            // and finally empty with attribute
            sw = getDTDValidatingWriter(strw, dtdStr, nsAware, repairing);
            sw.writeEmptyElement("root");
            sw.writeAttribute("attr", "otherValue");
            sw.writeEndDocument();
            sw.close();
        }
    }
View Full Code Here


            sw.close();

            // Then one with an attribute
            sw = getDTDValidatingWriter(strw, dtdStr, nsAware, repairing);
            sw.writeStartElement("root");
            sw.writeAttribute("attr", "value");
            sw.writeStartElement("leaf");
            sw.writeEndElement();
            sw.writeEndElement();
            sw.writeEndDocument();
            sw.close();
View Full Code Here

            // undecl attr:
            sw = getDTDValidatingWriter(strw, dtdStr, nsAware, repairing);
            sw.writeStartElement("root");
            try {
                sw.writeAttribute("unknown", "value");
                fail(modeDesc+" Expected a validation exception when trying to add an undeclared attribute");
            } catch (XMLValidationException vex) {
                // expected...
            }
            sw.close();
View Full Code Here

            sw.writeCharacters("test");
            sw.writeComment("comment");
            sw.writeEndElement();
            sw.writeEmptyElement("branch");
            sw.writeEmptyElement("end");
            sw.writeAttribute("endAttr", "value");
            sw.writeCharacters("\n"); // imitating indentation
            sw.writeEndElement(); // for root
        }
    }
View Full Code Here

            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

            // 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...
            }
            // Should not close, since stream is invalid now...
View Full Code Here

            // 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

            // And finally, same for empty elem in case impl. is different
            strw = new StringWriter();
            sw = getDTDValidatingWriter(strw, FIXED_DTD_STR, nsAware, repairing);
            sw.writeEmptyElement("root");
            try {
                sw.writeAttribute("fixAttr", "foobar");
                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

            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();

            // ... even if with empty value (for CDATA type, at least)
View Full Code Here

            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();

            // and ditto for empty element:
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.