Class XmlParser
java.lang.Object
com.icl.saxon.aelfred.XmlParser
Parse XML documents and return parse events through call-backs.
Use the
SAXDriver class as your entry point, as all
internal parser interfaces are subject to change.- Version:
- $Date: 2000/05/29 12:10:24 $
- Author:
- Written by David Megginson <dmeggins@microstar.com> (version 1.2a with bugfixes), Updated by David Brownell <david-b@pacbell.net>
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intConstant: the attribute value is a string value.static final intConstant: the attribute was declared #FIXED.static final intConstant: the attribute was declared #IMPLIED.static final intConstant: the attribute was declared #REQUIRED.static final intConstant: the attribute has a literal default value specified.static final intConstant: the attribute is not declared.static final intConstant: the attribute value is a list of entity names.static final intConstant: the attribute value is the name of an entity.static final intConstant: the attribute value is a token from an enumeration.static final intConstant: the attribute value is a unique identifier.static final intConstant: the attribute value is a reference to a unique identifier.static final intConstant: the attribute value is a list of ID references.static final intConstant: the attribute value is a name token.static final intConstant: the attribute value is a list of name tokens.static final intConstant: the attribute is the name of a notation.static final intConstant: the attribute has not been declared for this element type.static final intConstant: the element has a content model of ANY.static final intConstant: the element has element content.static final intConstant: the element has declared content of EMPTY.static final intConstant: the element has mixed content.static final intConstant: an element has not been declared.static final intConstant: the entity is internal.static final intConstant: the entity is external, non-XML data.static final intConstant: the entity is external XML data.static final intConstant: the entity has not been declared. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondeclaredAttributes(String elname) Get the declared attributes for an element type.Get the declared elements for an XML document.Get declared entities.Get declared notations.(package private) voidParse an XML document from the character stream, byte stream, or URI that you provide (in that order of preference).getAttributeDefaultValue(String name, String aname) Retrieve the default value of a declared attribute.intgetAttributeDefaultValueType(String name, String aname) Retrieve the default value type of a declared attribute.getAttributeEnumeration(String name, String aname) Retrieve the allowed values for an enumerated attribute type.getAttributeExpandedValue(String name, String aname) Retrieve the expanded value of a declared attribute.intgetAttributeType(String name, String aname) Retrieve the declared type of an attribute.intReturn the current column number.getElementContentModel(String name) Look up the content model of an element.intgetElementContentType(String name) Look up the content type of an element.getEntityNotationName(String eName) Get the notation name associated with an NDATA entity.getEntityPublicId(String ename) Return an external entity's public identifier, if any.getEntitySystemId(String ename) Return an external entity's system identifier.intgetEntityType(String ename) Find the type of an entity.getEntityValue(String ename) Return the value of an internal entity.intReturn the current line number.getNotationPublicId(String nname) Look up the public identifier for a notation.getNotationSystemId(String nname) Look up the system identifier for a notation.intern(char[] ch, int start, int length) Create an interned string from a character array.(package private) voidsetHandler(SAXDriver handler) Set the handler that will receive parsing events.
-
Field Details
-
CONTENT_UNDECLARED
public static final int CONTENT_UNDECLAREDConstant: an element has not been declared.- See Also:
-
CONTENT_ANY
public static final int CONTENT_ANYConstant: the element has a content model of ANY.- See Also:
-
CONTENT_EMPTY
public static final int CONTENT_EMPTYConstant: the element has declared content of EMPTY.- See Also:
-
CONTENT_MIXED
public static final int CONTENT_MIXEDConstant: the element has mixed content.- See Also:
-
CONTENT_ELEMENTS
public static final int CONTENT_ELEMENTSConstant: the element has element content.- See Also:
-
ENTITY_UNDECLARED
public static final int ENTITY_UNDECLAREDConstant: the entity has not been declared.- See Also:
-
ENTITY_INTERNAL
public static final int ENTITY_INTERNALConstant: the entity is internal.- See Also:
-
ENTITY_NDATA
public static final int ENTITY_NDATAConstant: the entity is external, non-XML data.- See Also:
-
ENTITY_TEXT
public static final int ENTITY_TEXTConstant: the entity is external XML data.- See Also:
-
ATTRIBUTE_UNDECLARED
public static final int ATTRIBUTE_UNDECLAREDConstant: the attribute has not been declared for this element type.- See Also:
-
ATTRIBUTE_CDATA
public static final int ATTRIBUTE_CDATAConstant: the attribute value is a string value.- See Also:
-
ATTRIBUTE_ID
public static final int ATTRIBUTE_IDConstant: the attribute value is a unique identifier.- See Also:
-
ATTRIBUTE_IDREF
public static final int ATTRIBUTE_IDREFConstant: the attribute value is a reference to a unique identifier.- See Also:
-
ATTRIBUTE_IDREFS
public static final int ATTRIBUTE_IDREFSConstant: the attribute value is a list of ID references.- See Also:
-
ATTRIBUTE_ENTITY
public static final int ATTRIBUTE_ENTITYConstant: the attribute value is the name of an entity.- See Also:
-
ATTRIBUTE_ENTITIES
public static final int ATTRIBUTE_ENTITIESConstant: the attribute value is a list of entity names.- See Also:
-
ATTRIBUTE_NMTOKEN
public static final int ATTRIBUTE_NMTOKENConstant: the attribute value is a name token.- See Also:
-
ATTRIBUTE_NMTOKENS
public static final int ATTRIBUTE_NMTOKENSConstant: the attribute value is a list of name tokens.- See Also:
-
ATTRIBUTE_ENUMERATED
public static final int ATTRIBUTE_ENUMERATEDConstant: the attribute value is a token from an enumeration.- See Also:
-
ATTRIBUTE_NOTATION
public static final int ATTRIBUTE_NOTATIONConstant: the attribute is the name of a notation.- See Also:
-
ATTRIBUTE_DEFAULT_UNDECLARED
public static final int ATTRIBUTE_DEFAULT_UNDECLAREDConstant: the attribute is not declared.- See Also:
-
ATTRIBUTE_DEFAULT_SPECIFIED
public static final int ATTRIBUTE_DEFAULT_SPECIFIEDConstant: the attribute has a literal default value specified.- See Also:
-
ATTRIBUTE_DEFAULT_IMPLIED
public static final int ATTRIBUTE_DEFAULT_IMPLIEDConstant: the attribute was declared #IMPLIED.- See Also:
-
ATTRIBUTE_DEFAULT_REQUIRED
public static final int ATTRIBUTE_DEFAULT_REQUIREDConstant: the attribute was declared #REQUIRED.- See Also:
-
ATTRIBUTE_DEFAULT_FIXED
public static final int ATTRIBUTE_DEFAULT_FIXEDConstant: the attribute was declared #FIXED.- See Also:
-
-
Constructor Details
-
XmlParser
XmlParser()Construct a new parser with no associated handler.- See Also:
-
-
Method Details
-
setHandler
Set the handler that will receive parsing events.- Parameters:
handler- The handler to receive callback events.- See Also:
-
doParse
void doParse(String systemId, String publicId, Reader reader, InputStream stream, String encoding) throws Exception Parse an XML document from the character stream, byte stream, or URI that you provide (in that order of preference). Any URI that you supply will become the base URI for resolving relative URI, and may be used to acquire a reader or byte stream.You may parse more than one document, but that must be done sequentially. Only one thread at a time may use this parser.
- Parameters:
systemId- The URI of the document; should never be null, but may be so iff a reader or a stream is provided.publicId- The public identifier of the document, or null.reader- A character stream; must be null if stream isn't.stream- A byte input stream; must be null if reader isn't.encoding- The suggested encoding, or null if unknown.- Throws:
Exception- Basically SAXException or IOException
-
intern
Create an interned string from a character array. Ælfred uses this method to create an interned version of all names and name tokens, so that it can test equality with==instead ofString.equals ().This is much more efficient than constructing a non-interned string first, and then interning it.
- Parameters:
ch- an array of characters for building the string.start- the starting position in the array.length- the number of characters to place in the string.- Returns:
- an interned string.
- See Also:
-
declaredElements
Get the declared elements for an XML document.The results will be valid only after the DTD (if any) has been parsed.
- Returns:
- An enumeration of all element types declared for this document (as Strings).
- See Also:
-
getElementContentType
Look up the content type of an element.- Parameters:
name- The element type name.- Returns:
- An integer constant representing the content type.
- See Also:
-
getElementContentModel
-
declaredAttributes
Get the declared attributes for an element type.- Parameters:
elname- The name of the element type.- Returns:
- An Enumeration of all the attributes declared for a specific element type. The results will be valid only after the DTD (if any) has been parsed.
- See Also:
-
getAttributeType
-
getAttributeEnumeration
-
getAttributeDefaultValue
Retrieve the default value of a declared attribute.- Parameters:
name- The name of the associated element.aname- The name of the attribute.- Returns:
- The default value, or null if the attribute was #IMPLIED or simply undeclared and unspecified.
- See Also:
-
getAttributeExpandedValue
Retrieve the expanded value of a declared attribute.General entities will be expanded (once).
- Parameters:
name- The name of the associated element.aname- The name of the attribute.- Returns:
- The expanded default value, or null if the attribute was #IMPLIED or simply undeclared
- Throws:
Exception- See Also:
-
getAttributeDefaultValueType
-
declaredEntities
Get declared entities.- Returns:
- An Enumeration of all the entities declared for this XML document. The results will be valid only after the DTD (if any) has been parsed.
- See Also:
-
getEntityType
-
getEntityPublicId
Return an external entity's public identifier, if any.- Parameters:
ename- The name of the external entity.- Returns:
- The entity's system identifier, or null if the entity was not declared, if it is not an external entity, or if no public identifier was provided.
- See Also:
-
getEntitySystemId
-
getEntityValue
-
getEntityNotationName
-
declaredNotations
Get declared notations.- Returns:
- An Enumeration of all the notations declared for this XML document. The results will be valid only after the DTD (if any) has been parsed.
- See Also:
-
getNotationPublicId
Look up the public identifier for a notation. You will normally use this method to look up a notation that was provided as an attribute value or for an NDATA entity.- Parameters:
nname- The name of the notation.- Returns:
- A string containing the public identifier, or null if none was provided or if no such notation was declared.
- See Also:
-
getNotationSystemId
Look up the system identifier for a notation. You will normally use this method to look up a notation that was provided as an attribute value or for an NDATA entity.- Parameters:
nname- The name of the notation.- Returns:
- A string containing the system identifier, or null if no such notation was declared.
- See Also:
-
getLineNumber
public int getLineNumber()Return the current line number. -
getColumnNumber
public int getColumnNumber()Return the current column number.
-