1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/XSLForms/XSL/Skeleton.xsl Fri Sep 30 22:53:43 2005 +0000
1.3 @@ -0,0 +1,113 @@
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 + <axsl:template select="/">
1.23 +
1.24 + <!-- Process the elements. -->
1.25 + <xsl:apply-templates select="*"/>
1.26 +
1.27 + </axsl:template>
1.28 +
1.29 + </axsl:stylesheet>
1.30 + </xsl:template>
1.31 +
1.32 +
1.33 +
1.34 + <!-- Match element references. -->
1.35 +
1.36 + <xsl:template match="*[@template:element]">
1.37 + <xsl:call-template name="enter-element">
1.38 + <xsl:with-param name="other-elements" select="@template:element"/>
1.39 + </xsl:call-template>
1.40 + </xsl:template>
1.41 +
1.42 + <xsl:template name="enter-element">
1.43 + <xsl:param name="other-elements"/>
1.44 + <xsl:variable name="first-element" select="substring-before($other-elements, ',')"/>
1.45 + <xsl:variable name="remaining-elements" select="substring-after($other-elements, ',')"/>
1.46 + <xsl:choose>
1.47 + <xsl:when test="$first-element = ''">
1.48 + <xsl:call-template name="next-element">
1.49 + <xsl:with-param name="first-element" select="$other-elements"/>
1.50 + </xsl:call-template>
1.51 + </xsl:when>
1.52 + <xsl:otherwise>
1.53 + <xsl:call-template name="next-element">
1.54 + <xsl:with-param name="first-element" select="$first-element"/>
1.55 + <xsl:with-param name="remaining-elements" select="$remaining-elements"/>
1.56 + </xsl:call-template>
1.57 + </xsl:otherwise>
1.58 + </xsl:choose>
1.59 + </xsl:template>
1.60 +
1.61 + <xsl:template name="next-element">
1.62 + <xsl:param name="first-element"/>
1.63 + <xsl:param name="remaining-elements"/>
1.64 + <axsl:for-each select="{$first-element}">
1.65 + <axsl:element name="{$first-element}">
1.66 + <xsl:choose>
1.67 + <xsl:when test="$remaining-elements = ''">
1.68 + <xsl:call-template name="enter-attribute"/>
1.69 + </xsl:when>
1.70 + <xsl:otherwise>
1.71 + <xsl:call-template name="enter-element">
1.72 + <xsl:with-param name="other-elements" select="$remaining-elements"/>
1.73 + </xsl:call-template>
1.74 + </xsl:otherwise>
1.75 + </xsl:choose>
1.76 + </axsl:element>
1.77 + </axsl:for-each>
1.78 + </xsl:template>
1.79 +
1.80 +
1.81 +
1.82 + <!-- Match special expression attributes. -->
1.83 +
1.84 + <xsl:template match="*[not(@template:element) and @template:attribute]">
1.85 + <xsl:call-template name="enter-attribute"/>
1.86 + </xsl:template>
1.87 +
1.88 + <xsl:template name="enter-attribute">
1.89 + <xsl:choose>
1.90 + <xsl:when test="@template:attribute">
1.91 + <axsl:choose>
1.92 + <axsl:when test="@{@template:attribute}">
1.93 + <axsl:attribute name="{@template:attribute}"><axsl:value-of select="@{@template:attribute}"/></axsl:attribute>
1.94 + <xsl:apply-templates select="*"/>
1.95 + </axsl:when>
1.96 + <axsl:otherwise>
1.97 + <axsl:attribute name="{@template:attribute}"/>
1.98 + <xsl:apply-templates select="*"/>
1.99 + </axsl:otherwise>
1.100 + </axsl:choose>
1.101 + </xsl:when>
1.102 + <xsl:otherwise>
1.103 + <xsl:apply-templates select="*"/>
1.104 + </xsl:otherwise>
1.105 + </xsl:choose>
1.106 + </xsl:template>
1.107 +
1.108 +
1.109 +
1.110 + <!-- Traverse unknown elements. -->
1.111 +
1.112 + <xsl:template match="*">
1.113 + <xsl:apply-templates select="*"/>
1.114 + </xsl:template>
1.115 +
1.116 +</xsl:stylesheet>