在 XSD 复杂类型中包含元素而不添加新元素
我有这个复杂类型:
<xsd:complexType name="Identifier">
<xsd:sequence>
<xsd:element name="Id" type="xsd:string"/>
<xsd:element name="Version" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
现在我想将其包含在另一个复杂类型中,并且我一直这样做:
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Id" type="Identifier"/>
<!-- More elements here -->
</xsd:sequence>
</xsd:complexType>
但这不是我真正想要的。我想将标识符类型的元素直接包含在我的第二个复杂类型中,而不创建新元素。例如,与这样做相同:
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Id" type="xsd:string"/>
<xsd:element name="Version" type="xsd:string"/>
<!-- More elements here -->
</xsd:sequence>
</xsd:complexType>
希望这是有道理的。
提前致谢。
I have this complex type:
<xsd:complexType name="Identifier">
<xsd:sequence>
<xsd:element name="Id" type="xsd:string"/>
<xsd:element name="Version" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
Now I want to include this in another complex type and I've been doing that like this:
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Id" type="Identifier"/>
<!-- More elements here -->
</xsd:sequence>
</xsd:complexType>
This isn't what I really want though. I want to include the Identifier type's elements directly in my second complex type without creating a new element. E.g. the same as just doing this:
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Id" type="xsd:string"/>
<xsd:element name="Version" type="xsd:string"/>
<!-- More elements here -->
</xsd:sequence>
</xsd:complexType>
Hope that makes sense.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
此复杂类型将始终解析为,
如果您不需要子结构,则
您可以将 Id 和 Version 定义为元素并在稍后使用时引用它们。但这样你就不能保证它们都会发生
你也可以将 Id 和 Version 属性设置为复杂类型中的 Identifier 元素,
祝你好运
麦克风
this complex type will always resolve to
if you don't want a child structure, you could define Id and Version as elements and reference them using
later on. But then you don't have the guarantee that they both occur
You can also make Id and Version attributes to the Identifier element in a complex type
good luck
Mike
您可以扩展类型,如下所示:
You can extend types, like this: