Add an array to an XSD file to assign users to a permissions specification
I am not a programmer, so this may or may not make sense, but I would like 开发者_JAVA百科to be able to link an external data file to an XSD file to specify whether a user belongs to a certain group.
Without linking, the code currently stands as:
<xs:element name="user">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="user1">
<xs:enumeration value="user2">
<xs:enumeration value="user3">
</xs:restriction>
</xs:simpleType>
</xs:element>
When an XML file is created from this, a user must be from one of the values listed.
Instead of listing the various enumeration values in the XSD file, I would like to link to an external file that can be be easily updated to add allowable users to the XSD file.
This is not possible in XML Schema. The choice is between enumeration inside the schema (but then it's hard to add values) or writing additional external validation code (but then you have code to write).
Could you explain how the schema is being used? That may help in finding a good solution for you.
But the xcut is right, the general answer is that what you're asking for can't be done. Except of course by pasting
<xs:enumeration value="user4">
into the schema when you have a new user, which is actually pretty easy...
精彩评论