StringWriter strw = new StringWriter();
// 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
// and then the same for empty elem
sw = getDTDValidatingWriter(strw, SIMPLE_NS_DTD, true, repairing);
// prefix, local name, uri (for elems)
try {
sw.writeEmptyElement(NS_PREFIX2, NS_URI, "root");
fail(modeDesc+" Expected a validation exception when passing wrong (unexpected) ns for element");
} catch (XMLValidationException vex) {
// expected...
}
// Oh, and finally, using non-ns DTD:
sw = getDTDValidatingWriter(strw, SIMPLE_DTD, true, repairing);
// prefix, local name, uri (for elems)
try {
sw.writeEmptyElement(NS_PREFIX, NS_URI, "root");
fail(modeDesc+" Expected a validation exception when passing wrong (unexpected) ns for element");
} catch (XMLValidationException vex) {
// expected...
}
}