[
Lists Home |
Date Index |
Thread Index
]
- From: James Clark <jjc@jclark.com>
- To: xml-dev Mailing List <xml-dev@ic.ac.uk>
- Date: Wed, 25 Feb 1998 09:42:14 +0700
> package org.xml.sax;
>
> public interface AttributeList {
>
> public abstract int getLength ();
> public abstract String getName (int index);
> public abstract String getValue (int index);
I think it's also desirable to provide a method to access attribute
values by name. Some applications only want to access attribute values
this way, and it's inconvenient and inefficient for the application to
have to iterate over all the names itself.
> public abstract String getType (int index);
I like this.
> public abstract String getEntityNotationName (int index);
> public abstract String getEntityPublicId (int index);
> public abstract String getEntitySystemId (int index);
> public abstract String getNotationPublicId (int index);
> public abstract String getNotationSystemId (int index);
I agree that SAX ought to provide access to unparsed entities but I
don't think this is the right way to achieve it. For a start, I can
have an ENTITIES attribute, so all these methods would need two
arguments (the index of the attribute in the attribute list, and the
index of the token in the value).
Another problem is that it is common to declare unparsed entities in the
internal subset, but to declare attribute types in an external DTD, eg
<!DOCTYPE doc SYSTEM "doc.dtd" [
<!ENTITY foo SYSTEM "foo.pic" NDATA gif>
]>
<doc><picture ref="foo"/></doc>
where doc.dtd contains
<!ATTLIST picture ref ENTITY #IMPLIED>
Now if I parse this without processing the external DTD, the SAX
interface as I understand it won't allow be to get at the system and
public id for foo, although an application might well intrinsically know
that ref is an ENTITY attribute.
I think a better approach is for the processor at the end of the prolog
to pass an object to the application that provides information about all
the declared notations and unparsed entities.
XP has a DTD object that does this, but it might be better to call it
something else (like UnparsedEntitySet) since SAX might someday be
extended to provide full DTD access.
Note that if you provide access to the system ID, you have to deal with
the issue of relative URLs. Either the processor has to resolve a
relative URL into an absolute URL before passing to the application, or
it ha to make available a base URL to the application.
Here's what XP's DTD interface looks like (it's a little fancier than
what's I think is needed for SAX in that it provides access to all
general entities not just unparsed ones):
package com.jclark.xml.parse;
import java.util.Enumeration;
import java.net.URL;
/**
* Information about a DTD.
* @version $Revision: 1.4 $ $Date: 1998/02/17 04:20:20 $
*/
public interface DTD {
/**
* Returns an enumeration over the names of general entities declared
in
* the DTD.
*/
Enumeration entityNames();
/**
* Returns an enumeration over the names of notations declared in
* the DTD.
*/
Enumeration notationNames();
/**
* Returns the system identifier for a notation.
* Returns null if the notation was not declared or no system
identifier
* was specified.
* A relative URL is not automatically resolved into an absolute URL;
* <code>getNotationBase</code> can be used to do this.
*
* @see #getNotationBase
*/
String getNotationSystemId(String notationName);
/**
* Returns the public identifier for a notation.
* Returns null if the notation was not declared or no public
identifier
* was specified.
*/
String getNotationPublicId(String notationName);
/**
* Returns the URL of the entity in which the notation was declared.
* Returns null if the entity was not declared or the URL of the
* declaring entity is not available.
*/
URL getNotationBase(String notationName);
/**
* Returns the replacement text of the specified general entity.
* Returns null if the entity was not declared or was
* as an external entity.
*/
String getEntityReplacementText(String entityName);
/**
* Returns the system identifier for a general entity.
* Returns null if the entity was not declared or is an internal
entity.
* A relative URL is not automatically resolved into an absolute URL;
* <code>getNotationBase</code> can be used to do this.
*
* @see #getEntityBase
*/
String getEntitySystemId(String entityName);
/**
* Returns the public identifier for a general entity.
* Returns null if the entity was not declared or no public identifier
* was specified.
*/
String getEntityPublicId(String entityName);
/**
* Returns the name of the notation of an unparsed general entity.
* Returns null if the entity was not declared or was a parsed entity.
*/
String getEntityNotationName(String entityName);
/**
* Returns the URL of the entity in which the general entity was
declared.
* Returns null if the entity was not declared or the URL of the
* declaring entity is not available.
*/
URL getEntityBase(String entityName);
/**
* Returns true if an element type was declared to have element
content.
*/
boolean getElementTypeElementContent(String elementTypeName);
/**
* Returns true if the complete DTD was processed.
*/
boolean isComplete();
/**
* Returns true if <code>standalone="yes"</code> was specified in the
* XML declaration.
*/
boolean isStandalone();
}
James
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/
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)
|