OSDN Git Service

書庫を作成する際にTPI内部のエンジンが存在するかどうかを確認していなかったバグを修正。
[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="#about">About</a></li>\r
30    <li><a href="#element">Element</a></li>\r
31    <li><a href="#complex">Complex type</a></li>\r
32    <li><a href="#simple">Simple type</a></li>\r
33    <li><a href="#attrgrp">Attribute group</a></li>\r
34   </ul>\r
35 \r
36    <h2 id="about">About</h2>\r
37    <p>This is schema file of TPI's common XML.</p>\r
38    <h2 id="element">Element</h2>\r
39    <xsl:apply-templates select="xs:element" />\r
40    <h2 id="complex">Complex type</h2>\r
41    <xsl:apply-templates select="xs:complexType" />\r
42    <h2 id="simple">Simple type</h2>\r
43    <xsl:apply-templates select="xs:simpleType" />\r
44    <h2 id="attrgrp">Attribute group</h2>\r
45    <xsl:apply-templates select="xs:attributeGroup" />\r
46   </body>\r
47  </html>\r
48 </xsl:template>\r
49 \r
50 <xsl:template name="base">\r
51  <h3>\r
52   <xsl:attribute name="id">\r
53    <xsl:value-of select="@name" />\r
54   </xsl:attribute>\r
55   <xsl:value-of select="@name" />\r
56  </h3>\r
57  <div style="white-space:pre">\r
58   <xsl:value-of select="xs:annotation/xs:documentation" />\r
59  </div>\r
60  <xsl:apply-templates select="xs:sequence" />\r
61 </xsl:template>\r
62 \r
63 <xsl:template name="type">\r
64  <xsl:choose>\r
65   <xsl:when test="@type='xs:string'">(string)</xsl:when>\r
66   <xsl:when test="@type='xs:int'">(int)</xsl:when>\r
67   <xsl:when test="@type='xs:boolean'">(bool)</xsl:when>\r
68   <xsl:otherwise>\r
69    <a>\r
70     <xsl:attribute name="href">#<xsl:value-of select="@type" /></xsl:attribute>\r
71     <xsl:value-of select="@type" />\r
72    </a>\r
73   </xsl:otherwise>\r
74  </xsl:choose>\r
75 </xsl:template>\r
76 \r
77 <xsl:template name="attributes">\r
78  <xsl:if test="count(xs:attribute)!=0">\r
79  <table>\r
80   <colgroup span="1" />\r
81   <colgroup>\r
82    <col span="1" style="text-align: center" />\r
83    <col span="1" style="text-align: right" />\r
84   </colgroup>\r
85   <thead>\r
86    <tr><th>attribute</th><th>type</th><th>default</th><th>description</th></tr>\r
87   </thead>\r
88   <tbody>\r
89    <xsl:for-each select="xs:attribute">\r
90     <tr>\r
91      <td>\r
92       <xsl:if test="@use='required'">\r
93        <xsl:attribute name="style">color: red</xsl:attribute>\r
94        <xsl:attribute name="title">Required</xsl:attribute>\r
95       </xsl:if>\r
96       <xsl:value-of select="@name" />\r
97      </td>\r
98      <td><xsl:call-template name="type" /></td>\r
99      <td><xsl:value-of select="@default" /></td>\r
100      <td><xsl:value-of select="xs:annotation/xs:documentation" /></td>\r
101     </tr>\r
102    </xsl:for-each>\r
103    <xsl:if test="count(xs:attributeGroup)!=0">\r
104     <tr>\r
105      <td colspan="4">\r
106       Attribute group: \r
107       <xsl:for-each select="xs:attributeGroup">\r
108        <a>\r
109         <xsl:attribute name="href">#<xsl:value-of select="@ref" /></xsl:attribute>\r
110         <xsl:value-of select="@ref" />\r
111        </a>\r
112        <xsl:if test="position()!=last()">, </xsl:if>\r
113       </xsl:for-each>\r
114      </td>\r
115     </tr>\r
116    </xsl:if>\r
117   </tbody>\r
118  </table>\r
119  </xsl:if>\r
120 </xsl:template>\r
121 \r
122 <xsl:template match="xs:simpleType">\r
123  <xsl:call-template name="base" />\r
124  <h4>Restriction</h4>\r
125  <p>Derived from <xsl:value-of select="xs:restriction/@base" />.</p>\r
126 </xsl:template>\r
127 \r
128 <xsl:template match="xs:complexType">\r
129  <xsl:call-template name="base" />\r
130  <xsl:call-template name="attributes" />\r
131 </xsl:template>\r
132 \r
133 <xsl:template match="xs:attributeGroup">\r
134  <xsl:call-template name="base" />\r
135  <xsl:call-template name="attributes" />\r
136 </xsl:template>\r
137 \r
138 <xsl:template match="xs:element">\r
139  <xsl:call-template name="base" />\r
140  <p>Type is <xsl:call-template name="type" />.</p>\r
141 </xsl:template>\r
142 \r
143 <xsl:template match="xs:sequence">\r
144  <h4>Children</h4>\r
145  <table>\r
146   <thead>\r
147    <tr><th>name</th><th>min</th><th>max</th></tr>\r
148   </thead>\r
149   <tbody>\r
150    <xsl:for-each select="xs:element">\r
151     <tr>\r
152      <td>\r
153       <a>\r
154        <xsl:attribute name="href">#<xsl:value-of select="@ref" /></xsl:attribute>\r
155        <xsl:value-of select="@ref" />\r
156       </a>\r
157      </td>\r
158      <td><xsl:value-of select="@minOccurs" /></td>\r
159      <td><xsl:value-of select="@maxOccurs" /></td>\r
160     </tr>\r
161    </xsl:for-each>\r
162   </tbody>\r
163  </table>\r
164 </xsl:template>\r
165 \r
166 </xsl:stylesheet>