This Version: August 5, 2001
Latest Version: http://simonstl.com/ns/namespaces/attributes/
Previous Version: None
Editors:
This vocabulary addresses problems created by the expectation that attributes without prefixes fall into the namespace of the element containing them (since they don't fall into the default namespace). Some vocabularies, notably RDF, are moving toward requirements that all attributes have explicit markup identifying the namespace to which they belong. It also provides a filter that will strip explicit namespace qualifications from attributes.
The com.simonstl.namespace.attributes.AttribNamespaceFilter
will use this vocabulary to convert markup that looks like:
<p:person xmlns:p="http://simonstl.com/person" givenName="Chip" familyName="Skillet" city="Ithaca" />
to:
<p:person xmlns:p="http://simonstl.com/person" p:givenName="Chip" p:familyName="Skillet" p:city="Ithaca" />
Warning: use of this technique may change the meaning of your documents substantially. Use it with care after studying options and impact.
Attribute rules work the same way as element rules, though they are defined in the http://simonstl.com/ns/namespaces/attributes/
namespace and identify the namespaces on elements whose attributes should be qualified to match the element.
All of these examples will operate on this document:
<p:person xmlns:p="http://simonstl.com/person" givenName="Chip" familyName="Skillet" city="Ithaca" />
The first set of rules converts attributes on elements in the http://simonstl.com/person
namespace:
<namespaces xmlns="http://simonstl.com/ns/namespaces/attributes/"> <include nsURI="http://simonstl.com/person" /> </namespaces>
Applying this rule produces:
C:\opensrc\namespace>java com.simonstl.namespace.attributes.AttribFilterTester qualAtt1.xml atttest.xml <?xml version="1.0" standalone="yes"?> <p:person p:givenName="Chip" p:familyName="Skillet" p:city="Ithaca" xmlns:p="http://simonstl.com/person"></p:person>
The second rule converts attributes on elements in any namespace:
<namespaces xmlns="http://simonstl.com/ns/namespaces/attributes/"> <include nsURI="##any" /> </namespaces>
Applying this rule produces:
C:\opensrc\namespace>java com.simonstl.namespace.attributes.AttribFilterTester qualAtt2.xml atttest.xml <?xml version="1.0" standalone="yes"?> <p:person p:givenName="Chip" p:familyName="Skillet" p:city="Ithaca" xmlns:p="http://simonstl.com/person"></p:person>
The next set of rules specifies the namespace as an inclusion and then blocks it with an exclusion:
<namespaces xmlns="http://simonstl.com/ns/namespaces/attributes/"> <include nsURI="http://simonstl.com/person" /> <exclude nsURI="http://simonstl.com/person" /> </namespaces>
This rule effectively doesn't modify anything:
C:\opensrc\namespace>java com.simonstl.namespace.attributes.AttribFilterTester qualAtt3.xml atttest.xml <?xml version="1.0" standalone="yes"?> <p:person givenName="Chip" familyName="Skillet" city="Ithaca" xmlns:p="http://simonstl.com/person"></p:person>
The final rule accepts any namespace for this processing, but it excludes the http://simonstl.com/person
namespace:
<namespaces xmlns="http://simonstl.com/ns/namespaces/attributes/"> <include nsURI="##any" /> <exclude nsURI="http://simonstl.com/person" /> </namespaces>
Again, blocking this particular namespace results in no modification of the original document:
C:\opensrc\namespace>java com.simonstl.namespace.attributes.AttribFilterTester qualAtt4.xml atttest.xml <?xml version="1.0" standalone="yes"?> <p:person givenName="Chip" familyName="Skillet" city="Ithaca" xmlns:p="http://simonstl.com/person"></p:person>