将数组添加到 XSD 文件以将用户分配给权限规范

发布于 2024-09-16 12:29:59 字数 538 浏览 3 评论 0原文

我不是程序员,所以这可能有意义也可能没有意义,但我希望能够将外部数据文件链接到 XSD 文件以指定用户是否属于某个组。

如果没有链接,代码当前表示为:

<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>

当由此创建 XML 文件时,用户必须来自列出的值之一。

我不想在 XSD 文件中列出各种枚举值,而是想链接到一个可以轻松更新以将允许的用户添加到 XSD 文件的外部文件。

I am not a programmer, so this may or may not make sense, but I would like 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蓝梦月影 2024-09-23 12:29:59

这在 XML 模式中是不可能的。选择是在模式内部进行枚举(但随后很难添加值)或编写额外的外部验证代码(但随后您需要编写代码)。

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).

网白 2024-09-23 12:29:59

您能解释一下该架构是如何使用的吗?这可能有助于为您找到一个好的解决方案。

但 xcut 是对的,一般答案是你所要求的东西无法完成。当然,除了

 <xs:enumeration value="user4">

当您有新用户时粘贴到架构中,这实际上非常简单......

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...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文