依照以下条件写出合适的XML Schema.

前端之家收集整理的这篇文章主要介绍了依照以下条件写出合适的XML Schema.前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

依照以下条件写出合适的XML Schema.

(1)父元素为Motorcycle.

(2)元素有一个属性名称为motorid,类型为正整数,且一定要输入.

(3)一个Brand子元素,类型为字符串,记录摩托车品牌.

(4)一个Date子元素,类型为日期,记录购买日期.

(5)一个Owner子元素,类型为字符串,记录摩托车所有人姓名.

Reg:

  1. motorcycle.xml
  2. -----------
  3. <motorcycle motorid="10">
  4. <Brand>豪爵摩托</Brand>
  5. <Date>2014-12-25</Date>
  6. <Owner>罗嘉欣</Owner>
  7. </motorcycle>
  8.  
  9.  
  10. motorcycle.xsd
  11.  
  12. <?xml version="1.0"?>
  13. <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  14.  
  15. <xsd:element name="motorcycle">
  16. <xsd:complexType>
  17. <xsd:sequence>
  18. <xsd:element name="Brand" type="xsd:string" />
  19. <xsd:element name="Data" type="xsd:data"/>
  20. <xsd:element name="Owner" type="xsd:string" />
  21. </xsd:sequence>
  22. <!-- 增加属性定义 -->
  23. <xsd:attribute name="motorid" type="xsd:integer" use="required"/>
  24. </xsd:complexType>
  25. </xsd:element>
  26.  
  27. </xsd:schema>

猜你在找的XML相关文章