OSDN Git Service

2611f9eab4118f94649ccf80a7e69d7adb88ed28
[tpi/lychee.git] / doc / schema.xsl
1 <?xml version="1.0" encoding="utf-8"?>\r
2 <xsl:stylesheet version="1.0"\r
3   xmlns    ="http://www.w3.org/1999/xhtml"\r
4   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"\r
5   xmlns:xs ="http://www.w3.org/2001/XMLSchema">\r
6 <xsl:template match="/">\r
7  <xsl:apply-templates select="xs:schema" />\r
8 </xsl:template>\r
9 \r
10 <xsl:template match="xs:schema">\r
11  <html xml:lang="ja">\r
12   <head>\r
13    <title>XML Schema</title>\r
14    <meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />\r
15    <link rel="stylesheet" href="style.css" type="text/css" />\r
16   </head>\r
17   <body>\r
18    <h1>XML Schema</h1>\r
19 \r
20   <ul id="menu">\r
21    <li><a href="readme.html">Readme</a></li>\r
22    <li><a href="files.html">Files</a></li>\r
23    <li><a href="history.html">History</a></li>\r
24    <li><a href="api/index.html">TPI spec</a></li>\r
25    <li>XML spec</li>\r
26    <li><a href="license.txt">License</a></li>\r
27    <li><br /></li>\r
28    <li>XML spec:</li>\r
29    <li><a href="#element">Element</a></li>\r
30    <li><a href="#complex">Complex type</a></li>\r
31    <li><a href="#simple">Simple type</a></li>\r
32    <li><a href="#attrgrp">Attribute group</a></li>\r
33   </ul>\r
34 \r
35    <h2 id="element">Element</h2>\r
36    <xsl:apply-templates select="xs:element" />\r
37    <h2 id="complex">Complex type</h2>\r
38    <xsl:apply-templates select="xs:complexType" />\r
39    <h2 id="simple">Simple type</h2>\r
40    <xsl:apply-templates select="xs:simpleType" />\r
41    <h2 id="attrgrp">Attribute group</h2>\r
42    <xsl:apply-templates select="xs:attributeGroup" />\r
43   </body>\r
44  </html>\r
45 </xsl:template>\r
46 \r
47 <xsl:template name="base">\r
48  <h3>\r
49   <xsl:attribute name="id">\r
50    <xsl:value-of select="@name" />\r
51   </xsl:attribute>\r
52   <xsl:value-of select="@name" />\r
53  </h3>\r
54  <div style="white-space:pre">\r
55   <xsl:value-of select="xs:annotation/xs:documentation" />\r
56  </div>\r
57  <xsl:apply-templates select="xs:sequence" />\r
58 </xsl:template>\r
59 \r
60 <xsl:template name="type">\r
61  <xsl:choose>\r
62   <xsl:when test="@type='xs:string'">(string)</xsl:when>\r
63   <xsl:when test="@type='xs:int'">(int)</xsl:when>\r
64   <xsl:when test="@type='xs:boolean'">(bool)</xsl:when>\r
65   <xsl:otherwise>\r
66    <a>\r
67     <xsl:attribute name="href">#<xsl:value-of select="@type" /></xsl:attribute>\r
68     <xsl:value-of select="@type" />\r
69    </a>\r
70   </xsl:otherwise>\r
71  </xsl:choose>\r
72 </xsl:template>\r
73 \r
74 <xsl:template name="attributes">\r
75  <xsl:if test="count(xs:attribute)!=0">\r
76  <table>\r
77   <colgroup span="1" />\r
78   <colgroup>\r
79    <col span="1" style="text-align: center" />\r
80    <col span="1" style="text-align: right" />\r
81   </colgroup>\r
82   <thead>\r
83    <tr><th>attribute</th><th>type</th><th>default</th><th>description</th></tr>\r
84   </thead>\r
85   <tbody>\r
86    <xsl:for-each select="xs:attribute">\r
87     <tr>\r
88      <td>\r
89       <xsl:if test="@use='required'">\r
90        <xsl:attribute name="style">color: red</xsl:attribute>\r
91        <xsl:attribute name="title">Required</xsl:attribute>\r
92       </xsl:if>\r
93       <xsl:value-of select="@name" />\r
94      </td>\r
95      <td><xsl:call-template name="type" /></td>\r
96      <td><xsl:value-of select="@default" /></td>\r
97      <td><xsl:value-of select="xs:annotation/xs:documentation" /></td>\r
98     </tr>\r
99    </xsl:for-each>\r
100    <xsl:if test="count(xs:attributeGroup)!=0">\r
101     <tr>\r
102      <td colspan="4">\r
103       Attribute group: \r
104       <xsl:for-each select="xs:attributeGroup">\r
105        <a>\r
106         <xsl:attribute name="href">#<xsl:value-of select="@ref" /></xsl:attribute>\r
107         <xsl:value-of select="@ref" />\r
108        </a>\r
109        <xsl:if test="position()!=last()">, </xsl:if>\r
110       </xsl:for-each>\r
111      </td>\r
112     </tr>\r
113    </xsl:if>\r
114   </tbody>\r
115  </table>\r
116  </xsl:if>\r
117 </xsl:template>\r
118 \r
119 <xsl:template match="xs:simpleType">\r
120  <xsl:call-template name="base" />\r
121  <h4>Restriction</h4>\r
122  <p>Derived from <xsl:value-of select="xs:restriction/@base" />.</p>\r
123 </xsl:template>\r
124 \r
125 <xsl:template match="xs:complexType">\r
126  <xsl:call-template name="base" />\r
127  <xsl:call-template name="attributes" />\r
128 </xsl:template>\r
129 \r
130 <xsl:template match="xs:attributeGroup">\r
131  <xsl:call-template name="base" />\r
132  <xsl:call-template name="attributes" />\r
133 </xsl:template>\r
134 \r
135 <xsl:template match="xs:element">\r
136  <xsl:call-template name="base" />\r
137  <p>Type is <xsl:call-template name="type" />.</p>\r
138 </xsl:template>\r
139 \r
140 <xsl:template match="xs:sequence">\r
141  <h4>Children</h4>\r
142  <table>\r
143   <thead>\r
144    <tr><th>name</th><th>min</th><th>max</th></tr>\r
145   </thead>\r
146   <tbody>\r
147    <xsl:for-each select="xs:element">\r
148     <tr>\r
149      <td>\r
150       <a>\r
151        <xsl:attribute name="href">#<xsl:value-of select="@ref" /></xsl:attribute>\r
152        <xsl:value-of select="@ref" />\r
153       </a>\r
154      </td>\r
155      <td><xsl:value-of select="@minOccurs" /></td>\r
156      <td><xsl:value-of select="@maxOccurs" /></td>\r
157     </tr>\r
158    </xsl:for-each>\r
159   </tbody>\r
160  </table>\r
161 </xsl:template>\r
162 \r
163 </xsl:stylesheet>