diff --git a/src/main/java/com/ctc/wstx/sw/BufferingXmlWriter.java b/src/main/java/com/ctc/wstx/sw/BufferingXmlWriter.java index 587527b9..91ca4091 100644 --- a/src/main/java/com/ctc/wstx/sw/BufferingXmlWriter.java +++ b/src/main/java/com/ctc/wstx/sw/BufferingXmlWriter.java @@ -1364,6 +1364,7 @@ public void writeTypedAttribute(String prefix, String localName, String nsURI, mOutputPtr = enc.encodeMore(mOutputBuffer, mOutputPtr, mOutputBufLen); if (enc.isCompleted()) { // yup validator.validateAttribute(localName, nsURI, prefix, mOutputBuffer, start, mOutputPtr); + fastWriteRaw('"'); return; } diff --git a/src/test/java/wstxtest/msv/TestW3CSchemaTypes.java b/src/test/java/wstxtest/msv/TestW3CSchemaTypes.java index c150f9de..19b78ee0 100644 --- a/src/test/java/wstxtest/msv/TestW3CSchemaTypes.java +++ b/src/test/java/wstxtest/msv/TestW3CSchemaTypes.java @@ -30,6 +30,16 @@ public class TestW3CSchemaTypes +"\n" ; + final static String SCHEMA_ATTRIBUTE = + "\n" + +"\n" + +"\n" + +"\n" + +"\n" + +"\n" + +"" + ; + // // // First 'int' datatype public void testSimpleValidInt() throws Exception @@ -66,6 +76,25 @@ public void testSimpleInvalidFloat() throws Exception // // // Writing + public void testValdiationWhenWritingAttribute() throws Exception + { + XMLValidationSchema schema = parseW3CSchema(SCHEMA_ATTRIBUTE); + + XMLOutputFactory2 f = getOutputFactory(); + final StringWriter stringWriter = new StringWriter(); + XMLStreamWriter2 sw = (XMLStreamWriter2)f.createXMLStreamWriter(stringWriter); + sw.validateAgainst(schema); + + sw.writeStartElement("price"); + sw.writeIntAttribute(null, null, "amount", 129); + sw.writeEndElement(); + sw.flush(); + + XMLStreamReader2 sr = getReader(stringWriter.toString()); + sr.validateAgainst(schema); + streamThrough(sr); + } + public void testValdiationWhenWritingCharactersFromArray() throws Exception { XMLValidationSchema schema = parseW3CSchema(SCHEMA_INT);