Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

496 lines
16 KiB

  1. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
  2. xmlns="http://www.w3.org/1999/XMLSchema"
  3. xmlns:xdr = "urn:schemas-microsoft-com:xml-data"
  4. xmlns:s = "namespace-for-this-schema"
  5. xmlns:dt = "urn:schemas-microsoft-com:datatypes" xmlns:msxsl="urn:schemas-microsoft-com:xslt"
  6. xmlns:local="#local-functions">
  7. <xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
  8. <xsl:template match="node()"/>
  9. <!-- document converion template -->
  10. <xsl:template match="/">
  11. <xsl:comment>
  12. [XDR-XDS] This schema automatically updated from an IE5-compatible XDR schema to W3C
  13. XML Schema.
  14. </xsl:comment>
  15. <xsl:text disable-output-escaping="yes"><![CDATA[
  16. <!DOCTYPE schema SYSTEM "xsd.dtd">
  17. ]]></xsl:text>
  18. <xsl:apply-templates select="@*|node()"/>
  19. </xsl:template>
  20. <xsl:template match="xdr:Schema">
  21. <schema version="1.0">
  22. <xsl:if test="@name">
  23. <annotation>
  24. <documentation>Schema name: <xsl:value-of select="@name"/></documentation>
  25. </annotation>
  26. </xsl:if>
  27. <xsl:if test="*[not(self::xdr:*)]">
  28. <annotation>
  29. <xsl:for-each select="*[not(self::xdr:*)]">
  30. <appinfo>
  31. <xsl:copy-of select="."/>
  32. </appinfo>
  33. </xsl:for-each>
  34. </annotation>
  35. </xsl:if>
  36. <!-- BUGBUG not completed yet
  37. <xsl:for-each select=".//s:attribute[contains(@type,':')] | .//s:element[contains(@type,':')]">
  38. <import schemaLocation="{@type}"/>
  39. </xsl:for-each>
  40. -->
  41. <xsl:apply-templates select="node()">
  42. <xsl:sort select="not(self::xdr:description)"/>
  43. </xsl:apply-templates>
  44. <xsl:comment> XDR datatype derivations </xsl:comment>
  45. <xsl:if test="//@dt:type='fixed.14.4'">
  46. <simpleType name="fixed.14.4" base="decimal">
  47. <scale value="4"/>
  48. <minInclusive value="-922337203685477.5808"/>
  49. <maxInclusive value="922337203685477.5807"/>
  50. </simpleType>
  51. </xsl:if>
  52. <xsl:if test="//@dt:type='bin.base64'">
  53. <simpleType name="bin.base64" base="binary" >
  54. <encoding value="base64"/>
  55. <!---data encoded in Base64 notation -->
  56. </simpleType>
  57. </xsl:if>
  58. <xsl:if test="//@dt:type='bin.hex'">
  59. <simpleType name="bin.hex" base="binary" >
  60. <encoding value="hex"/>
  61. </simpleType>
  62. </xsl:if>
  63. <xsl:if test="//@dt:type='boolean'">
  64. <simpleType name="ISOBoolean" base="boolean">
  65. <enumeration value="0"/> <!--False -->
  66. <enumeration value="1"/> <!--True -->
  67. </simpleType>
  68. </xsl:if>
  69. <xsl:if test="//@dt:type='char'">
  70. <simpleType name="char" base="string">
  71. <length value="1"/>
  72. </simpleType>
  73. </xsl:if>
  74. <xsl:if test="//@dt:type='i1'">
  75. <simpleType name="i1" base="integer">
  76. <minInclusive value="-128"/>
  77. <maxInclusive value="127"/>
  78. </simpleType>
  79. </xsl:if>
  80. <xsl:if test="//@dt:type='i2'">
  81. <simpleType name="i2" base="integer">
  82. <minInclusive value="-32768"/>
  83. <maxInclusive value="32767"/>
  84. </simpleType>
  85. </xsl:if>
  86. <xsl:if test="//@dt:type='i4'">
  87. <simpleType name="i4" base="integer">
  88. <minInclusive value="-2147483648"/>
  89. <maxInclusive value="2147483647"/>
  90. </simpleType>
  91. </xsl:if>
  92. <xsl:if test="//@dt:type='i8'">
  93. <simpleType name="i8" base="integer">
  94. <minInclusive value="-9223372036854775808"/>
  95. <maxInclusive value="9223372036854775807"/>
  96. </simpleType>
  97. </xsl:if>
  98. <xsl:if test="//@dt:type='ui1'">
  99. <simpleType name="ui1" base="non-negative-integer">
  100. <minInclusive value="0"/>
  101. <maxInclusive value="255"/>
  102. </simpleType>
  103. </xsl:if>
  104. <xsl:if test="//@dt:type='ui2'">
  105. <simpleType name="ui2" base="non-negative-integer">
  106. <minInclusive value="0"/>
  107. <maxInclusive value="65535"/>
  108. </simpleType>
  109. </xsl:if>
  110. <xsl:if test="//@dt:type='ui4'">
  111. <simpleType name="ui4" base="non-negative-integer">
  112. <minInclusive value="0"/>
  113. <maxInclusive value="4294967295"/>
  114. </simpleType>
  115. </xsl:if>
  116. <xsl:if test="//@dt:type='ui8'">
  117. <simpleType name="ui8" base="non-negative-integer">
  118. <minInclusive value="0"/>
  119. <maxInclusive value="18446744073709551615"/>
  120. </simpleType>
  121. </xsl:if>
  122. <xsl:if test="//@dt:type='r4'">
  123. <simpleType name="r4" base="float">
  124. <minInclusive value="-3.40282347E+38" />
  125. <maxInclusive value="3.40282347E+38" />
  126. </simpleType>
  127. </xsl:if>
  128. <xsl:if test="//@dt:type='date'">
  129. <simpleType name="date" base="timeInstant">
  130. <pattern value="\d*-\d\d-\d\d"/>
  131. <!---CCYY-MM-DD -->
  132. </simpleType>
  133. </xsl:if>
  134. <xsl:if test="//@dt:type='dateTime'">
  135. <simpleType name="dateTime" base="timeInstant">
  136. <pattern value="\d*-\d\d-\d\dT\d\d:\d\d(:\d\d(\.\d{{0,9}})?)?"/>
  137. <!---CCYY-MM-DDTHH:MM:SS.fffffffff Note no time zone. -->
  138. </simpleType>
  139. </xsl:if>
  140. <xsl:if test="//@dt:type='dateTime.tz'">
  141. <simpleType name="dateTime.tz" base="timeInstant">
  142. <pattern value="\d*-\d\d-\d\dT\d\d:\d\d(:\d\d(\.\d{{0,9}})?)?(\+|-)\d\d:\d\d"/>
  143. <!---CCYY-MM-DDTHH:MM:SS.fffffffff+HH:MM Note required time zone.-->
  144. </simpleType>
  145. </xsl:if>
  146. <xsl:if test="//@dt:type='time'">
  147. <simpleType name="time" base="timeInstant">
  148. <pattern value="\d\d:\d\d(:\d\d)?"/>
  149. <!---HH:MM:SS Note no time zone. -->
  150. </simpleType>
  151. </xsl:if>
  152. <xsl:if test="//@dt:type='time.tz'">
  153. <simpleType name="time.tz" base="timeInstant">
  154. <pattern value="\d\d:\d\d(:\d\d)?(\+|-)\d\d:\d\d"/>
  155. <!---HH:MM:SS+HH:MM Note required time zone -->
  156. </simpleType>
  157. </xsl:if>
  158. <xsl:if test="//@dt:type='Number'">
  159. <simpleType name="Number" base="string">
  160. <pattern value="(\+|-)?\d*(\.\d*)?((e|E)(\+|-)\d+)?" />
  161. <!--contentValues>
  162. <value>-Inf</value>
  163. <value>Inf</value>
  164. <value>*</value>
  165. </contentValues-->
  166. </simpleType>
  167. </xsl:if>
  168. <xsl:if test="//@dt:type='uuid'">
  169. <simpleType name="uuid" base="string">
  170. <pattern value="[0-9A-F]{{8}}\-?[0-9A-F]{{4}}\-?[0-9A-F]{{4}}\-?[0-9A-F]{{4}}\-?[0-9A-F]{{12}}"/>
  171. </simpleType>
  172. </xsl:if>
  173. </schema>
  174. </xsl:template>
  175. <!-- element conversion templates -->
  176. <xsl:template match="*" mode="ElementTypeContent">
  177. <xsl:apply-templates select="xdr:description"/>
  178. <xsl:apply-templates select="xdr:element | xdr:group"/>
  179. </xsl:template>
  180. <xsl:template match="xdr:ElementType[*]">
  181. <element name="{@name}">
  182. <xsl:if test="*[not(self::xdr:*)]">
  183. <annotation>
  184. <xsl:for-each select="*[not(self::xdr:*)]">
  185. <appinfo><xsl:copy-of select="."/></appinfo>
  186. </xsl:for-each>
  187. </annotation>
  188. </xsl:if>
  189. <complexType>
  190. <xsl:choose>
  191. <xsl:when test="@content='textOnly' or @content='empty' or @content='mixed'">
  192. <xsl:apply-templates select="@content"/>
  193. <xsl:if test="@context='mixed' and (@order='one' or @order='seq')">
  194. <xsl:comment>
  195. ****Warning!****
  196. Original schema illegally combined content="mixed" and @order="<xsl:value-of select="@order"/>".
  197. Treating this as order='many' instead.
  198. </xsl:comment>
  199. </xsl:if>
  200. <xsl:apply-templates select="." mode="ElementTypeContent"/>
  201. </xsl:when>
  202. <xsl:when test="@content='eltOnly'">
  203. <xsl:apply-templates select="@content"/>
  204. <xsl:choose>
  205. <xsl:when test="@order='one'">
  206. <choice>
  207. <xsl:apply-templates select="." mode="ElementTypeContent"/>
  208. </choice>
  209. </xsl:when>
  210. <xsl:when test="@order='seq'">
  211. <sequence>
  212. <xsl:apply-templates select="." mode="ElementTypeContent"/>
  213. </sequence>
  214. </xsl:when>
  215. <xsl:when test="@order='many'">
  216. <choice minOccurs="0" maxOccurs="*">
  217. <xsl:apply-templates select="." mode="ElementTypeContent"/>
  218. </choice>
  219. </xsl:when>
  220. <xsl:otherwise>
  221. <sequence>
  222. <xsl:apply-templates select="." mode="ElementTypeContent"/>
  223. </sequence>
  224. </xsl:otherwise>
  225. </xsl:choose>
  226. </xsl:when>
  227. <xsl:when test="@order='one'">
  228. <xsl:attribute name="content">elementOnly</xsl:attribute>
  229. <choice>
  230. <xsl:apply-templates select="." mode="ElementTypeContent"/>
  231. </choice>
  232. </xsl:when>
  233. <xsl:when test="@order='seq'">
  234. <xsl:attribute name="content">elementOnly</xsl:attribute>
  235. <sequence>
  236. <xsl:apply-templates select="." mode="ElementTypeContent"/>
  237. </sequence>
  238. </xsl:when>
  239. <xsl:otherwise>
  240. <xsl:attribute name="content">mixed</xsl:attribute>
  241. <xsl:apply-templates select="." mode="ElementTypeContent"/>
  242. </xsl:otherwise>
  243. </xsl:choose>
  244. <xsl:if test="not(@model='closed')">
  245. <any namespace="##other"/>
  246. </xsl:if>
  247. <xsl:apply-templates select="node()[not(self::xdr:element or self::xdr:group or self::xdr:description or self::xdr:datatype)]"/>
  248. </complexType>
  249. </element>
  250. </xsl:template>
  251. <xsl:template match="xdr:ElementType">
  252. <element name="{@name}">
  253. <xsl:choose>
  254. <xsl:when test="@dt:type">
  255. <xsl:apply-templates select="@dt:type"/>
  256. </xsl:when>
  257. <xsl:otherwise>
  258. <xsl:attribute name="type">string</xsl:attribute>
  259. </xsl:otherwise>
  260. </xsl:choose>
  261. <xsl:if test="node()"><xsl:apply-templates/></xsl:if>
  262. </element>
  263. </xsl:template>
  264. <xsl:template match="xdr:element">
  265. <element ref="{@type}">
  266. <xsl:apply-templates select="@minOccurs | @maxOccurs"/>
  267. <xsl:if test="*[not(self::xdr:*)]">
  268. <annotation>
  269. <xsl:for-each select="*[not(self::xdr:*)]">
  270. <appinfo><xsl:copy-of select="."/></appinfo>
  271. </xsl:for-each>
  272. </annotation>
  273. </xsl:if>
  274. </element>
  275. </xsl:template>
  276. <xsl:template match="xdr:AttributeType"/>
  277. <xsl:template match="xdr:attribute">
  278. <attribute name="{@type}">
  279. <xsl:variable name="definition" select="ancestor::*[xdr:AttributeType/@name = current()/@type][1]/xdr:AttributeType[@name = current()/@type]"/>
  280. <xsl:choose>
  281. <xsl:when test="@default"><xsl:apply-templates select="@default"/></xsl:when>
  282. <xsl:otherwise><xsl:apply-templates select="$definition/@default"/></xsl:otherwise>
  283. </xsl:choose>
  284. <xsl:choose>
  285. <xsl:when test="@required"><xsl:apply-templates select="@required"/></xsl:when>
  286. <xsl:otherwise><xsl:apply-templates select="$definition/@required"/></xsl:otherwise>
  287. </xsl:choose>
  288. <xsl:apply-templates select="$definition/@dt:type | $definition/xdr:datatype"/>
  289. <!-- description and annotations -->
  290. <xsl:if test="$definition/*[not(self::xdr:*)] | $definition/xdr:description">
  291. <annotation>
  292. <xsl:for-each select="$definition/xdr:description">
  293. <documentation><xsl:copy-of select="node()"/></documentation>
  294. </xsl:for-each>
  295. <xsl:for-each select="$definition/*[not(self::xdr:*)]">
  296. <appinfo><xsl:copy-of select="."/></appinfo>
  297. </xsl:for-each>
  298. </annotation>
  299. </xsl:if>
  300. </attribute>
  301. </xsl:template>
  302. <xsl:template match="xdr:description"/>
  303. <xsl:template match="xdr:description[1]">
  304. <annotation>
  305. <!-- collect multiple descriptions into a single annotation -->
  306. <xsl:for-each select="../xdr:description">
  307. <documentation><xsl:copy-of select="node()"/></documentation>
  308. </xsl:for-each>
  309. </annotation>
  310. </xsl:template>
  311. <xsl:template match="xdr:group">
  312. <xsl:variable name="inherited-order">
  313. <xsl:choose>
  314. <xsl:when test="ancestor-or-self::group[@order]">
  315. <xsl:value-of select="ancestor-or-self::group[@order]/@order"/>
  316. </xsl:when>
  317. <xsl:when test="ancestor::xdr:ElementType[@order]">
  318. <xsl:value-of select="ancestor::xdr:ElementType[@order]/@order"/>
  319. </xsl:when>
  320. <xsl:when test="ancestor::xdr:ElementType/@content='eltOnly'">seq</xsl:when>
  321. <xsl:otherwise>many</xsl:otherwise>
  322. </xsl:choose>
  323. </xsl:variable>
  324. <xsl:variable name="group-name">
  325. <xsl:choose>
  326. <xsl:when test="$inherited-order='one'">choice</xsl:when>
  327. <xsl:when test="$inherited-order='seq'">sequence</xsl:when>
  328. <xsl:when test="$inherited-order='many'">choice</xsl:when>
  329. </xsl:choose>
  330. </xsl:variable>
  331. <xsl:element name="{$group-name}">
  332. <xsl:choose>
  333. <xsl:when test="$group-name='many'">
  334. <xsl:attribute name="minOccurs">0</xsl:attribute>
  335. <xsl:attribute name="maxOccurs">*</xsl:attribute>
  336. </xsl:when>
  337. <xsl:otherwise>
  338. <xsl:apply-templates select="@minOccurs | @maxOccurs"/>
  339. </xsl:otherwise>
  340. </xsl:choose>
  341. <xsl:if test="*[not(self::xdr:*)] | xdr:description">
  342. <annotation>
  343. <xsl:for-each select="xdr:description">
  344. <documentation><xsl:copy-of select="node()"/></documentation>
  345. </xsl:for-each>
  346. <xsl:for-each select="*[not(self::xdr:*)]">
  347. <appinfo><xsl:copy-of select="."/></appinfo>
  348. </xsl:for-each>
  349. </annotation>
  350. </xsl:if>
  351. <xsl:apply-templates select="xdr:*[not(self::xdr:description)]"/>
  352. </xsl:element>
  353. </xsl:template>
  354. <!-- attribute conversion templates -->
  355. <xsl:template match="@*"/>
  356. <xsl:template match="@content">
  357. <xsl:attribute name="content"><xsl:value-of select="."/></xsl:attribute>
  358. </xsl:template>
  359. <xsl:template match="@content[.='eltOnly']">
  360. <xsl:attribute name="content">elementOnly</xsl:attribute>
  361. </xsl:template>
  362. <xsl:template match="@minOccurs | @maxOccurs">
  363. <xsl:copy><xsl:value-of select="."/></xsl:copy>
  364. </xsl:template>
  365. <xsl:template match="@default">
  366. <xsl:attribute name="fixed"><xsl:value-of select="."/></xsl:attribute>
  367. </xsl:template>
  368. <xsl:template match="@required[.='yes']">
  369. <xsl:attribute name="minOccurs">1</xsl:attribute>
  370. </xsl:template>
  371. <!-- Data type attribute/element conversions -->
  372. <xsl:template match="@dt:type">
  373. <xsl:attribute name="type"><xsl:value-of select="."/></xsl:attribute>
  374. </xsl:template>
  375. <xsl:template match="xdr:datatype">
  376. <xsl:attribute name="type"><xsl:value-of select="@dt:type"/></xsl:attribute>
  377. </xsl:template>
  378. <xsl:template match="@dt:type[.='id'] | xdr:datatype[@dt:type='id']">
  379. <xsl:attribute name="type">ID</xsl:attribute>
  380. </xsl:template>
  381. <xsl:template match="@dt:type[.='idref'] | xdr:datatype[@dt:type='idref']">
  382. <xsl:attribute name="type">IDREF</xsl:attribute>
  383. </xsl:template>
  384. <xsl:template match="@dt:type[.='idrefs'] | xdr:datatype[@dt:type='idrefs']">
  385. <xsl:attribute name="type">IDREFS</xsl:attribute>
  386. </xsl:template>
  387. <xsl:template match="@dt:type[.='entity'] | xdr:datatype[@dt:type='entity']">
  388. <xsl:attribute name="type">ENTITY</xsl:attribute>
  389. </xsl:template>
  390. <xsl:template match="@dt:type[.='entities'] | xdr:datatype[@dt:type='entities']">
  391. <xsl:attribute name="type">ENTITIES</xsl:attribute>
  392. </xsl:template>
  393. <xsl:template match="@dt:type[.='nmtoken'] | xdr:datatype[@dt:type='nmtoken']">
  394. <xsl:attribute name="type">NMTOKEN</xsl:attribute>
  395. </xsl:template>
  396. <xsl:template match="@dt:type[.='nmtokens'] | xdr:datatype[@dt:type='nmtokens']">
  397. <xsl:attribute name="type">NMTOKENS</xsl:attribute>
  398. </xsl:template>
  399. <xsl:template match="@dt:type[.='notation'] | xdr:datatype[@dt:type='notation']">
  400. <xsl:attribute name="type">NOTATION</xsl:attribute>
  401. </xsl:template>
  402. <xsl:template match="@dt:type[.='int'] | xdr:datatype[@dt:type='int']">
  403. <xsl:attribute name="type">integer</xsl:attribute>
  404. </xsl:template>
  405. <xsl:template match="@dt:type[.='r8'] | xdr:datatype[@dt:type='r8']">
  406. <xsl:attribute name="type">double</xsl:attribute>
  407. </xsl:template>
  408. <xsl:template match="@dt:type[.='boolean'] | xdr:datatype[@dt:type='boolean']">
  409. <xsl:attribute name="type">ISOBoolean</xsl:attribute>
  410. </xsl:template>
  411. <xsl:template match="@dt:type[.='enumeration']">
  412. <simpleType base="NMTOKEN">
  413. <xsl:value-of select="local:formatEnum(string(../@dt:values))" disable-output-escaping="yes"/>
  414. </simpleType>
  415. </xsl:template>
  416. <xsl:template match="xdr:datatype[@dt:type='enumeration']">
  417. <simpleType base="NMTOKEN">
  418. <xsl:value-of select="local:formatEnum(string(@dt:values))" disable-output-escaping="yes"/>
  419. </simpleType>
  420. </xsl:template>
  421. <msxsl:script language="JScript" implements-prefix="local"><![CDATA[
  422. function formatEnum(e)
  423. {
  424. // trim trailing spaces
  425. while (e.charAt(e.length - 1) == " ")
  426. e = e.substring(0, e.length - 1);
  427. var re = new RegExp("\\s+", "g");
  428. e = e.replace(re, "'/> <enumeration value='");
  429. return "<enumeration value='" + e + "'/>\n";
  430. }
  431. ]]></msxsl:script>
  432. </xsl:stylesheet>