1
<?xml version="1.0" encoding="UTF-8"?>
3
<!-- (C) 2009 Rackspace Hosting, All Rights Reserved -->
6
<xslt:stylesheet version="1.0"
7
xmlns:xslt="http://www.w3.org/1999/XSL/Transform"
8
xmlns:html="http://www.w3.org/1999/xhtml"
9
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
10
xmlns:xsdxt="http://docs.rackspacecloud.com/xsd-ext/v1.0"
11
xmlns="http://www.w3.org/1999/xhtml"
14
<xslt:output method="html"
16
media-type="text/html"
17
doctype-public = "-//W3C//DTD HTML 4.01//EN"
18
doctype-system = "http://www.w3.org/TR/html4/strict.dtd" />
21
<xslt:param name="base">
23
<xslt:when test="/xsd:schema/@xsdxt:base">
24
<xslt:value-of select="/xsd:schema/@xsdxt:base"/>
27
<xslt:text>..</xslt:text>
32
<!-- Global Variables -->
33
<xslt:variable name="defaultTitle">XML Schema Documentation</xslt:variable>
34
<xslt:variable name="templateType">application/xhtml+xml</xslt:variable>
35
<xslt:variable name="schemaNamespace">http://www.w3.org/2001/XMLSchema</xslt:variable>
36
<xslt:variable name="schemaDatatypeURI">http://web4.w3.org/TR/2001/REC-xmlschema-2-20010502/#</xslt:variable>
38
<xslt:variable name="dQuote">"</xslt:variable>
39
<xslt:variable name="sQuote">'</xslt:variable>
41
<!-- The namespace prefixes -->
42
<xslt:variable name="targetPrefix">
43
<xslt:for-each select="/xsd:schema/namespace::node()">
44
<xslt:if test=".=/xsd:schema/@targetNamespace">
45
<xslt:value-of select="name(.)"/>
50
<xslt:variable name="schemaPrefix">
51
<xslt:for-each select="/xsd:schema/namespace::node()">
52
<xslt:if test="(.=$schemaNamespace) and (string-length(.) > 0)">
53
<xslt:value-of select="name(.)"/>
58
<!-- Anchor prefixes -->
59
<xslt:variable name="elementPrefix">element_</xslt:variable>
60
<xslt:variable name="attributePrefix">attrib_</xslt:variable>
61
<xslt:variable name="attributeGroupPrefix">attgrp_</xslt:variable>
62
<xslt:variable name="groupPrefix">grp_</xslt:variable>
63
<xslt:variable name="typePrefix">type_</xslt:variable>
67
We only load YUI style sheets here. We bring js stuff
68
dynamically. Stylesheet's can't really be brought dynamically.
69
They need to be loaded before anything else.
71
<xslt:variable name="YUI_BASE">http://yui.yahooapis.com/2.7.0/build/</xslt:variable>
72
<xslt:variable name="YUI_RESET_STYLESHEET">
73
<xslt:value-of select="concat($YUI_BASE,'reset/reset-min.css')" />
75
<xslt:variable name="YUI_BASE_STYLESHEET">
76
<xslt:value-of select="concat($YUI_BASE,'base/base-min.css')" />
78
<xslt:variable name="YUI_FONTS_STYLESHEET">
79
<xslt:value-of select="concat($YUI_BASE,'fonts/fonts-min.css')" />
81
<xslt:variable name="YUI_GRIDS_STYLESHEET">
82
<xslt:value-of select="concat($YUI_BASE,'grids/grids-min.css')" />
85
<xslt:template name="addStylesheet">
86
<xslt:param name="sheet" />
87
<xslt:element name="link">
88
<xslt:attribute name="rel">stylesheet</xslt:attribute>
89
<xslt:attribute name="type">text/css</xslt:attribute>
90
<xslt:attribute name="href">
91
<xslt:value-of select="$sheet"/>
97
<xslt:template name="SchemaHandler" match="xsd:schema">
100
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
101
<xslt:call-template name="addStylesheet">
102
<xslt:with-param name="sheet" select="$YUI_RESET_STYLESHEET"/>
103
</xslt:call-template>
104
<xslt:call-template name="addStylesheet">
105
<xslt:with-param name="sheet" select="$YUI_BASE_STYLESHEET"/>
106
</xslt:call-template>
107
<xslt:call-template name="addStylesheet">
108
<xslt:with-param name="sheet" select="$YUI_FONTS_STYLESHEET"/>
109
</xslt:call-template>
110
<xslt:call-template name="addStylesheet">
111
<xslt:with-param name="sheet" select="$YUI_GRIDS_STYLESHEET"/>
112
</xslt:call-template>
113
<xslt:call-template name="addStylesheet">
114
<xslt:with-param name="sheet" select="concat($base,'/style/schema.css')"/>
115
</xslt:call-template>
120
<xslt:for-each select="//xsdxt:link">
121
<xslt:if test="not(@qname)">
122
<xslt:element name="link">
123
<xslt:if test="@rev">
124
<xslt:attribute name="rev"><xslt:value-of select="@rev"/></xslt:attribute>
126
<xslt:if test="@rel">
127
<xslt:attribute name="rel"><xslt:value-of select="@rel"/></xslt:attribute>
129
<xslt:if test="@href">
130
<xslt:attribute name="href"><xslt:value-of select="@href"/></xslt:attribute>
132
<xslt:if test="@type">
133
<xslt:attribute name="type"><xslt:value-of select="@type"/></xslt:attribute>
140
Set the title if it's available, default title if not.
143
<xslt:when test="xsd:annotation/xsd:appinfo/xsdxt:title">
144
<title><xslt:value-of select="xsd:annotation/xsd:appinfo/xsdxt:title"/></title>
147
<title><xslt:value-of select="$defaultTitle"/></title>
151
<!-- Schema scripts -->
152
<script type="text/javascript" src="{$base}/js/trc/util.js"> </script>
153
<script type="text/javascript" src="{$base}/js/trc/schema/layoutManager.js"> </script>
154
<script type="text/javascript" src="{$base}/js/trc/schema/sampleManager.js"> </script>
155
<script type="text/javascript" src="{$base}/js/trc/schema/controller.js"> </script>
157
<xslt:if test="//xsdxt:samples | //xsdxt:code">
158
<script type="text/javascript">
159
<xslt:for-each select="//xsdxt:samples">
160
<xslt:variable name="elmId"><xslt:value-of select="generate-id(.)"/></xslt:variable>
161
<xslt:if test="xsdxt:sample">
162
<xslt:text>trc.schema.sampleManager.samples["</xslt:text>
163
<xslt:value-of select="$elmId"/>
164
<xslt:text>"]=[</xslt:text>
165
<xslt:for-each select="xsdxt:sample">
166
<xslt:call-template name="StringToJavascript">
167
<xslt:with-param name="inString" select="generate-id(.)"/>
168
</xslt:call-template>
169
<xslt:if test="generate-id(../xsdxt:sample[count(../xsdxt:sample)]) !=
172
<xslt:text>,</xslt:text>
175
<xslt:text>];</xslt:text>
178
<xslt:if test="//xsdxt:code">
179
<xslt:text>trc.schema.sampleManager.codes.push(</xslt:text>
180
<xslt:for-each select="//xsdxt:code">
181
<xslt:text>{ id : </xslt:text>
182
<xslt:value-of select="concat($dQuote,generate-id(.),$dQuote)" />
183
<xslt:text>, type : "</xslt:text>
185
<xslt:when test="@type">
186
<xslt:value-of select="@type"/>
189
<xslt:text>application/xml</xslt:text>
192
<xslt:text>", href : </xslt:text>
194
<xslt:when test="@href">
195
<xslt:value-of select="concat($dQuote,@href,$dQuote)"/>
198
<xslt:text>null</xslt:text>
201
<xslt:text>}</xslt:text>
202
<xslt:text>,</xslt:text>
204
<xslt:text>null);</xslt:text>
209
<xslt:call-template name="ControllerJSHandler" />
212
Copy any HTML header tags here
214
<xslt:for-each select="//xsdxt:head">
216
<xslt:when test="not(@type)">
217
<xslt:copy-of select="./*" />
219
<xslt:when test="@type = $templateType">
220
<xslt:copy-of select="./*" />
226
<div id="Controller">
230
<div id="SrcContent">
231
<div class="SampleCode">
232
<pre id="SrcContentCode">Loading...</pre>
237
If there is a title use it as a first heading, otherwise,
241
<xslt:when test="xsd:annotation/xsd:appinfo/xsdxt:title">
242
<h1><xslt:value-of select="xsd:annotation/xsd:appinfo/xsdxt:title"/></h1>
245
<h1><xslt:value-of select="$defaultTitle"/></h1>
252
<table summary="Schema-level attributes">
254
<xslt:for-each select="@*">
256
<td><xslt:value-of select="local-name(.)"/></td>
257
<td><xslt:value-of select="."/></td>
264
Copy schema-level documentation if there's anything to
265
copy. This also processes any internal documentation
266
annotations: currently just xsdxt:code.
268
<xslt:apply-templates select="xsd:annotation/xsd:documentation/*" mode="Docs"/>
271
Next comes custom header...
274
<xslt:for-each select="//xsdxt:header">
276
<xslt:when test="not(@type)">
277
<xslt:copy-of select="./*" />
279
<xslt:when test="@type = $templateType">
280
<xslt:copy-of select="./*" />
288
Namespace info, not all borowsers have namespace node
289
support. Specifically Firefox currently lacks it.
292
https://bugzilla.mozilla.org/show_bug.cgi?id=94270
294
In this case we ask the user to try a different
295
browser: Opera, Safari, or even IE.
299
<xslt:when test="count(namespace::*) = 0">
300
<!--Namespaces are not available...-->
301
<div class="Warning">
303
Your browser does not seem to have support for
304
namespace nodes in XPath. If you're a Firefox
305
user, please consider voting to get this issue
307
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=94270"
308
title="FireFox Bug 94270">
309
https://bugzilla.mozilla.org/show_bug.cgi?id=94270
315
<table summary="Namespace details">
317
<xslt:for-each select="namespace::*">
320
<td><xslt:value-of select="name(.)"/></td>
321
<td><xslt:value-of select="."/></td>
330
Next, call the handlers for the top schema elements.
332
<xslt:if test="xsd:import">
333
<xslt:call-template name="ImportHandler" />
335
<xslt:if test="xsd:include">
336
<xslt:call-template name="IncludeHandler" />
339
<xslt:if test="xsd:element">
340
<xslt:call-template name="ElementHandler" />
343
<xslt:if test="xsd:complexType">
344
<xslt:call-template name="ComplexTypeHandler" />
347
<xslt:if test="xsd:simpleType">
348
<xslt:call-template name="SimpleTypeHandler" />
351
<!-- Finally, custom footers -->
353
<xslt:for-each select="//xsdxt:footer">
355
<xslt:when test="not(@type)">
356
<xslt:copy-of select="./*" />
358
<xslt:when test="@type = $templateType">
359
<xslt:copy-of select="./*" />
371
<xslt:template name="ControllerExternJSLinks">
372
<xslt:param name="nodes" />
374
<xslt:text>trc.schema.controller.links['</xslt:text>
375
<xslt:value-of select="local-name($nodes[1])"/>
376
<xslt:text>']=[</xslt:text>
377
<xslt:for-each select="$nodes">
378
<xslt:call-template name="ControllerJSLink">
379
<xslt:with-param name="href" select="@schemaLocation"/>
380
<xslt:with-param name="name">
382
<xslt:when test="@namespace">
383
<xslt:value-of select="@namespace" />
386
<xslt:value-of select="@schemaLocation" />
390
<xslt:with-param name="title">
392
<xslt:when test="@namespace">
393
<xslt:value-of select="concat('View schema for namespace ',@namespace)"/>
396
<xslt:value-of select="concat('Visit schema ',@schemaLocation)"/>
400
</xslt:call-template>
401
<xslt:if test="$nodes[count($nodes)]/@schemaLocation !=
403
<xslt:text>,</xslt:text>
406
<xslt:text>];</xslt:text>
409
<xslt:template name="ControllerIndexJSLink">
410
<xslt:param name="node" select="//xsdxt:link[@rel = 'index']" />
412
<xslt:text>trc.schema.controller.index = </xslt:text>
413
<xslt:call-template name="ControllerJSLink">
414
<xslt:with-param name="href">
415
<xslt:value-of select="$node/@href"/>
417
<xslt:with-param name="name">
418
<xslt:text>index</xslt:text>
420
<xslt:with-param name="title">
421
<xslt:text>Index Schema Document</xslt:text>
423
</xslt:call-template>
424
<xslt:text>;</xslt:text>
427
<xslt:template name="ControllerNamedElementJSLink">
428
<xslt:param name="nodes" />
429
<xslt:param name="anchorPrefix" />
431
<xslt:text>trc.schema.controller.links['</xslt:text>
432
<xslt:value-of select="local-name($nodes[1])"/>
433
<xslt:text>']=[</xslt:text>
434
<xslt:for-each select="$nodes">
435
<xslt:call-template name="ControllerJSLink">
436
<xslt:with-param name="href">
437
<xslt:text>#</xslt:text>
438
<xslt:value-of select="$anchorPrefix" />
439
<xslt:value-of select="@name" />
441
<xslt:with-param name="name">
442
<xslt:call-template name="StringToName"/>
444
<xslt:with-param name="title">
445
<xslt:text>See definition of </xslt:text>
446
<xslt:call-template name="StringToName"/>
448
</xslt:call-template>
449
<xslt:if test="generate-id($nodes[count($nodes)]) !=
451
<xslt:text>,</xslt:text>
454
<xslt:text>];</xslt:text>
457
<xslt:template name="ControllerJSLink">
458
<xslt:param name="name" />
459
<xslt:param name="href" />
460
<xslt:param name="title" />
462
<xslt:text>{ href : </xslt:text>
463
<xslt:call-template name="StringToJavascript">
464
<xslt:with-param name="inString">
465
<xslt:value-of select="$href"/>
467
</xslt:call-template>
468
<xslt:text>, name : </xslt:text>
469
<xslt:call-template name="StringToJavascript">
470
<xslt:with-param name="inString">
471
<xslt:value-of select="$name"/>
473
</xslt:call-template>
474
<xslt:text>, title : </xslt:text>
475
<xslt:call-template name="StringToJavascript">
476
<xslt:with-param name="inString">
477
<xslt:value-of select="$title"/>
479
</xslt:call-template>
480
<xslt:text>}</xslt:text>
484
Adds javascript for controller data..
486
<xslt:template name="ControllerJSHandler">
487
<script type="text/javascript">
488
<xslt:if test="xsd:import">
489
<xslt:call-template name="ControllerExternJSLinks">
490
<xslt:with-param name="nodes" select="xsd:import" />
491
</xslt:call-template>
493
<xslt:if test="xsd:include">
494
<xslt:call-template name="ControllerExternJSLinks">
495
<xslt:with-param name="nodes" select="xsd:include" />
496
</xslt:call-template>
498
<xslt:if test="xsd:element">
499
<xslt:call-template name="ControllerNamedElementJSLink">
500
<xslt:with-param name="nodes" select="xsd:element"/>
501
<xslt:with-param name="anchorPrefix" select="$elementPrefix"/>
502
</xslt:call-template>
504
<xslt:if test="xsd:attribute">
505
<xslt:call-template name="ControllerNamedElementJSLink">
506
<xslt:with-param name="nodes" select="xsd:attribute"/>
507
<xslt:with-param name="anchorPrefix" select="$attributePrefix"/>
508
</xslt:call-template>
510
<xslt:if test="xsd:complexType">
511
<xslt:call-template name="ControllerNamedElementJSLink">
512
<xslt:with-param name="nodes" select="xsd:complexType"/>
513
<xslt:with-param name="anchorPrefix" select="$typePrefix"/>
514
</xslt:call-template>
516
<xslt:if test="xsd:simpleType">
517
<xslt:call-template name="ControllerNamedElementJSLink">
518
<xslt:with-param name="nodes" select="xsd:simpleType"/>
519
<xslt:with-param name="anchorPrefix" select="$typePrefix"/>
520
</xslt:call-template>
522
<xslt:if test="//xsdxt:link[@rel = 'index']">
523
<xslt:call-template name="ControllerIndexJSLink" />
528
<xslt:template name="ImportHandler">
530
<table summary="A list of imported XML Schema" class="ImportTable">
532
<xslt:for-each select="xsd:import">
535
<xslt:value-of select="@namespace"/>
539
<div class="ExternHref">
540
<xslt:element name="a">
541
<xslt:attribute name="href"><xslt:value-of select="@schemaLocation"/></xslt:attribute>
542
<xslt:attribute name="title">Visit <xslt:value-of select="@schemaLocation"/></xslt:attribute>
543
<xslt:value-of select="@schemaLocation"/>
546
<div class="ExternDoc">
547
<xslt:apply-templates select="xsd:annotation/xsd:documentation/*" mode="Docs"/>
557
<xslt:template name="IncludeHandler">
559
<table summary="A list of included XML Schema">
561
<xslt:for-each select="xsd:include">
565
<div class="ExternHref">
566
<xslt:element name="a">
567
<xslt:attribute name="href"><xslt:value-of select="@schemaLocation"/></xslt:attribute>
568
<xslt:attribute name="title">Visit <xslt:value-of select="@schemaLocation"/></xslt:attribute>
569
<xslt:value-of select="@schemaLocation"/>
572
<div class="ExternDoc">
573
<xslt:apply-templates select="xsd:annotation/xsd:documentation/*" mode="Docs"/>
583
<xslt:template name="ElementHandler">
585
<xslt:for-each select="xsd:element">
586
<xslt:call-template name="NamedElement">
587
<xslt:with-param name="anchorPrefix" select="$elementPrefix" />
588
</xslt:call-template>
589
<xslt:if test="xsd:annotation/xsd:appinfo/xsdxt:samples">
590
<xslt:apply-templates select="xsd:annotation/xsd:appinfo/xsdxt:samples" mode="Docs" />
595
<xslt:template name="SampleHandler" match="xsdxt:samples" mode="Docs">
596
<xslt:variable name="sampleID" select="generate-id(.)"/>
597
<xslt:if test="xsdxt:description">
598
<xslt:apply-templates select="xsdxt:description/*" mode="Docs" />
601
<div class="SampleControl">
602
<xslt:element name="select">
603
<xslt:attribute name="onchange">
604
<xslt:text>trc.schema.sampleManager.showSample(</xslt:text>
605
<xslt:call-template name="StringToJavascript">
606
<xslt:with-param name="inString" select="$sampleID"/>
607
</xslt:call-template>
608
<xslt:text>);</xslt:text>
610
<xslt:attribute name="id">
611
<xslt:value-of select="$sampleID"/>
613
<xslt:for-each select="xsdxt:sample">
614
<xslt:element name="option">
615
<xslt:attribute name="value">
616
<xslt:value-of select="generate-id(.)"/>
619
<xslt:when test="@title">
620
<xslt:value-of select="@title"/>
623
<xslt:value-of select="./xsdxt:code/@type"/>
631
<xslt:for-each select="xsdxt:sample">
632
<xslt:element name="div">
633
<xslt:attribute name="id"><xslt:value-of select="generate-id(.)"/></xslt:attribute>
634
<xslt:attribute name="class">Sample</xslt:attribute>
635
<div class="SampleDesc">
636
<xslt:apply-templates select="xsdxt:description/*" mode="Docs"/>
638
<xslt:apply-templates select="xsdxt:code" mode="Docs"/>
644
Documentation templates, copy everything but process the
647
<xslt:template match="xsdxt:code" mode="Docs">
648
<div class="SampleCode">
649
<xslt:element name="pre">
650
<xslt:attribute name="id">
651
<xslt:value-of select="generate-id(.)"/>
654
<xslt:when test="@href">
655
<xslt:text>Loading...</xslt:text>
658
<xslt:value-of select="."/>
665
<xslt:template match="*" mode="Docs">
666
<xslt:copy-of select="." />
669
<xslt:template name="ComplexTypeHandler">
670
<h2>Complex Types</h2>
671
<xslt:for-each select="xsd:complexType">
672
<xslt:call-template name="NamedElement">
673
<xslt:with-param name="anchorPrefix" select="$typePrefix" />
674
</xslt:call-template>
675
<xslt:apply-templates />
679
<xslt:template name="SimpleTypeHandler">
680
<h2>Simple Types</h2>
681
<xslt:for-each select="xsd:simpleType">
682
<xslt:call-template name="NamedElement">
683
<xslt:with-param name="anchorPrefix" select="$typePrefix" />
684
</xslt:call-template>
685
<xslt:apply-templates />
689
<xslt:template name="NamedElementLink">
690
<xslt:param name="anchorPrefix" />
691
<xslt:call-template name="Anchor">
692
<xslt:with-param name="href">
693
<xslt:text>#</xslt:text>
694
<xslt:value-of select="$anchorPrefix"/>
695
<xslt:value-of select="@name"/>
697
<xslt:with-param name="content">
698
<xslt:call-template name="StringToName" />
700
</xslt:call-template>
703
<xslt:template name="NamedElement">
704
<xslt:param name="anchorPrefix" />
705
<xslt:element name="a">
706
<xslt:attribute name="id"><xslt:value-of select="$anchorPrefix"/><xslt:value-of select="@name"/></xslt:attribute>
708
Placing a comment here causes the anchor tag to be closed
712
<xslt:value-of select="@name"/>
716
<xslt:call-template name="StringToName" />
720
<!-- look for extensions and restrictions in type names -->
721
<xslt:when test="$anchorPrefix = $typePrefix">
722
<xslt:if test=".//xsd:extension">
723
<div class="NameAddl">
724
<xslt:text> extends: </xslt:text>
725
<xslt:for-each select=".//xsd:extension">
726
<xslt:apply-templates select="@base" mode="QNameToLink" />
727
<xslt:if test=".//xsd:extension[count(.//xsd:extension)]/@base != @base">
728
<xslt:text>,</xslt:text>
733
<xslt:if test=".//xsd:restriction">
734
<div class="NameAddl">
735
<xslt:text> restricts: </xslt:text>
736
<xslt:for-each select=".//xsd:restriction">
737
<xslt:apply-templates select="@base" mode="QNameToLink" />
738
<xslt:if test=".//xsd:restriction[count(.//xsd:restriction)]/@base != @base">
739
<xslt:text>,</xslt:text>
747
<xslt:call-template name="AttribsAndDocs" />
751
<!-- Display all attributes besides @name -->
752
<xslt:template name="Attribs">
753
<xslt:param name="isSubItem" select="false()"/>
754
<xslt:if test="(count(@*) > 1) or ((count(@*) = 1) and not(@name))">
755
<xslt:element name="div">
756
<xslt:attribute name="class">
758
<xslt:when test="$isSubItem = true()">
759
<xslt:text>SubAttributes</xslt:text>
762
<xslt:text>Attributes</xslt:text>
766
<table summary="Attributes">
768
<xslt:for-each select="@*">
769
<xslt:sort select="local-name(.)"/>
770
<xslt:if test="local-name(.) != 'name'">
772
<td><xslt:value-of select="local-name(.)"/></td>
773
<td><xslt:call-template name="QNameToLink"/></td>
783
<xslt:template name="Docs">
784
<xslt:param name="isSubItem" select="false()"/>
786
Copy element-level documentation
788
<xslt:if test="xsd:annotation/xsd:documentation">
789
<xslt:element name="div">
790
<xslt:attribute name="class">
792
<xslt:when test="$isSubItem = true()">
793
<xslt:text>SubDocumentation</xslt:text>
796
<xslt:text>Documentation</xslt:text>
800
<xslt:apply-templates select="xsd:annotation/xsd:documentation/*" mode="Docs"/>
805
<xslt:template name="AttribsAndDocs">
806
<xslt:param name="isSubItem" select="false()"/>
807
<xslt:call-template name="Attribs">
808
<xslt:with-param name="isSubItem" select="$isSubItem"/>
809
</xslt:call-template>
810
<xslt:call-template name="Docs">
811
<xslt:with-param name="isSubItem" select="$isSubItem"/>
812
</xslt:call-template>
816
Convert a qname to a link.
818
<xslt:template name="QNameToLink" match="@*" mode="QNameToLink">
819
<xslt:param name="qname" select="normalize-space(.)"/>
821
<xslt:when test="contains($qname,':')">
822
<xslt:variable name="prefix" select="substring-before($qname,':')"/>
823
<xslt:variable name="localName" select="substring-after($qname,':')"/>
825
<xslt:when test="//xsdxt:link[(@qname = $qname) and (@rel = 'schema')]">
826
<xslt:call-template name="Anchor">
827
<xslt:with-param name="href" select="//xsdxt:link[(@qname = $qname) and (@rel = 'schema')]/@href"/>
828
<xslt:with-param name="title" select="concat('See ',$localName)"/>
829
</xslt:call-template>
831
<xslt:when test="$prefix = $targetPrefix">
832
<xslt:call-template name="Anchor">
833
<xslt:with-param name="href"><xslt:call-template name="QNameToLocalAnchor"/></xslt:with-param>
834
<xslt:with-param name="title" select="concat('See ',$localName)"/>
835
</xslt:call-template>
837
<xslt:when test="$prefix = $schemaPrefix">
838
<xslt:call-template name="Anchor">
839
<xslt:with-param name="href"><xslt:call-template name="QNameToXSDAnchor"/></xslt:with-param>
840
<xslt:with-param name="title" select="concat('See ',$localName)"/>
841
</xslt:call-template>
844
<xslt:call-template name="Anchor">
845
<xslt:with-param name="href"><xslt:call-template name="QNameToForeignAnchor"/></xslt:with-param>
846
<xslt:with-param name="title" select="concat('See ',$localName)"/>
847
</xslt:call-template>
852
<xslt:value-of select="."/>
857
<!-- Write an anchor if it's defined for the current node -->
858
<xslt:template name="Anchor">
859
<xslt:param name="href" /> <!-- if empty don't make an anchor -->
860
<xslt:param name="title">
861
<xslt:if test="@name">
862
<xslt:value-of select="concat('See ',@name)"/>
865
<xslt:param name="content" select="."/>
867
<xslt:when test="string-length($href) != 0">
868
<xslt:element name="a">
869
<xslt:attribute name="href"><xslt:value-of select="$href"/></xslt:attribute>
870
<xslt:attribute name="title"><xslt:value-of select="$title"/></xslt:attribute>
871
<xslt:value-of select="$content"/>
874
<xslt:otherwise><xslt:value-of select="."/></xslt:otherwise>
879
Given a quname attribute pointing to a forign XSD type return a
880
link if a single import statement exists with a schemaLocation
883
<xslt:template name="QNameToForeignAnchor">
884
<xslt:param name="qname" select="normalize-space(.)"/>
885
<xslt:param name="localName" select="substring-after($qname, ':')"/>
886
<xslt:param name="prefix" select="substring-before($qname, ':')"/>
887
<xslt:if test="namespace-uri(..) = $schemaNamespace">
888
<xslt:variable name="namespace">
889
<xslt:for-each select="/xsd:schema/namespace::node()">
890
<xslt:if test="name(.)=$prefix">
891
<xslt:value-of select="."/>
895
<xslt:if test="(string-length($namespace) > 0) and
896
(count(/xsd:schema/xsd:import[@namespace = $namespace]) = 1) and
897
/xsd:schema/xsd:import[@namespace = $namespace]/@schemaLocation
899
<xslt:value-of select="/xsd:schema/xsd:import[@namespace = $namespace]/@schemaLocation"/>
905
Given a qname attribute pointing to an XSD type, returns an anchor
906
to the XSD definition. This only works for type references.
908
<xslt:template name="QNameToXSDAnchor">
909
<xslt:param name="qname" select="normalize-space(.)"/>
910
<xslt:param name="localName" select="substring-after($qname, ':')"/>
911
<xslt:if test="namespace-uri(..) = $schemaNamespace">
912
<xslt:if test="(local-name(.) = 'type') or (local-name(.) = 'base')">
913
<xslt:value-of select="concat($schemaDatatypeURI,$localName)" />
919
Given a qname attribute, returns an anchor target for that qname,
920
or an empty string if an anchor cannot be generated for whatever
923
<xslt:template name="QNameToLocalAnchor">
924
<xslt:param name="qname" select="normalize-space(.)"/>
925
<xslt:param name="localName" select="substring-after($qname, ':')"/>
926
<xslt:if test="namespace-uri(..) = $schemaNamespace">
928
<xslt:when test="(local-name(.) = 'type') or
929
(local-name(.) = 'base') or
930
(local-name(.) = 'itemType')"><xslt:call-template name="LocalTypeAnchor"><xslt:with-param name="localName" select="$localName"/>
931
</xslt:call-template></xslt:when>
932
<xslt:when test="local-name(.) = 'ref'"><xslt:call-template name="LocalRefAnchor"><xslt:with-param name="localName" select="$localName"/>
933
</xslt:call-template></xslt:when>
938
<xslt:template name="LocalRefAnchor">
939
<xslt:param name="localName" />
941
<!-- Element Reference -->
942
<xslt:when test="local-name(..) = 'element'">
943
<xslt:call-template name="LocalRefAnchorBuilder">
944
<xslt:with-param name="localName" select="$localName"/>
945
<xslt:with-param name="search" select="/xsd:schema/xsd:element[@name= $localName]"/>
946
<xslt:with-param name="refPrefix" select="$elementPrefix"/>
947
</xslt:call-template>
949
<!-- Attribute Reference -->
950
<xslt:when test="local-name(..) = 'attribute'">
951
<xslt:call-template name="LocalRefAnchorBuilder">
952
<xslt:with-param name="localName" select="$localName"/>
953
<xslt:with-param name="search" select="/xsd:schema/xsd:attribute[@name= $localName]"/>
954
<xslt:with-param name="refPrefix" select="$attributePrefix"/>
955
</xslt:call-template>
957
<!-- Attribute Group Reference -->
958
<xslt:when test="local-name(..) = 'attributeGroup'">
959
<xslt:call-template name="LocalRefAnchorBuilder">
960
<xslt:with-param name="localName" select="$localName"/>
961
<xslt:with-param name="search" select="/xsd:schema/xsd:attributeGroup[@name= $localName]"/>
962
<xslt:with-param name="refPrefix" select="$attributeGroupPrefix"/>
963
</xslt:call-template>
965
<!-- Group Reference -->
966
<xslt:when test="local-name(..) = 'group'">
967
<xslt:call-template name="LocalRefAnchorBuilder">
968
<xslt:with-param name="localName" select="$localName"/>
969
<xslt:with-param name="search" select="/xsd:schema/xsd:group[@name= $localName]"/>
970
<xslt:with-param name="refPrefix" select="$groupPrefix"/>
971
</xslt:call-template>
976
<xslt:template name="LocalRefAnchorBuilder">
977
<xslt:param name="localName" />
978
<xslt:param name="search" />
979
<xslt:param name="refPrefix" />
981
<xslt:when test="$search">
982
<xslt:value-of select="concat('#',$refPrefix,$localName)"/>
985
If we have a single incude then we assume it's
988
<xslt:when test="count(/xsd:schema/xsd:include) = 1"><xslt:value-of
989
select="concat(/xsd:schema/xsd:include/@schemaLocation,'#',$refPrefix,$localName)"/></xslt:when>
994
Given a local name as a pram, returns a local "type" anchor or an
995
empty string if one cannot be generated.
997
<xslt:template name="LocalTypeAnchor">
998
<xslt:param name="localName" />
1000
<!-- Search the types -->
1002
test="/xsd:schema/xsd:complexType[@name = $localName] or
1003
/xsd:schema/xsd:simpleType[@name = $localName]"
1004
><xslt:value-of select="concat('#',$typePrefix,$localName)"/></xslt:when>
1006
If we haven't hit yet see if we have an include.
1007
Currently this only works with a single include.
1010
test="count(/xsd:schema/xsd:include) = 1"><xslt:value-of
1011
select="concat(/xsd:schema/xsd:include/@schemaLocation,'#',$typePrefix,$localName)"/></xslt:when>
1012
<!-- Can't tell so send an empty string... -->
1017
<!-- Internal sequences -->
1018
<xslt:template match="xsd:sequence">
1019
<div class="Sequence">
1020
<span class="h4">Sequence</span>
1021
<xslt:call-template name="AttribsAndDocs" />
1022
<xslt:apply-templates />
1026
<xslt:template name="SubItem">
1027
<xslt:param name="name" />
1028
<div class="SubItem">
1029
<div class="SubItemProps">
1030
<div class="SubName">
1031
<xslt:value-of select="$name"/>
1033
<xslt:call-template name="Attribs">
1034
<xslt:with-param name="isSubItem" select="true()"/>
1035
</xslt:call-template>
1037
<xslt:call-template name="Docs">
1038
<xslt:with-param name="isSubItem" select="true()"/>
1039
</xslt:call-template>
1043
<xslt:template match="xsd:element">
1044
<xslt:call-template name="SubItem">
1045
<xslt:with-param name="name">
1047
<xslt:when test="@name">
1048
<xslt:call-template name="StringToElementName">
1049
<xslt:with-param name="inString" select="@name"/>
1050
</xslt:call-template>
1052
<xslt:when test="@ref">
1053
<xslt:variable name="elementName" select="substring-after(@ref,':')"/>
1054
<xslt:call-template name="StringToElementName">
1055
<xslt:with-param name="inString" select="$elementName"/>
1056
</xslt:call-template>
1060
</xslt:call-template>
1063
<xslt:template match="xsd:any">
1064
<xslt:call-template name="SubItem">
1065
<xslt:with-param name="name">
1066
<xslt:text><?> (Any Element)</xslt:text>
1068
</xslt:call-template>
1071
<xslt:template match="xsd:anyAttribute">
1072
<xslt:call-template name="SubItem">
1073
<xslt:with-param name="name">
1074
<xslt:text>@? (Any Attribute)</xslt:text>
1076
</xslt:call-template>
1079
<xslt:template match="xsd:restriction">
1080
<div class="SubName">
1081
<xslt:text>restriction</xslt:text>
1083
<table summary="Restriction Props and Attributes">
1085
<xslt:for-each select="@*">
1086
<xslt:sort select="local-name(.)"/>
1087
<xslt:if test="local-name(.) != 'name'">
1089
<td><xslt:value-of select="local-name(.)"/></td>
1090
<td><xslt:call-template name="QNameToLink"/></td>
1095
<!-- simple restrictions -->
1096
<xslt:for-each select="xsd:minExclusive | xsd:minInclusive |
1097
xsd:maxExclusive | xsd:maxInclusive |
1098
xsd:totalDigits | xsd:fractionDigits |
1099
xsd:length | xsd:minLength |
1100
xsd:maxLength | xsd:minLength |
1101
xsd:whitespace | xsd:pattern
1104
<td><xslt:value-of select="local-name(.)"/></td>
1105
<xslt:call-template name="DisplaySimpleRestriction"/>
1109
<xslt:if test="xsd:enumeration">
1111
<td>enum values</td>
1112
<xslt:call-template name="DisplayEnumeration">
1113
<xslt:with-param name="enum" select="xsd:enumeration[1]"/>
1114
</xslt:call-template>
1116
<xslt:for-each select="xsd:enumeration">
1117
<xslt:if test="@value != ../xsd:enumeration[1]/@value">
1120
<xslt:call-template name="DisplayEnumeration"/>
1129
Copy restriction docs documentation...
1131
<xslt:if test="xsd:annotation/xsd:documentation">
1132
<xslt:apply-templates select="xsd:annotation/xsd:documentation/*" mode="Docs"/>
1136
Apply templates for unhandled children
1138
<xslt:apply-templates select="xsd:simpleType | xsd:group |
1139
xsd:all | xsd:choice |
1140
xsd:sequence | xsd:attribute |
1141
xsd:attributeGroup | xsd:anyAttribute" />
1145
Displays an enumeration in a table...
1147
<xslt:template name="DisplayEnumeration">
1148
<xslt:param name="enum" select="." />
1151
<div class="EnumValue">
1152
<xslt:value-of select="$enum/@value"/>
1153
<xslt:if test="$enum/@id">
1154
<xslt:text> (id = </xslt:text>
1155
<xslt:value-of select="$enum/@id"/>
1156
<xslt:text>)</xslt:text>
1159
<xslt:if test="$enum/xsd:annotation/xsd:documentation">
1160
<div class="EnumDoc">
1161
<xslt:apply-templates select="$enum/xsd:annotation/xsd:documentation/*" mode="Docs"/>
1169
A Simple restriction in a table fragment.
1171
<xslt:template name="DisplaySimpleRestriction">
1172
<xslt:param name="restriction" select="." />
1174
<xslt:value-of select="$restriction/@value"/>
1175
<xslt:if test="$restriction/@id">
1176
<xslt:text> (id = </xslt:text>
1177
<xslt:value-of select="$restriction/@id"/>
1178
<xslt:text>)</xslt:text>
1180
<xslt:if test="$restriction/@fixed = 'true'">
1181
<xslt:text> (fixed)</xslt:text>
1184
<xslt:if test="$restriction/xsd:annotation/xsd:documentation">
1186
<xslt:apply-templates select="$restriction/xsd:annotation/xsd:documentation/*" mode="Docs"/>
1191
<!-- Catch all for the missed elements -->
1192
<xslt:template match="xsd:*">
1193
<xslt:if test="local-name(.) != 'annotation'">
1194
<div class="SubElementName">
1195
<xslt:value-of select="local-name(.)"/>
1197
<xslt:call-template name="AttribsAndDocs" />
1198
<div class="SubElementContent">
1199
<xslt:apply-templates />
1204
<xslt:template match="xsd:attribute">
1205
<xslt:call-template name="SubItem">
1206
<xslt:with-param name="name">
1208
<xslt:when test="@name">
1209
<xslt:call-template name="StringToAttributeName">
1210
<xslt:with-param name="inString" select="@name"/>
1211
</xslt:call-template>
1213
<xslt:when test="@ref">
1214
<xslt:variable name="attribName" select="substring-after(@ref,':')"/>
1215
<xslt:call-template name="StringToAttributeName">
1216
<xslt:with-param name="inString" select="$attribName"/>
1217
</xslt:call-template>
1221
</xslt:call-template>
1224
<!-- ignore other text -->
1225
<xslt:template match="text()" />
1227
<!-- Convert a string to a name -->
1228
<xslt:template name="StringToName">
1229
<xslt:param name="inString" select="@name" />
1230
<xslt:param name="inNode" select="." />
1233
<!-- element names handled with StringToElementName -->
1234
<xslt:when test="(local-name($inNode) = 'element') and
1235
(namespace-uri($inNode) = $schemaNamespace)
1237
<xslt:call-template name="StringToElementName">
1238
<xslt:with-param name="inString" select="$inString"/>
1239
</xslt:call-template>
1242
<!-- attribute names handled with StringToAttributeName -->
1243
<xslt:when test="(local-name($inNode) = 'attribute') and
1244
(namespace-uri($inNode) = $schemaNamespace)
1246
<xslt:call-template name="StringToAttributeName">
1247
<xslt:with-param name="inString" select="$inString"/>
1248
</xslt:call-template>
1252
<xslt:value-of select="@name"/>
1257
<!-- Convert a string to an element name -->
1258
<xslt:template name="StringToElementName">
1259
<xslt:param name="inString" />
1260
<xslt:text><</xslt:text>
1261
<xslt:value-of select="$inString" />
1262
<xslt:text>></xslt:text>
1265
<!-- Convert a string to an attribute name -->
1266
<xslt:template name="StringToAttributeName">
1267
<xslt:param name="inString" />
1268
<xslt:text>@</xslt:text>
1269
<xslt:value-of select="$inString" />
1273
Convert a string parameter to an escapted Javascript string in
1276
<xslt:template name="StringToJavascript">
1277
<xslt:param name="inString" />
1278
<!-- quote the string -->
1279
<xslt:variable name="quotedString"
1280
select="concat($dQuote,translate($inString,$dQuote,$sQuote),$dQuote)"/>
1281
<!-- replace linefeeds with \n -->
1282
<xslt:variable name="lfString">
1283
<xslt:call-template name="ReplaceText">
1284
<xslt:with-param name="inString" select="$quotedString"/>
1285
<xslt:with-param name="searchString" select="'
'"/>
1286
<xslt:with-param name="replaceString" select="'\n'"/>
1287
</xslt:call-template>
1289
<!-- replace tabs with 5 spaces -->
1290
<xslt:variable name="tabString">
1291
<xslt:call-template name="ReplaceText">
1292
<xslt:with-param name="inString" select="$lfString"/>
1293
<xslt:with-param name="searchString" select="'	'"/>
1294
<xslt:with-param name="replaceString" select="' '"/>
1295
</xslt:call-template>
1297
<!-- remove carrige returns -->
1298
<xslt:variable name="crString" select="translate($tabString,'
','')"/>
1299
<!-- replace < with unicode sequence -->
1300
<xslt:variable name="ltString">
1301
<xslt:call-template name="ReplaceText">
1302
<xslt:with-param name="inString" select="$crString"/>
1303
<xslt:with-param name="searchString" select="'<'"/>
1304
<xslt:with-param name="replaceString" select="'\u003c'"/>
1305
</xslt:call-template>
1307
<!-- replace > with unicode sequence -->
1308
<xslt:variable name="gtString">
1309
<xslt:call-template name="ReplaceText">
1310
<xslt:with-param name="inString" select="$ltString"/>
1311
<xslt:with-param name="searchString" select="'>'"/>
1312
<xslt:with-param name="replaceString" select="'\u003e'"/>
1313
</xslt:call-template>
1315
<xslt:value-of select="$gtString"/>
1319
Simple search and replace
1321
<xslt:template name="ReplaceText">
1322
<xslt:param name="inString" />
1323
<xslt:param name="searchString"/>
1324
<xslt:param name="replaceString"/>
1327
<xslt:when test="$searchString and
1328
contains($inString, $searchString)">
1329
<xslt:value-of select="substring-before($inString, $searchString)"/>
1330
<xslt:value-of select="$replaceString"/>
1331
<xslt:call-template name="ReplaceText">
1332
<xslt:with-param name="inString" select="substring-after($inString, $searchString)"/>
1333
<xslt:with-param name="searchString" select="$searchString"/>
1334
<xslt:with-param name="replaceString" select="$replaceString"/>
1335
</xslt:call-template>
1338
<xslt:value-of select="$inString"/>