如何为复合类型创建模式?
我有一个如下所示的 XML 规范:
<Root>
<Directory Name="SomeName">
<TextFile Name="ExampleDocument.txt>This is the content of my sample text file.</TextFile>
<Directory Name="SubDirectory">
<Speech Name="Example Canned Speech">
...
</Speech>
</Directory>
</Directory>
</Root>
请注意,Directory
元素可以包含其他 Directory
元素。我如何使用 W3C 架构来表示它?
I have an XML spec that looks like this:
<Root>
<Directory Name="SomeName">
<TextFile Name="ExampleDocument.txt>This is the content of my sample text file.</TextFile>
<Directory Name="SubDirectory">
<Speech Name="Example Canned Speech">
...
</Speech>
</Directory>
</Directory>
</Root>
Note that Directory
elements can contain other Directory
elements. How can I represent that using W3C Schema?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要创建一个递归
来表示您的
类型。根据您提供的元素,以下是此技术的示例。You need to create a recursive
<complexType>
to represent your<Directory>
type. The following is an example of this technique, given the elements you provided.这应该可以做到(您可能希望将名称限制在
xs:string
之外):测试于:
This should do it (you may want to restrict names further than to
xs:string
):Tested on: