有什么方法可以让架构在其结构中使用用户定义的元素吗?
我想知道是否可以让模式使用用户定义的元素(来自 XML)作为其结构。
就像作为用户一样,我将能够拥有类似的内容:
<subjectType>
<name>plane</name>
<name>bird</name>
</subjectType>
<questionType>
<name>organic</name>
<name>awesome</name>
</questionType>
<subjectInterview subjectType="plane">
<question questionType="organic">false</question>
<question questionType="awesome">true</question>
</subjectInterview>
<subjectInterview subjectType="bird">
<question questionType="organic">true</question>
<question questionType="awesome">false</question>
</subjectInterview>
因此模式将了解:
- subjectType
- QuestionType
- subjectInterview
- Question
但不知道用户定义的子元素。 它将理解元素如何相互嵌套并具有其他限制(它将像枚举一样对待用户定义的值,以防止拼写错误并防止每个 subjectType 出现重复的 QuestionType)。
我将如何在架构中强制执行这种类型的用户定义内容?
编辑:如果重要的话,我还计划将用户定义的 xml 解组为 java 类。
谢谢
I'm wondering if it's possible to have a schema use user-defined elements (from the XML) for its structure.
As in, as a user, I would be able to have something like:
<subjectType>
<name>plane</name>
<name>bird</name>
</subjectType>
<questionType>
<name>organic</name>
<name>awesome</name>
</questionType>
<subjectInterview subjectType="plane">
<question questionType="organic">false</question>
<question questionType="awesome">true</question>
</subjectInterview>
<subjectInterview subjectType="bird">
<question questionType="organic">true</question>
<question questionType="awesome">false</question>
</subjectInterview>
So the schema would know about:
- subjectType
- questionType
- subjectInterview
- question
but not the user-defined sub-elements.
It would understand how the elements nest in relation to each other and have other restrictions (it would treat the user-defined values like enums to prevent typos and prevent duplicate questionType's per subjectType).
How would I go about getting this type of user-defined content to be enforced in a schema?
edit: If it matters, I also plan on unmarshalling the user-defined xml to java classes.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的 - 发现我必须在架构中使用“key”和“keyref”。
首先-修改后的 XML 文件:
这是架构:
对于尝试做同样事情的人来说应该是一个不错的基础。
Ok - found out that I have to use "key" and "keyref" in the schema.
First- a modified XML file:
and here's the schema:
Should be a decent base for people trying to do the same.