有没有办法从 XML 模式中删除幻数?

发布于 2024-09-15 17:08:17 字数 219 浏览 2 评论 0原文

我有一个 WSDL,其中定义了一些类型。某些元素接受元素列表,并且在服务返回上我也有带有值列表的元素(或其他元素)。

因此,我在 XSD 中有一些神奇的数字(例如 minOccurs="10"、maxOccurs="250" 等)。这些值 10、250 等在整个 XSD 类型中重复。

有没有办法将它们声明为某种常量?然后按名称重用它们作为 minOccurs 和 maxOccurs 属性?

I have a WSDL with some types defined. Some elements accept lists of elements and on the service return I also have elements with list of values (or other elements).

As a result I have some magic numbers in the XSD (e.g. minOccurs="10", maxOccurs="250" etc). These values 10, 250 etc are repeated throughout the XSD types.

Is there a way to declare them as some sort of constants? and then reuse them by name for the minOccurs and maxOccurs attributes?

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

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

发布评论

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

评论(2

甜`诱少女 2024-09-22 17:08:17

不,没有。您唯一可以做的就是在加载之前使用某种模板处理器来预处理模式。

No there isn't. The only thing you could do is to pre-process the schema using some sort of template processor before loading.

无法言说的痛 2024-09-22 17:08:17

XSD 是 XML,因此您可以使用 DTD 中定义的实体:

minOccurs="&minOccurs;"

XSD is XML so you could use entities defined in a DTD:

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