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

'Element <root> has no attribute "verbose"' not thrown from RepairingNsStreamWriter when validating against a DTD schema #190

Open
ppalaga opened this issue Jan 13, 2024 · 1 comment · May be fixed by #187

Comments

@ppalaga
Copy link
Contributor

ppalaga commented Jan 13, 2024

The same scenario is passing for ValidatingStreamReader in the following test:

public void testInvalidAttributeValue() throws Exception
{
final String DOC = "<root note='note' verbose='yes'/>\n";
final String INPUT_DTD =
"<!ELEMENT root ANY>\n"
+"<!ATTLIST root note CDATA #IMPLIED>\n"
;
XMLInputFactory f = getInputFactory();
setCoalescing(f, true);
XMLValidationSchemaFactory schemaFactory =
XMLValidationSchemaFactory.newInstance(XMLValidationSchema.SCHEMA_ID_DTD);
XMLValidationSchema schema = schemaFactory.createSchema(new StringReader(INPUT_DTD));
XMLStreamReader2 sr = (XMLStreamReader2)f.createXMLStreamReader(
new StringReader(DOC));
final List<XMLValidationProblem> probs = new ArrayList<XMLValidationProblem>();
sr.validateAgainst(schema);
sr.setValidationProblemHandler(new ValidationProblemHandler() {
@Override
public void reportProblem(XMLValidationProblem problem)
throws XMLValidationException {
probs.add(problem);
}
});
assertTokenType(START_ELEMENT, sr.next());
assertEquals("root", sr.getLocalName());
final String verboseValue = sr.getAttributeValue(null, "verbose");
assertEquals("yes", verboseValue);
}

When the test is adapted for SimpleNsStreamWriter it still works.

But when the test is adapted for RepairingNsStreamWriter it does not work anymore.

The PR with a reproducer follows.

@ppalaga
Copy link
Contributor Author

ppalaga commented Jan 13, 2024

RepairingNsStreamWriter perhaps has a general problem with attribute access, because it does not see a required attribute that is set in the input document.
This can be reproduced by adapting wstxtest.vstream.TestRelaxNG.testPartialValidationOk() a reproducer PR follows.

ppalaga added a commit to ppalaga/woodstox that referenced this issue Jan 13, 2024
…verbose"' not thrown from RepairingNsStreamWriter when validating against a DTD schema
ppalaga added a commit to ppalaga/woodstox that referenced this issue Jan 13, 2024
…verbose"' not thrown from RepairingNsStreamWriter when validating against a DTD schema
ppalaga added a commit to ppalaga/woodstox that referenced this issue Jan 14, 2024
</nl:nillableIntElement>) when validating a document with nillable
elements fix FasterXML#179 fix FasterXML#190
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant