XML/XSD-添加描述 [英] XML / XSD - Adding descriptions
问题描述
使用XSD可以确保XML文件有效,但是还有一种方法可以使用XSD将信息附加到元素和属性,以便打开XML和XSD文件的软件可以显示当用户单击所描述的元素时向用户显示该描述?
With XSD I can make sure that an XML file is valid, but is there also a way, using XSD, to attach informations to elements and properties so that a software that would open the XML and XSD file would be able to display that description to the user when he clicks on the element being described?
推荐答案
您正在描述 xsd:documentation
元素.
You're describing the xsd:documentation
element.
xsd:documentation
和 xsd:appinfo
都可以包含在 xsd:annotation
元素中:
Both xsd:documentation
and xsd:appinfo
can be included within an xsd:annotation
element:
- 使用
xsd:documentation
将元信息提供给 用户 . - 使用
xsd:appinfo
将元信息提供给 应用 .
- Use
xsd:documentation
to provide meta information to a user. - Use
xsd:appinfo
to provide meta information to a application.
W3C XML模式第0部分:入门第二版介绍了批注此处,其中提供了以下有关如何使用 xsd的示例:文档
:
The W3C XML Schema Part 0: Primer Second Edition has an introduction to annotations here, where they provide the following example of how to use xsd:documentation
:
<xsd:element name="internationalPrice">
<xsd:annotation>
<xsd:documentation xml:lang="en">
element declared with anonymous type
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:annotation>
<xsd:documentation xml:lang="en">
empty anonymous type with 2 attributes
</xsd:documentation>
</xsd:annotation>
<xsd:complexContent>
<xsd:restriction base="xsd:anyType">
<xsd:attribute name="currency" type="xsd:string"/>
<xsd:attribute name="value" type="xsd:decimal"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
这篇关于XML/XSD-添加描述的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!