2015-01-21 115 views
1

使用XSD我可以確保XML文件是有效的,但是還有一種方法(使用XSD)將信息附加到元素和屬性,以便打開XML和XSD的軟件文件能夠在點擊所描述的元素時向用戶顯示該描述?XML/XSD - 添加描述

+0

您可能正在尋找[註釋](https://msdn.microsoft .com/en-us/library/ms256102%28v = vs.110%29.aspx)元素。 – Filburt 2015-01-21 10:49:38

回答

4

您正在描述xsd:documentation元素。

xsd:documentation都和xsd:appinfo可以包括一個xsd:annotation元件內:

  • 使用xsd:documentation以向用戶提供元信息。
  • 使用xsd:appinfo提供元信息給應用程序

W3C XML Schema Part 0: Primer Second Edition有介紹註釋here,在那裏他們提供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> 
+0

但是,當然,要找出是否有任何特定的編輯器使用此信息,您需要檢查該特定編輯器的文檔。 – 2015-01-21 15:05:05