Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing closing quote for attribute values during in Validating output mode #88

Merged
merged 1 commit into from
Nov 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/com/ctc/wstx/sw/BufferingXmlWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
29 changes: 29 additions & 0 deletions src/test/java/wstxtest/msv/TestW3CSchemaTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ public class TestW3CSchemaTypes
+"\n</xsd:schema>"
;

final static String SCHEMA_ATTRIBUTE =
"<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'>\n"
+"<xsd:element name='price'>\n"
+"<xsd:complexType>\n"
+"<xsd:attribute name='amount' type='xsd:int' use='required'/>\n"
+"</xsd:complexType>\n"
+"</xsd:element>\n"
+"</xsd:schema>"
;

// // // First 'int' datatype

public void testSimpleValidInt() throws Exception
Expand Down Expand Up @@ -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);
Expand Down