I have updated XSP::SimpleTaglib to allow arbitrary namespaces to be specified for the generated nodes. A description of this extension to SimpleTaglib's perl attribute interface is below.
I am seeking feedback on this interface and information on where to submit the patch if it is deemed useful or if someone wants to try it out. (Being new to AxKit there is a slightly nagging question in my mind that maybe this namespace patch is unnecessary because I may have missed something.) Ken Neighbors XML NAMESPACES in SimpleTaglib By default, all output elements nodes are placed in the same namespace as the tag library. To specify a different namespace or no namespace, the following shorthand can be used in place of C<name> when specifying a node name in a result attribute: prefix:name:namespaceURI For example, to create an XML node named C<otherNS:name> and associate the prefix 'otherNS' with the namespace 'http://mydomain/NS/other/v1': node(otherNS:name:http://mydomain/NS/other/v1) To create an XML node with no namespace, use an empty prefix and an empty namespace: node(:name:) The shorthand notation for specifying namespaces can also be used in the C<struct> result attribute. Alternatively, the standard 'xmlns' XML attribute may be used to specify namespaces. For example, the following are equivalent: sub sample_struct : struct { return "{ 'otherNS:name:http://mydomain/NS/other/v1' => 'value' }"; } sub sample_struct : struct { return q{{ 'otherNS:name' => { '@xmlns:otherNS' => 'http://mydomain/NS/other/v1', '' => 'value' } }}; } Namespace scoping in the hashref is patterned after XML documents. You may refer to previously declared namespaces by using the same prefix, and you may override previously declared namespaces with new declarations (either with shorthand notation or 'xmlns' XML attributes). To specify a default prefix and namespace for all unqualified node names in the hashref, state them as parameters to the C<struct> result attribute: struct(prefix,namespace) For example, the following is equivalent to the previous example: sub sample_struct : struct(otherNS,http://mydomain/NS/other/v1) { return "{ 'name' => 'value' }"; } To turn off the default namespace for all node names, use empty parameters for the C<struct> result attribute: sub sample_struct : struct("","") { return "{ 'name' => 'value' }"; } By default, XML attributes created with the C<nodeAttr> output attribute are not in a namespace. The shorthand notation can be used to specify a namespace. For example: nodeAttr(html:href:http://www.w3.org/TR/REC-html40,'http://www.axkit.org/') If you are specifying more than one attribute in the same namespace, you can refer to previously declared namespaces by using the same prefix: nodeAttr(html:href:http://www.w3.org/TR/REC-html40,'http://www.axkit.org/',html:class,'link') OTHER IDEAS THAT I ABANDONED: 1) create a separate set of result attributes with a 'NS' suffix: nodeNS(name,prefix,namespace) nodelistNS(name,prefix,namespace) exprOrNodeNS(name,prefix,namespace,attrname,attrvalue) exprOrNodelistNS(name,prefix,namespace,attrname,attrvalue) nodeAttrNS(name,prefix,namespace,expr,...) structNS(prefix,namespace) 2) use existing result attributes and include the prefix with the name: node(prefix:name,namespace) nodelist(prefix:name,namespace) exprOrNode(prefix:name,namespace,attrname,attrvalue) exprOrNodelist(prefix:name,namespace,attrname,attrvalue) nodeAttr(prefix:name,namespace,expr,...) struct(prefix,namespace) Both of these ideas were abandoned because it was too complicated to implement (requiring changes to the handling of perl attributes). I went ahead with the "shorthand" namespace declaration idea because it extends the node name parameter to include both the prefix and the namespace: node(prefix:name:namespace) nodelist(prefix:name:namespace) exprOrNode(prefix:name:namespace,attrname,attrvalue) exprOrNodelist(prefix:name:namespace,attrname,attrvalue) nodeAttr(prefix:name:namespace,expr,...) struct(prefix,namespace) which means I did not have to modify how the perl attributes were processed--I just had to modify how the node name was processed. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
