1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/XSLForms/XSL/Input.xsl Sun Oct 02 01:10:50 2005 +0000
1.3 @@ -0,0 +1,134 @@
1.4 +<?xml version="1.0"?>
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 +
1.10 + <xsl:output indent="yes"/>
1.11 + <xsl:namespace-alias stylesheet-prefix="axsl" result-prefix="xsl"/>
1.12 +
1.13 +
1.14 +
1.15 + <!-- Match the document itself. -->
1.16 +
1.17 + <xsl:template match="/">
1.18 + <axsl:stylesheet version="1.0">
1.19 +
1.20 + <axsl:output indent="yes"/>
1.21 +
1.22 + <!-- Make document parameters for all elements appearing to use enumerations. -->
1.23 + <xsl:for-each select="//element[*/@expr]">
1.24 + <axsl:param name="{@name}"/>
1.25 + </xsl:for-each>
1.26 +
1.27 + <!-- Make a document-level rule. -->
1.28 + <axsl:template match="/">
1.29 + <axsl:apply-templates select="*"/>
1.30 + </axsl:template>
1.31 +
1.32 + <!-- Process the top-level element to make other rules. -->
1.33 + <xsl:apply-templates select="*"/>
1.34 +
1.35 + <!-- Replicate unknown elements. -->
1.36 + <axsl:template match="@*|node()">
1.37 + <axsl:copy>
1.38 + <axsl:apply-templates select="@*|node()"/>
1.39 + </axsl:copy>
1.40 + </axsl:template>
1.41 +
1.42 + </axsl:stylesheet>
1.43 + </xsl:template>
1.44 +
1.45 +
1.46 +
1.47 + <!-- Match element references. -->
1.48 +
1.49 + <xsl:template match="element">
1.50 + <xsl:param name="nested">false</xsl:param>
1.51 +
1.52 + <!-- Make a rule for the element. -->
1.53 + <axsl:template match="{@name}">
1.54 +
1.55 + <!-- Copy the element. -->
1.56 + <xsl:element name="{@name}">
1.57 +
1.58 + <!-- Process attributes. -->
1.59 + <axsl:apply-templates select="@*"/>
1.60 +
1.61 + <!-- Find elements and determine how to process them. -->
1.62 + <xsl:for-each select="element">
1.63 + <xsl:choose>
1.64 + <!-- Enumerations. -->
1.65 + <xsl:when test="@expr">
1.66 + <xsl:call-template name="inside-element"/>
1.67 + </xsl:when>
1.68 + <!-- Top-level or "section" elements are added. -->
1.69 + <xsl:when test="count(attribute) = 0 or $nested = 'false'">
1.70 + <xsl:element name="{@name}">
1.71 + <xsl:call-template name="inside-element"/>
1.72 + </xsl:element>
1.73 + </xsl:when>
1.74 + <!-- Other elements are only added if found. -->
1.75 + <xsl:otherwise>
1.76 + <axsl:apply-templates select="{@name}"/>
1.77 + </xsl:otherwise>
1.78 + </xsl:choose>
1.79 + </xsl:for-each>
1.80 +
1.81 + </xsl:element>
1.82 +
1.83 + </axsl:template>
1.84 +
1.85 + <!-- Make rules for nested elements. -->
1.86 + <xsl:choose>
1.87 + <xsl:when test="$nested = 'true'">
1.88 + <xsl:apply-templates select="*[not(@expr)]">
1.89 + <xsl:with-param name="nested">true</xsl:with-param>
1.90 + </xsl:apply-templates>
1.91 + </xsl:when>
1.92 + <xsl:otherwise>
1.93 + <xsl:apply-templates select="*/*[not(@expr)]">
1.94 + <xsl:with-param name="nested">true</xsl:with-param>
1.95 + </xsl:apply-templates>
1.96 + </xsl:otherwise>
1.97 + </xsl:choose>
1.98 +
1.99 + </xsl:template>
1.100 +
1.101 +
1.102 +
1.103 + <!-- Fill in elements. -->
1.104 +
1.105 + <xsl:template name="inside-element">
1.106 + <axsl:apply-templates select="{@name}/@*"/>
1.107 + <xsl:choose>
1.108 + <!-- Enumerations. -->
1.109 + <xsl:when test="@expr">
1.110 + <xsl:call-template name="inside-enumeration"/>
1.111 + </xsl:when>
1.112 + <xsl:otherwise>
1.113 + <!-- Enumeration containers. -->
1.114 + <xsl:for-each select="*[@expr]">
1.115 + <xsl:call-template name="inside-element"/>
1.116 + </xsl:for-each>
1.117 + <!-- Normal elements. -->
1.118 + <xsl:if test="count(element[not(@expr)]) != 0">
1.119 + <axsl:apply-templates select="{@name}/*"/>
1.120 + </xsl:if>
1.121 + </xsl:otherwise>
1.122 + </xsl:choose>
1.123 + </xsl:template>
1.124 +
1.125 +
1.126 +
1.127 + <!-- Fill in enumerations. -->
1.128 +
1.129 + <xsl:template name="inside-enumeration">
1.130 + <axsl:for-each select="${../@name}/{../@name}/{@name}">
1.131 + <axsl:copy>
1.132 + <axsl:apply-templates select="@*"/>
1.133 + </axsl:copy>
1.134 + </axsl:for-each>
1.135 + </xsl:template>
1.136 +
1.137 +</xsl:stylesheet>
2.1 --- a/XSLForms/XSL/Schema.xsl Sun Oct 02 01:10:02 2005 +0000
2.2 +++ b/XSLForms/XSL/Schema.xsl Sun Oct 02 01:10:50 2005 +0000
2.3 @@ -48,8 +48,11 @@
2.4 <xsl:template name="next-element">
2.5 <xsl:param name="first-element"/>
2.6 <xsl:param name="remaining-elements"/>
2.7 - <xsl:element name="element">
2.8 + <element>
2.9 <xsl:attribute name="name"><xsl:value-of select="$first-element"/></xsl:attribute>
2.10 + <xsl:if test="@template:expr">
2.11 + <xsl:attribute name="expr"><xsl:value-of select="@template:expr"/></xsl:attribute>
2.12 + </xsl:if>
2.13 <xsl:choose>
2.14 <xsl:when test="$remaining-elements = ''">
2.15 <xsl:call-template name="enter-attribute"/>
2.16 @@ -60,7 +63,7 @@
2.17 </xsl:call-template>
2.18 </xsl:otherwise>
2.19 </xsl:choose>
2.20 - </xsl:element>
2.21 + </element>
2.22 </xsl:template>
2.23
2.24
2.25 @@ -74,16 +77,20 @@
2.26 <xsl:template name="enter-attribute">
2.27 <xsl:choose>
2.28 <xsl:when test="@template:attribute">
2.29 - <xsl:element name="attribute">
2.30 + <attribute>
2.31 <xsl:attribute name="name"><xsl:value-of select="@template:attribute"/></xsl:attribute>
2.32 - </xsl:element>
2.33 - </xsl:when>
2.34 - <xsl:when test="@template:expr-attr">
2.35 - <xsl:element name="attribute">
2.36 - <xsl:attribute name="name"><xsl:value-of select="@template:value"/></xsl:attribute>
2.37 - </xsl:element>
2.38 + </attribute>
2.39 </xsl:when>
2.40 <xsl:otherwise>
2.41 + <xsl:if test="@template:expr-attr">
2.42 + <xsl:attribute name="expr-attr"><xsl:value-of select="@template:expr-attr"/></xsl:attribute>
2.43 + </xsl:if>
2.44 + <xsl:if test="@template:expr">
2.45 + <xsl:attribute name="expr"><xsl:value-of select="@template:expr"/></xsl:attribute>
2.46 + </xsl:if>
2.47 + <xsl:if test="@template:value">
2.48 + <xsl:attribute name="value"><xsl:value-of select="@template:value"/></xsl:attribute>
2.49 + </xsl:if>
2.50 <xsl:apply-templates select="*"/>
2.51 </xsl:otherwise>
2.52 </xsl:choose>