1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/examples/Common/VerySimple/Resources/structure_multivalue_template.xhtml Wed Jul 20 22:46:04 2005 +0000
1.3 @@ -0,0 +1,45 @@
1.4 +<?xml version="1.0" encoding="iso-8859-1"?>
1.5 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
1.6 + "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1.7 +<html xmlns="http://www.w3.org/1999/xhtml"
1.8 + xmlns:template="http://www.boddie.org.uk/ns/xmltools/template">
1.9 +<head>
1.10 + <title>Example</title>
1.11 +</head>
1.12 +<body template:element="structure">
1.13 +<form action="" method="POST">
1.14 +
1.15 +<!-- Template text between the start and the interesting part. -->
1.16 +
1.17 +<div template:element="item">
1.18 + <p>
1.19 + Some item: <input template:attribute="value" name="{template:this-attribute()}" type="text" value="{$this-value}" />
1.20 + <input name="remove={template:this-element()}" type="submit" value="Remove" />
1.21 + </p>
1.22 + <p template:element="types">
1.23 + Item type:
1.24 + <select template:element="type" name="{template:list-attribute('value')}" multiple="multiple">
1.25 + <option template:element="type-enum" template:expr="@value-is-set" template:expr-attr="selected"
1.26 + template:value="@value" value="{@value}" />
1.27 + </select>
1.28 + </p>
1.29 + <p>
1.30 + Itself containing more items:
1.31 + </p>
1.32 + <p template:element="subitem">
1.33 + Sub-item: <input template:attribute="subvalue" name="{template:this-attribute()}" type="text" value="{$this-value}" />
1.34 + <input name="remove2={template:this-element()}" type="submit" value="Remove" />
1.35 + </p>
1.36 + <p>
1.37 + <input name="add2={template:this-element()}" type="submit" value="Add subitem" />
1.38 + </p>
1.39 +</div>
1.40 +<p>
1.41 + <input name="add={template:this-element()}" type="submit" value="Add item" />
1.42 +</p>
1.43 +
1.44 +<!-- Template text between the interesting part and the end. -->
1.45 +
1.46 +</form>
1.47 +</body>
1.48 +</html>
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/examples/Common/VerySimple/Resources/structure_multivalue_types.xsl Wed Jul 20 22:46:04 2005 +0000
2.3 @@ -0,0 +1,59 @@
2.4 +<?xml version="1.0" encoding="utf-8"?>
2.5 +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
2.6 + xmlns:template="http://www.boddie.org.uk/ns/xmltools/template"
2.7 + version="1.0">
2.8 +
2.9 + <xsl:param name="types"/>
2.10 +
2.11 + <!-- Add or process type elements inside item elements. -->
2.12 +
2.13 + <xsl:template match="item">
2.14 + <!-- Copy the element and its contents. -->
2.15 + <xsl:copy>
2.16 + <xsl:apply-templates select="@*"/>
2.17 + <!-- Look for a types element. -->
2.18 + <xsl:call-template name="types"/>
2.19 + <xsl:apply-templates select="*[local-name() != 'types']"/>
2.20 + </xsl:copy>
2.21 + </xsl:template>
2.22 +
2.23 + <!-- Investigate types elements. -->
2.24 +
2.25 + <xsl:template name="types">
2.26 + <!-- Make the elements. -->
2.27 + <types>
2.28 + <type>
2.29 + <!-- Look for type element values. -->
2.30 + <xsl:call-template name="type-enum">
2.31 + <!-- Supply the existing type values. -->
2.32 + <xsl:with-param name="values" select="types/type/@value"/>
2.33 + </xsl:call-template>
2.34 + </type>
2.35 + </types>
2.36 + </xsl:template>
2.37 +
2.38 + <!-- Add to type elements the range of acceptable values. -->
2.39 +
2.40 + <xsl:template name="type-enum">
2.41 + <xsl:param name="values"/>
2.42 + <!-- Find all values in the range and add them. -->
2.43 + <xsl:for-each select="$types/types/type-enum">
2.44 + <xsl:copy>
2.45 + <xsl:apply-templates select="@*"/>
2.46 + <!-- Mark those whose value are the same as that found on the element. -->
2.47 + <xsl:if test="$values[string() = current()/@value]">
2.48 + <xsl:attribute name="value-is-set">true</xsl:attribute>
2.49 + </xsl:if>
2.50 + </xsl:copy>
2.51 + </xsl:for-each>
2.52 + </xsl:template>
2.53 +
2.54 + <!-- Replicate unknown elements. -->
2.55 +
2.56 + <xsl:template match="@*|*|node()">
2.57 + <xsl:copy>
2.58 + <xsl:apply-templates select="@*|*|node()"/>
2.59 + </xsl:copy>
2.60 + </xsl:template>
2.61 +
2.62 +</xsl:stylesheet>
3.1 --- a/examples/Common/VerySimple/__init__.py Wed Jul 20 17:59:53 2005 +0000
3.2 +++ b/examples/Common/VerySimple/__init__.py Wed Jul 20 22:46:04 2005 +0000
3.3 @@ -16,10 +16,12 @@
3.4 resource_dir = os.path.join(os.path.split(__file__)[0], "Resources")
3.5 encoding = "utf-8"
3.6 template_resources = {
3.7 - "structure" : ("structure_template.xhtml", "structure_output.xsl")
3.8 + #"structure" : ("structure_template.xhtml", "structure_output.xsl")
3.9 + "structure" : ("structure_multivalue_template.xhtml", "structure_output.xsl")
3.10 }
3.11 transform_resources = {
3.12 - "types" : ["structure_types.xsl"]
3.13 + #"types" : ["structure_types.xsl"]
3.14 + "types" : ["structure_multivalue_types.xsl"]
3.15 }
3.16 document_resources = {
3.17 "types" : "structure_types.xml"