开发者

XML Schema: How to validate an attribute with multiple keys concatenated?

开发者 https://www.devze.com 2023-01-24 03:38 出处:网络
Let\'s say I can get XML like this: <Property Name=\"Title\"/> <Property Name=\"Content\"/>

Let's say I can get XML like this:

<Property Name="Title"/>
<Property Name="Content"/>
<Property Name="Address"/>

<Source properties="Title,Content,Address"/>

How coud I validate the "properties" attribute of "Source", so that any composition of the above listed "Property" items could开发者_如何学Python be checked? (For example: "Title", "Title,Content", all of these concatenations are correct, while "Title, URL" is not correct.)


You can't do that within XML Schema. You can do it with your own higher level of validation based on XSLT, XQuery or Schematron, for example.


xan is right; validating always means, to match a XML file against a given schema. But there is no schema involved here, your problem is instead, to read a data file, and validate later entries against earlier ones (if the box above is supposed to represent one file) or one data file against another data file (if the gap is supposed to be a file separator). Beyond that, a schema defines the structure of elements and attributes and optionally data types (values only, if there is a strict enumeration of valid values). Also no match here, instead you want to verify data against data. Sorry, the tool of a schema mismatches the problem to solve.

0

精彩评论

暂无评论...
验证码 换一张
取 消