1.1 --- a/XSLForms/XSL/Extract.xsl Fri Jan 27 00:35:15 2006 +0000
1.2 +++ b/XSLForms/XSL/Extract.xsl Fri Jan 27 00:40:56 2006 +0000
1.3 @@ -18,13 +18,9 @@
1.4 -->
1.5 <xsl:stylesheet version="1.0"
1.6 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
1.7 - xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias"
1.8 - xmlns:template="http://www.boddie.org.uk/ns/xmltools/template"
1.9 - xmlns:dyn="http://exslt.org/dynamic"
1.10 - extension-element-prefixes="dyn">
1.11 + xmlns:template="http://www.boddie.org.uk/ns/xmltools/template">
1.12
1.13 <xsl:output indent="yes"/>
1.14 - <xsl:namespace-alias stylesheet-prefix="axsl" result-prefix="xsl"/>
1.15
1.16 <xsl:param name="element-id"/>
1.17
1.18 @@ -33,33 +29,7 @@
1.19 <!-- Start at the top, finding only the specified element. -->
1.20
1.21 <xsl:template match="/">
1.22 - <axsl:stylesheet version="1.0"
1.23 - xmlns:dyn="http://exslt.org/dynamic"
1.24 - extension-element-prefixes="dyn">
1.25 -
1.26 - <axsl:output indent="yes"/>
1.27 - <axsl:param name="element-path"/>
1.28 -
1.29 - <!-- NOTE: Hard-coded doctypes to hopefully satisfy JavaScript code. -->
1.30 - <!-- doctype-public="-//W3C//DTD XHTML 1.1//EN"
1.31 - doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" -->
1.32 -
1.33 - <axsl:template match="/">
1.34 -
1.35 - <!-- Include the remaining attributes. -->
1.36 - <xsl:apply-templates select="@*"/>
1.37 -
1.38 - <!-- Process the elements. -->
1.39 - <xsl:for-each select="//*[@template:id=$element-id]">
1.40 - <axsl:for-each select="dyn:evaluate($element-path)">
1.41 - <xsl:copy>
1.42 - <xsl:apply-templates select="@*|node()"/>
1.43 - </xsl:copy>
1.44 - </axsl:for-each>
1.45 - </xsl:for-each>
1.46 -
1.47 - </axsl:template>
1.48 - </axsl:stylesheet>
1.49 + <xsl:apply-templates select="//*[@template:id=$element-id]"/>
1.50 </xsl:template>
1.51
1.52
2.1 --- a/XSLForms/XSL/FixNamespace.xsl Fri Jan 27 00:35:15 2006 +0000
2.2 +++ b/XSLForms/XSL/FixNamespace.xsl Fri Jan 27 00:40:56 2006 +0000
2.3 @@ -39,7 +39,7 @@
2.4
2.5 <!-- Match specific template attributes. -->
2.6
2.7 - <xsl:template match="@if|@element|@attribute|@attribute-field|@attribute-area|@attribute-button|@attribute-list-button|@selector-field|@multiple-choice-field|@multiple-choice-list-field|@multiple-choice-value|@multiple-choice-list-value|@multiple-choice-list-element|@effect|@value|@expr|@expr-attr|@i18n">
2.8 + <xsl:template match="@if|@element|@attribute|@attribute-field|@attribute-area|@attribute-button|@attribute-list-button|@selector-field|@multiple-choice-field|@multiple-choice-list-field|@multiple-choice-value|@multiple-choice-list-value|@multiple-choice-list-element|@effect|@value|@expr|@expr-attr|@i18n|@copy">
2.9 <!-- Add the namespace. -->
2.10 <xsl:attribute name="template:{local-name(.)}">
2.11 <xsl:copy-of select="string(.)"/>
3.1 --- a/XSLForms/XSL/Prepare.xsl Fri Jan 27 00:35:15 2006 +0000
3.2 +++ b/XSLForms/XSL/Prepare.xsl Fri Jan 27 00:40:56 2006 +0000
3.3 @@ -23,109 +23,158 @@
3.4 <xsl:stylesheet version="1.0"
3.5 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3.6 xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias"
3.7 - xmlns:template="http://www.boddie.org.uk/ns/xmltools/template">
3.8 + xmlns:template="http://www.boddie.org.uk/ns/xmltools/template"
3.9 + xmlns:str="http://exslt.org/strings"
3.10 + extension-element-prefixes="str">
3.11
3.12 <xsl:output indent="yes"/>
3.13 <xsl:namespace-alias stylesheet-prefix="axsl" result-prefix="xsl"/>
3.14
3.15 -
3.16 + <!-- Fragment extraction support. -->
3.17 + <xsl:param name="element-id"/>
3.18
3.19 <!-- Match the document itself. -->
3.20
3.21 <xsl:template match="/">
3.22 - <axsl:stylesheet version="1.0">
3.23 + <axsl:stylesheet version="1.0"
3.24 + xmlns:dyn="http://exslt.org/dynamic"
3.25 + extension-element-prefixes="dyn">
3.26
3.27 <axsl:output indent="yes"/>
3.28 - <!-- NOTE: Hard-coded doctypes to hopefully satisfy JavaScript code. -->
3.29 - <!-- doctype-public="-//W3C//DTD XHTML 1.1//EN"
3.30 - doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" -->
3.31
3.32 <!-- Include internationalisation (i18n) support if appropriate. -->
3.33 <axsl:param name="translations"/>
3.34 <axsl:param name="locale"/>
3.35
3.36 + <!-- Include fragment support if appropriate. -->
3.37 + <axsl:param name="element-path"/>
3.38 +
3.39 <axsl:template match="/">
3.40 + <xsl:choose>
3.41 + <!-- Fragment production. -->
3.42 + <xsl:when test="$element-id != ''">
3.43 + <axsl:for-each select="dyn:evaluate($element-path)">
3.44 + <xsl:apply-templates select="@*|node()"/>
3.45 + </axsl:for-each>
3.46 + </xsl:when>
3.47 + <!-- Whole template production. -->
3.48 + <xsl:otherwise>
3.49 + <xsl:apply-templates select="@*|node()"/>
3.50 + </xsl:otherwise>
3.51 + </xsl:choose>
3.52 + </axsl:template>
3.53
3.54 - <!-- Include the remaining attributes. -->
3.55 - <xsl:apply-templates select="@*"/>
3.56 + <!-- Produce the rules for each element. -->
3.57 +
3.58 + <xsl:apply-templates select="//*[@template:element]">
3.59 + <xsl:with-param name="top-level">true</xsl:with-param>
3.60 + </xsl:apply-templates>
3.61 +
3.62 + </axsl:stylesheet>
3.63 + </xsl:template>
3.64 +
3.65 +
3.66 +
3.67 + <!-- Match elements referencing elements. -->
3.68 +
3.69 + <xsl:template match="*[@template:element]" priority="1">
3.70 + <xsl:param name="top-level">false</xsl:param>
3.71 + <xsl:call-template name="enter-element">
3.72 + <xsl:with-param name="top-level" select="$top-level"/>
3.73 + </xsl:call-template>
3.74 + </xsl:template>
3.75
3.76 - <!-- Process the elements. -->
3.77 - <xsl:apply-templates select="*"/>
3.78 + <xsl:template name="enter-element">
3.79 + <xsl:param name="top-level"/>
3.80 + <xsl:choose>
3.81 + <!-- Produce templates where this is a top-level definition. -->
3.82 + <xsl:when test="$top-level = 'true'">
3.83 + <xsl:call-template name="element-template">
3.84 + <xsl:with-param name="element-names" select="@template:element"/>
3.85 + </xsl:call-template>
3.86 + </xsl:when>
3.87 + <!-- Produce references to elements where this is within a template. -->
3.88 + <xsl:otherwise>
3.89 + <xsl:variable name="first-name" select="str:split(@template:element, ',')[1]"/>
3.90 + <!-- Check to see if this is a recursive reference. -->
3.91 + <xsl:variable name="recursive-element" select="ancestor::*[$first-name = str:split(@template:element, ',')[1]]"/>
3.92 + <xsl:choose>
3.93 + <!-- Generate a reference to the previous element definition. -->
3.94 + <xsl:when test="$recursive-element">
3.95 + <axsl:apply-templates select="{$first-name}" mode="{generate-id($recursive-element)}"/>
3.96 + </xsl:when>
3.97 + <!-- Generate a reference to this element definition. -->
3.98 + <xsl:otherwise>
3.99 + <axsl:apply-templates select="{$first-name}" mode="{generate-id(.)}"/>
3.100 + </xsl:otherwise>
3.101 + </xsl:choose>
3.102 + </xsl:otherwise>
3.103 + </xsl:choose>
3.104 + </xsl:template>
3.105
3.106 - </axsl:template>
3.107 - </axsl:stylesheet>
3.108 + <xsl:template name="element-template">
3.109 + <xsl:param name="element-names"/>
3.110 + <xsl:variable name="this-name" select="substring-before($element-names, ',')"/>
3.111 + <xsl:variable name="next-names" select="substring-after($element-names, ',')"/>
3.112 + <xsl:variable name="next-name" select="str:split($next-names, ',')[1]"/>
3.113 + <xsl:choose>
3.114 + <!-- Non-last part of a list of element names. -->
3.115 + <!-- Produce a template referencing another template. -->
3.116 + <xsl:when test="$this-name != ''">
3.117 + <!-- Produce a template with a mode. -->
3.118 + <axsl:template match="{$this-name}" mode="{generate-id(.)}">
3.119 + <axsl:apply-templates select="{$next-name}" mode="{generate-id(.)}"/>
3.120 + </axsl:template>
3.121 + <!-- Produce the other elements' templates... -->
3.122 + <xsl:call-template name="element-template">
3.123 + <xsl:with-param name="element-names" select="$next-names"/>
3.124 + </xsl:call-template>
3.125 + </xsl:when>
3.126 + <!-- Last part of a list of element names. -->
3.127 + <!-- Produce a template with content. -->
3.128 + <xsl:otherwise>
3.129 + <!-- Produce a template with a mode. -->
3.130 + <axsl:template match="{$element-names}" mode="{generate-id(.)}">
3.131 + <xsl:call-template name="enter-attribute"/>
3.132 + </axsl:template>
3.133 + </xsl:otherwise>
3.134 + </xsl:choose>
3.135 </xsl:template>
3.136
3.137
3.138
3.139 <!-- Match special conditional expression attributes. -->
3.140
3.141 - <xsl:template match="*[@template:if]">
3.142 - <axsl:if test="{@template:if}">
3.143 - <xsl:choose>
3.144 - <xsl:when test="@template:element">
3.145 - <xsl:call-template name="enter-element">
3.146 - <xsl:with-param name="other-elements" select="@template:element"/>
3.147 - </xsl:call-template>
3.148 - </xsl:when>
3.149 - <xsl:otherwise>
3.150 - <xsl:call-template name="enter-attribute"/>
3.151 - </xsl:otherwise>
3.152 - </xsl:choose>
3.153 - </axsl:if>
3.154 - </xsl:template>
3.155 -
3.156 -
3.157 -
3.158 - <!-- Match element references. -->
3.159 -
3.160 - <xsl:template match="*[not(@template:if) and @template:element]">
3.161 - <xsl:call-template name="enter-element">
3.162 - <xsl:with-param name="other-elements" select="@template:element"/>
3.163 - </xsl:call-template>
3.164 - </xsl:template>
3.165 -
3.166 - <xsl:template name="enter-element">
3.167 - <xsl:param name="other-elements"/>
3.168 - <xsl:variable name="first-element" select="substring-before($other-elements, ',')"/>
3.169 - <xsl:variable name="remaining-elements" select="substring-after($other-elements, ',')"/>
3.170 + <xsl:template match="*[@template:if]" priority="2">
3.171 + <xsl:param name="top-level">false</xsl:param>
3.172 <xsl:choose>
3.173 - <xsl:when test="$first-element = ''">
3.174 - <xsl:call-template name="next-element">
3.175 - <xsl:with-param name="first-element" select="$other-elements"/>
3.176 + <!-- Since this rule may be invoked at the top level, ignore conditions. -->
3.177 + <xsl:when test="$top-level = 'true'">
3.178 + <xsl:call-template name="enter-element">
3.179 + <xsl:with-param name="top-level" select="$top-level"/>
3.180 </xsl:call-template>
3.181 </xsl:when>
3.182 + <!-- As part of a template, generate the condition. -->
3.183 <xsl:otherwise>
3.184 - <xsl:call-template name="next-element">
3.185 - <xsl:with-param name="first-element" select="$first-element"/>
3.186 - <xsl:with-param name="remaining-elements" select="$remaining-elements"/>
3.187 - </xsl:call-template>
3.188 + <axsl:if test="{@template:if}">
3.189 + <xsl:choose>
3.190 + <xsl:when test="@template:element">
3.191 + <xsl:call-template name="enter-element"/>
3.192 + </xsl:when>
3.193 + <xsl:otherwise>
3.194 + <xsl:call-template name="enter-attribute"/>
3.195 + </xsl:otherwise>
3.196 + </xsl:choose>
3.197 + </axsl:if>
3.198 </xsl:otherwise>
3.199 </xsl:choose>
3.200 </xsl:template>
3.201
3.202 - <xsl:template name="next-element">
3.203 - <xsl:param name="first-element"/>
3.204 - <xsl:param name="remaining-elements"/>
3.205 - <axsl:for-each select="{$first-element}">
3.206 - <xsl:choose>
3.207 - <xsl:when test="$remaining-elements = ''">
3.208 - <xsl:call-template name="enter-attribute"/>
3.209 - </xsl:when>
3.210 - <xsl:otherwise>
3.211 - <xsl:call-template name="enter-element">
3.212 - <xsl:with-param name="other-elements" select="$remaining-elements"/>
3.213 - </xsl:call-template>
3.214 - </xsl:otherwise>
3.215 - </xsl:choose>
3.216 - </axsl:for-each>
3.217 - </xsl:template>
3.218 -
3.219
3.220
3.221 <!-- Match special expression attributes. -->
3.222
3.223 - <xsl:template match="*[not(@template:if) and not(@template:element) and (@template:attribute or @template:value or @template:expr or @template:copy)]">
3.224 + <xsl:template match="*[@template:attribute or @template:value or @template:expr or @template:copy]">
3.225 <xsl:call-template name="enter-attribute"/>
3.226 </xsl:template>
3.227
3.228 @@ -242,7 +291,7 @@
3.229
3.230 <!-- Remove template attributes. -->
3.231
3.232 - <xsl:template match="@template:element|@template:init|@template:attribute|@template:value|@template:expr|@template:expr-attr|@template:effect|@template:if|@template:i18n">
3.233 + <xsl:template match="@template:element|@template:init|@template:attribute|@template:value|@template:expr|@template:expr-attr|@template:effect|@template:if|@template:i18n|@template:copy">
3.234 </xsl:template>
3.235
3.236