[XML-SIG] SAX2: Attribute extensions

Lars Marius Garshol larsga@ifi.uio.no
17 Apr 1999 18:06:12 +0200


This posting specifies two interfaces for information needed by the
DOM (and possibly also others) and also for full XML 1.0 conformance.
I'm not really sure whether we should actually use all of this, so
opinions are welcome.

class AttributeList2:

  def isSpecified(self,attr):
    """Returns true if the attribute was explicitly specified in the
    document and false otherwise. attr can be the attribute name or
    its index in the AttributeList."""

  def getEntityRefList(self,attr):
    """This returns the EntityRefList (see below) for an attribute,
    which can be specified by name or index."""


The class below is inteded to be used for discovering entity reference
boundaries inside attribute values. This is needed because the XML 1.0
recommendation requires parsers to report unexpanded entity references, 
also inside attribute values. Whether this is really
something we want is another matter.

class EntityRefList:

  def getLength(self):
    "Returns the number of entity references inside this attribute value."

  def getEntityName(self, ix):
    "Returns the name of entity reference number ix (zero-based index)."

  def getEntityRefStart(self, ix):
    """Returns the index of the first character inside the attribute
    value that stems from entity reference number ix."""

  def getEntityRefEnd(self, ix):
    "Returns the index of the last character in entity reference ix."


One redeeming feature of this interface is that it lives entirely
outside the attribute value, and so can be ignored entirely by those
who are not interested.