OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: SAX2 RFD: LexicalHandler draft v.1.1

[ Lists Home | Date Index | Thread Index ]
  • From: David Megginson <david@megginson.com>
  • To: "XML Developers' List" <xml-dev@ic.ac.uk>
  • Date: Sun, 21 Mar 1999 13:59:35 -0500 (EST)

James Clark writes:

 > David Megginson wrote:
 > 
 > >     public abstract void startEntity (String name)
 > >         throws SAXException;
 > > 
 > >     public abstract void endEntity (String name)
 > >         throws SAXException;
 > 
 > How does this allow me to find out about entity references in attribute
 > values (including defaulted attribute values)?

This is an interesting problem, and I was thinking about it last night 
while I was out walking my dog.  One possible solution is to extend
AttributeList to provide access to this information somehow (as we'll
be extending it, no doubt, to provide access to isSpecified
information).  Here's one alternative:

  public interface AttributeValueHandler
  {
    public abstract void startEntity (String name)
      throws SAXException;
    public abstract void endEntity (String name)
      throws SAXException;
    public abstract void characters (char ch[], int start, int length)
      throws SAXException;
  }

  public interface AttributeValue2 extends AttributeValue
  {
    public abstract boolean isSpecified (String name);
    public abstract void accept (AttributeValueHandler handler)
      throws SAXException;
  }

With this approach, the 99.9% of SAX applications that don't care
about entity boundaries within attribute values can continue to use
getValue() (which returns a literal string), while the others can use
AttributeValueHandler if the parser supports it -- of course, the
parser can throw a SAXNotSupportedException if it thinks that this
whole thing is too pathological.

 > It might be convenient to distinguish parameter entities and general
 > entities here.  The application can do this itself by maintaining the
 > appropriate state, but there doesn't seem any advantage in munging
 > together general and parameter entities.

There are two alternatives here:

1. Declare that PEs will always have '%' prepended to their names; or
2. add a boolean parameter isParameterEntity.

I'll add (2) for now.

 > How would general entity references in default attribute values in
 > attribute list declarations be handled?

Probably using a method similar to the one I specified above.  Now I
remember why I didn't want to cover DTD-related events in SAX...

 > Would all parameter entity references be reported or just those at the
 > top-level (ie between markup declarations)?

All, I'd imagine -- would there be a good reason for not doing so?

 > I don't think support for entities can be fully designed without also
 > considering DTD information.

Correct -- I apologise for my omitted note from earlier (which Lars
also caught).  I am assuming that there is already a mechanism for
reporting entity declarations.


All the best,


David

-- 
David Megginson                 david@megginson.com
           http://www.megginson.com/

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To (un)subscribe, mailto:majordomo@ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@ic.ac.uk)





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS