Take the 2-minute tour ×

I am having problems using a schema in either DTD or XSD format to validate XML returned to JMeter.

The error code I am getting is this.

Assertion error: true
Assertion failure: false
Assertion failure message: error: line=1 col=71 schema_reference.4: Failed to read schema document 'schema.dtd', because 
1) could not find the document; 
2) the document could not be read; 

I have made sure the schema is in this same location as the Jmeter test and is not read only etc.

Sample DTD

<!ELEMENT recordId (#PCDATA)>
<!ELEMENT operationDateTime (#PCDATA)>
<!ELEMENT operationCode (#PCDATA)>
<!ELEMENT listOfAuditItems ((auditItem))>
<!ELEMENT fieldName (#PCDATA)>
<!ELEMENT buscomp (#PCDATA)>
<!ELEMENT auditItem ((recordId, userId, operationCode, buscomp, operationDateTime, fieldName, oldVal, newVal))>
<!ELEMENT ariResponse ((listOfAuditItems))>

I checked the validity of the DTD file here and it passed!

Sample XML

                <buscomp>Service Request</buscomp>
                <fieldName />
                <oldVal />
                <newVal />
        <errormessage />


share|improve this question
Look into this one: Relative path for JMeter XML Schema? - seems to be your case. –  Alies Belik Nov 20 '12 at 15:12
Your DTD does not seem to match your message, returnCode and errormessage are not in it –  PMD UBIK-INGENIERIE Nov 20 '12 at 22:10
Ah sorry, I was changing my XML after this problem occurred. Sorry for the confusion! –  loosebruce Nov 21 '12 at 9:58

1 Answer 1

up vote 0 down vote accepted

Summary: in the end I've used http://path.to.schema/myschema.xsd as the File Name parameter in the Assertion.

Explanation: following Alies Belik's advice, I've found that the code for setting up the schema looks something like this:

DocumentBuilderFactory parserFactory = DocumentBuilderFactory.newInstance();
parserFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", xsdFileName);

where xsdFileName is a string (the attribute string is actually a constant, I inlined it for readability).

According to e.g. this page, the attribute, when in the form a String, is interpreted as an URI - which includes HTTP URLs. Since I already have the schema accessible through HTTP, I've opted for this solution.

share|improve this answer

Your Answer


