Posted to tcl by mjanssen at Fri Oct 30 13:41:06 GMT 2015view raw

  1. This:
  2.  
  3. text {<?xml version="1.0" encoding="UTF-8"?>}
  4. text {<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">}
  5. define root {
  6. item+
  7. }
  8. define item {
  9. part1!
  10. part2?
  11. part3
  12. }
  13. define part1 xsd:string
  14. define part2 xsd:decimal {This is optional}
  15. extension part3 xsd:normalizedString {{attr1 {this is attr1}}} {
  16. Complex stuff
  17. }
  18. text "</xsd:schema>"
  19.  
  20.  
  21. Becomes:
  22.  
  23. <?xml version="1.0" encoding="UTF-8"?>
  24. <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
  25. <xsd:element name="root" type="rootType"/>
  26. <xsd:complexType name="rootType">
  27. <xsd:sequence>
  28. <xsd:element minOccurs="1" maxOccurs="unbounded" ref="item"/>
  29. </xsd:sequence>
  30. </xsd:complexType>
  31. <xsd:element name="item" type="itemType"/>
  32. <xsd:complexType name="itemType">
  33. <xsd:sequence>
  34. <xsd:element minOccurs="1" maxOccurs="1" ref="part1"/>
  35. <xsd:element minOccurs="0" maxOccurs="1" ref="part2"/>
  36. <xsd:element ref="part3"/>
  37. </xsd:sequence>
  38. </xsd:complexType>
  39. <xsd:element name="part1" type="xsd:string"/>
  40. <xsd:element name="part2" type="xsd:decimal">
  41. <xsd:annotation>
  42. <xsd:documentation>This is optional</xsd:documentation>
  43. </xsd:annotation>
  44. </xsd:element>
  45. <xsd:element name="part3" type="part3Type"/>
  46. <xsd:complexType name="part3Type">
  47. <xsd:annotation>
  48. <xsd:documentation>
  49. Complex stuff
  50. </xsd:documentation>
  51. </xsd:annotation>
  52. <xsd:simpleContent>
  53. <xsd:extension base="xsd:normalizedString">
  54. <xsd:attribute name="attr1" use="optional">
  55. <xsd:annotation>
  56. <xsd:documentation>this is attr1</xsd:documentation>
  57. </xsd:annotation>
  58. </xsd:attribute>
  59. </xsd:extension>
  60. </xsd:simpleContent>
  61. </xsd:complexType>
  62. </xsd:schema>
  63.  
  64.