RDF/XML Syntax Bug: Missing Parent Accessor

Section 6 of the RDF/XML Syntax Specification (Revised) [1] says that
the parent property of the element information item in the XML Infoset
is required, but section 6.1.2 Element Event does not create a parent
accessor for that event.

Element events therefore do not have a parent accessor, and yet a
parent accessor on element events is made use of in the following
sections:

7.2.14 Production propertyElt
7.2.15 Production resourcePropertyElt
7.2.16 Production literalPropertyElt
7.2.17 Production parseTypeLiteralPropertyElt
7.2.18 Production parseTypeResourcePropertyElt
7.2.19 Production parseTypeCollectionPropertyElt
7.2.21 Production emptyPropertyElt

The intent must have been that element events are passed the element
information item's parent property to be set as a parent accessor.
That it does not specify this is a bug.

The specification could (should?) also have noted for convenience that
when one is to "create a new sequence of events" in 7.2.18 Production
parseTypeResourcePropertyElt, the setting of the parent accessor on
new element events may in practice have to take place in the handling
of propertyEltList if, for example, you're using a strictly streaming
XML parser.

In an implementation that I've written, for example, the child.parent
= e assignment in the following:

   def propertyEltList(self, e):
      for child in elements(e.children):
         child.parent = e
         self.propertyElt(child)

Is necessary due to the construction that takes place here:

   def parseTypeResourcePropertyElt(self, e):
      [...]
      local_name = u'Description'
      children = e.children
      base_uri = e.base_uri
      nodeElt = Element(local_name, rdf.name, children, base_uri, {}, e)
      nodeElt.subject = n
      self.nodeElement(nodeElt)

Given that e.children, a generator, cannot be consumed at that point.

Thanks,

[1] http://www.w3.org/TR/2004/REC-rdf-syntax-grammar-20040210/

-- 
Sean B. Palmer, http://inamidst.com/sbp/

Received on Thursday, 1 November 2007 10:01:35 UTC