1.1 --- a/XSLForms/Output.py Wed Oct 12 15:26:30 2005 +0000
1.2 +++ b/XSLForms/Output.py Wed Oct 12 16:29:31 2005 +0000
1.3 @@ -264,6 +264,27 @@
1.4 l.append(node_path + Constants.path_separator + attribute_name)
1.5 return ",".join(l).encode("utf-8")
1.6
1.7 +def selector_name(context, field_name, nodes):
1.8 +
1.9 + """
1.10 + Exposed as {template:selector-name(field_name, nodes)}.
1.11 + Provides a selector field name defined using 'field_name' and referring to
1.12 + the given 'nodes'. For example:
1.13 +
1.14 + template:selector-name('add-platform', package/platforms) -> 'add-platform=/package$1/platforms$1'
1.15 +
1.16 + NOTE: The 'nodes' must be element references.
1.17 + """
1.18 +
1.19 + #print "selector_name"
1.20 + names = []
1.21 + for node in nodes:
1.22 + name = path_to_node(libxml2dom.Node(node), 0, None, 0)
1.23 + if name not in names:
1.24 + names.append(field_name + "=" + name)
1.25 + r = ",".join(names)
1.26 + return r.encode("utf-8")
1.27 +
1.28 # Old implementations.
1.29
1.30 def multi_field_name(context, multivalue_name):
1.31 @@ -338,6 +359,7 @@
1.32 libxsltmod.xsltRegisterExtModuleFunction("other-attributes", "http://www.boddie.org.uk/ns/xmltools/template", other_attributes)
1.33 libxsltmod.xsltRegisterExtModuleFunction("child-element", "http://www.boddie.org.uk/ns/xmltools/template", child_element)
1.34 libxsltmod.xsltRegisterExtModuleFunction("child-attribute", "http://www.boddie.org.uk/ns/xmltools/template", child_attribute)
1.35 +libxsltmod.xsltRegisterExtModuleFunction("selector-name", "http://www.boddie.org.uk/ns/xmltools/template", selector_name)
1.36
1.37 # New names.
1.38