Sa I have two types of schemas, one for <Request>
and one for <Response>
. I have the schema xsd for both.
I want to be able to get the "type" of the schema, even if it is invalid. For example, <Request to2="">...
should be invalid, but I want to still know that this is a Request
.
The problem is $xml->schemaValidate(...)
will return false
for both of my schemas if the attributes are also wrong.
(this example is simplified, in reality, I can have multiple verbs for each schema types, so I don't want to iterate through the child nodes and check what the nodeType is).
Is there a way to use DOMDocument to validate the choice only (no attribute validation)?
For instance:
<Request>...</Request> ---> {type: 'Request', isValid: true},
<Response>...</Response> ---> {type: 'Response', isValid: true},
<Request to="api/action">...</Request> ---> {type: 'Request', isValid: true},
<Request tooo="api/action">...</Request> ---> {type: 'Request', isValid: false},
<Response type="json">...</Response> ---> {type: 'Response', isValid: true},
<Response typeeee="json">...</Response> ---> {type: 'Response', isValid: false},
If I juse use $xml->schemaValidate('/path/to/request.xsd');
and $xml->schemaValidate('/path/to/response.xsd');
I will not be able to determine the type of <Request tooo="api/action">...</Request>
and <Response typeeee="json">...</Response>
respectively because they are "invalid"
生成一个组合的XSD,根据它们的标签名称来验证这两种类型。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.