我在使用DTD或XSD格式的模式来验证返回给 JMeter 的 XML 时遇到问题。
我得到的错误代码是这样的。
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;
3) the root element of the document is not <xsd:schema>.
我已确保架构与 Jmeter 测试位于同一位置,并且不是只读等。
示例 DTD
<!ELEMENT userId (#PCDATA)>
<!ELEMENT recordId (#PCDATA)>
<!ELEMENT operationDateTime (#PCDATA)>
<!ELEMENT operationCode (#PCDATA)>
<!ELEMENT oldVal (#PCDATA)>
<!ELEMENT newVal (#PCDATA)>
<!ELEMENT listOfAuditItems ((auditItem))>
<!ELEMENT fieldName (#PCDATA)>
<!ELEMENT buscomp (#PCDATA)>
<!ELEMENT auditItem ((recordId, userId, operationCode, buscomp, operationDateTime, fieldName, oldVal, newVal))>
<!ELEMENT ariResponse ((listOfAuditItems))>
我在这里检查了DTD文件的有效性,它通过了!
示例 XML
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<ariResponse>
<listOfAuditItems>
<auditItem>
<recordId>2-1DFSGT</recordId>
<userId>1-1SJKJS</userId>
<operationCode>Modify</operationCode>
<buscomp>Service Request</buscomp>
<operationDateTime>2010-05-12T15:23:53.000+05:30</operationDateTime>
<fieldName />
<oldVal />
<newVal />
<auditLog>2*C311*EVT_STAT_CD16*TODO_PLAN_END_DT11*OWNER_LOGIN2*N34*Open19*2011-01-06
16:28:567*RITESHP2*O30*0*0*
</auditLog>
</auditItem>
</listOfAuditItems>
<returncode>0</returncode>
<errormessage />
</ariResponse>
谢谢!