# HG changeset patch # User paulb # Date 1121863984 0 # Node ID 1ef19d572106803ada5eb5c5d7661c533da6c08f # Parent 8745080ee6800e788507b60f7fff26ec5a98d9bc [project @ 2005-07-20 12:52:53 by paulb] Introduced new, better names for the XSL extension functions. diff -r 8745080ee680 -r 1ef19d572106 XSLForms/Output.py --- a/XSLForms/Output.py Tue Jul 19 23:40:05 2005 +0000 +++ b/XSLForms/Output.py Wed Jul 20 12:53:04 2005 +0000 @@ -150,6 +150,17 @@ r = ",".join(names) return r.encode("utf-8") +# New names. + +libxsltmod.xsltRegisterExtModuleFunction("this-element", "http://www.boddie.org.uk/ns/xmltools/template", this_position) +libxsltmod.xsltRegisterExtModuleFunction("this-attribute", "http://www.boddie.org.uk/ns/xmltools/template", field_name) +libxsltmod.xsltRegisterExtModuleFunction("list-attribute", "http://www.boddie.org.uk/ns/xmltools/template", multi_field_name) +libxsltmod.xsltRegisterExtModuleFunction("new-attribute", "http://www.boddie.org.uk/ns/xmltools/template", new_field) +libxsltmod.xsltRegisterExtModuleFunction("other-nodes", "http://www.boddie.org.uk/ns/xmltools/template", other_field_names) +libxsltmod.xsltRegisterExtModuleFunction("other-list-attributes", "http://www.boddie.org.uk/ns/xmltools/template", other_multi_field_names) + +# Old names. + libxsltmod.xsltRegisterExtModuleFunction("this-position", "http://www.boddie.org.uk/ns/xmltools/template", this_position) libxsltmod.xsltRegisterExtModuleFunction("field-name", "http://www.boddie.org.uk/ns/xmltools/template", field_name) libxsltmod.xsltRegisterExtModuleFunction("multi-field-name", "http://www.boddie.org.uk/ns/xmltools/template", multi_field_name) diff -r 8745080ee680 -r 1ef19d572106 docs/multiple.html --- a/docs/multiple.html Tue Jul 19 23:40:05 2005 +0000 +++ b/docs/multiple.html Wed Jul 20 12:53:04 2005 +0000 @@ -40,14 +40,14 @@

Taking the example HTML code from before, we can add a definition of this new list to the template to produce something like this:

-
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:template="http://www.boddie.org.uk/ns/xmltools/template">
<head>
<title>Example</title>
</head>
<body template:element="structure">
<form action="" method="POST">

<!-- Template text between the start and the interesting part. -->

<div template:element="item">
<p>
Some item: <input template:attribute="value" name="{template:field-name()}" type="text" value="{$this-value}" />
<input name="remove={template:this-position()}" type="submit" value="Remove" />
</p>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:template="http://www.boddie.org.uk/ns/xmltools/template">
<head>
<title>Example</title>
</head>
<body template:element="structure">
<form action="" method="POST">

<!-- Template text between the start and the interesting part. -->

<div template:element="item">
<p>
Some item: <input template:attribute="value" name="{template:this-attribute()}" type="text" value="{$this-value}" />
<input name="remove={template:this-element()}" type="submit" value="Remove" />
</p>
<p>
Item type:
<select template:element="type" name="{template:new-field('value')}">
<select template:element="type" name="{template:new-attribute('value')}">
<option template:element="type-enum" template:expr="@value = ../@value" template:expr-attr="selected"
template:value="@value" value="{@value}" />
</select>
</p>
<p>
Itself containing more items:
</p>
<p template:element="subitem">
Sub-item: <input template:attribute="subvalue" name="{template:field-name()}" type="text" value="{$this-value}" />
<input name="remove2={template:this-position()}" type="submit" value="Remove" />
</p>
<p>
<input name="add2={template:this-position()}" type="submit" value="Add subitem" />
</p>
</div>
<p>
<input name="add={template:this-position()}" type="submit" value="Add item" />
</p> </p>
<p>
Itself containing more items:
</p>
<p template:element="subitem">
Sub-item: <input template:attribute="subvalue" name="{template:this-attribute()}" type="text" value="{$this-value}" />
<input name="remove2={template:this-element()}" type="submit" value="Remove" />
</p>
<p>
<input name="add2={template:this-element()}" type="submit" value="Add subitem" />
</p>
</div>
<p>
<input name="add={template:this-element()}" type="submit" value="Add item" />
</p>

<!-- Template text between the interesting part and the end. -->

</form>
</body>
</html>

There are a lot of details here that need to be explained. Here is what was done:

diff -r 8745080ee680 -r 1ef19d572106 docs/selectors.html --- a/docs/selectors.html Tue Jul 19 23:40:05 2005 +0000 +++ b/docs/selectors.html Wed Jul 20 12:53:04 2005 +0000 @@ -29,11 +29,11 @@

Taking the example HTML code from before, we add some of these selector annotations to the template to produce something like this:

-
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:template="http://www.boddie.org.uk/ns/xmltools/template">
<head>
<title>Example</title>
</head>
<body template:element="structure">
<form action="" method="POST">

<!-- Template text between the start and the interesting part. -->

<div template:element="item">
<p>
Some item: <input template:attribute="value" name="{template:field-name()}" type="text" value="{$this-value}" />
<input name="remove={template:this-position()}" type="submit" value="Remove" />
</p>
<p>
Itself containing more items:
</p>
<p template:element="subitem">
Sub-item: <input template:attribute="subvalue" name="{template:field-name()}" type="text" value="{$this-value}" />
<input name="remove2={template:this-position()}" type="submit" value="Remove" />
</p>
<p>
<input name="add2={template:this-position()}" type="submit" value="Add subitem" />
</p>
</div>
<p>
<input name="add={template:this-position()}" type="submit" value="Add item" />
</p><html xmlns="http://www.w3.org/1999/xhtml"
xmlns:template="http://www.boddie.org.uk/ns/xmltools/template">
<head>
<title>Example</title>
</head>
<body template:element="structure">
<form action="" method="POST">

<!-- Template text between the start and the interesting part. -->

<div template:element="item">
<p>
Some item: <input template:attribute="value" name="{template:this-attribute()}" type="text" value="{$this-value}" />
<input name="remove={template:this-element()}" type="submit" value="Remove" />
</p>
<p>
Itself containing more items:
</p>
<p template:element="subitem">
Sub-item: <input template:attribute="subvalue" name="{template:this-attribute()}" type="text" value="{$this-value}" />
<input name="remove2={template:this-element()}" type="submit" value="Remove" />
</p>
<p>
<input name="add2={template:this-element()}" type="submit" value="Add subitem" />
</p>
</div>
<p>
<input name="add={template:this-element()}" type="submit" value="Add item" />
</p>

<!-- Template text between the interesting part and the end. -->

</form>
</body>
</html>

The Remove Buttons

Some of the attributes in the previous HTML code have been diff -r 8745080ee680 -r 1ef19d572106 docs/structure.html --- a/docs/structure.html Tue Jul 19 23:40:05 2005 +0000 +++ b/docs/structure.html Wed Jul 20 12:53:04 2005 +0000 @@ -39,11 +39,11 @@ style="font-weight: bold;">template:element="structure">

<item <div template:element="item">
<p>
value="some value"> Some item: <input template:attribute="value" name="{template:field-name()}" type="text" value="{template:this-attribute()}" type="text" value="{$this-value}" />
<input name="remove" type="submit" value="Remove" />
</p>
<p>
Itself containing more items:
</p>
<subitem <p template:element="subitem">
 subvalue="some other value"/> Sub-item: <input template:attribute="subvalue" name="{template:field-name()}" type="text" value="{template:this-attribute()}" type="text" value="{$this-value}" />
<input name="remove2" type="submit" value="Remove" />
</p>
<p>
<input name="add2" type="submit" value="Add subitem" />
</p>
</item> </div>
<p>
<input name="add" type="submit" value="Add item" />
</p>

</structure> </body>

The following annotations have been added:

@@ -59,7 +59,7 @@ been changed: