Top Description Fields Constructors Methods
com.sun.msv.verifier

public abstract Class AbstractVerifier

extends Object
implements ContentHandler, DTDHandler, IDContextProvider2
Class Inheritance
All Implemented Interfaces
com.sun.msv.grammar.IDContextProvider2, org.relaxng.datatype.ValidationContext, org.xml.sax.DTDHandler, org.xml.sax.ContentHandler
Known Direct Subclasses
com.sun.msv.verifier.Verifier
Imports
java.util.HashMap, .Map, .Set, .StringTokenizer, org.relaxng.datatype.Datatype, org.xml.sax.Attributes, .ContentHandler, .DTDHandler, .Locator, .SAXException, org.xml.sax.helpers.LocatorImpl, .NamespaceSupport, com.sun.msv.grammar.IDContextProvider2, com.sun.msv.verifier.regexp.StringToken

Base implementation for various Verifier implementations. This implementation provides common service like:
  1. collecting ID/IDREFs.
  2. storing Locator.

    By setting performIDcheck variable, the ID/IDREF checking can be either turned on or turned off.

Author
Kohsuke KAWAGUCHI

Field Summary

Modifier and TypeField and Description
private boolean
protected static final Locator
protected final Set<Object>
idrefs

this map remembers every IDREF token encountered in this document

protected final Map<Object, Object>
ids

this map remembers every ID token encountered in this document

protected Locator
locator

Document Locator that is given by XML reader.

protected final NamespaceSupport
namespaceSupport

namespace prefix to namespace URI resolver.

private final Set<String>
notations

declared notations.

protected boolean
performIDcheck

set this flag to true to perform ID/IDREF validation.

private final Set<String>
unparsedEntities

unparsed entities found in the document.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
endElement(String
the Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed
namespaceUri
,
String
the local name (without prefix), or the empty string if Namespace processing is not being performed
localName
,
String
the qualified XML name (with prefix), or the empty string if qualified names are not available
qName
)

Implements org.xml.sax.ContentHandler.endElement.

Receive notification of the end of an element.
public void
endPrefixMapping(String
the prefix that was being mapped. This is the empty string when a default mapping scope ends.
prefix
)

Implements org.xml.sax.ContentHandler.endPrefixMapping.

End the scope of a prefix-URI mapping.
public String
getBaseUri()

Implements org.relaxng.datatype.ValidationContext.getBaseUri.

Returns the base URI of the context.
public final Locator
protected void
init()

public boolean
isNotation(String notationName)

Implements org.relaxng.datatype.ValidationContext.isNotation.

Checks if a notation is declared with the specified name.
public boolean
isUnparsedEntity(String entityName)

Implements org.relaxng.datatype.ValidationContext.isUnparsedEntity.

Checks if an unparsed entity is declared with the specified name.
public void
notationDecl(String
The notation name.
name
,
String
The notation's public identifier, or null if none was given.
publicId
,
String
The notation's system identifier, or null if none was given.
systemId
)

Implements org.xml.sax.DTDHandler.notationDecl.

Receive notification of a notation declaration event.
protected abstract void
onDuplicateId(String id)

this method is called when a duplicate id value is found.

public void
onID(Datatype dt, StringToken token)

Implements com.sun.msv.grammar.IDContextProvider2.onID.

this method is called when a type with ID semantics is matched.
public void
processingInstruction(String
the processing instruction target
name
,
String
the processing instruction data, or null if none was supplied. The data does not include any whitespace separating it from the target
data
)

Implements org.xml.sax.ContentHandler.processingInstruction.

Receive notification of a processing instruction.
public String
resolveNamespacePrefix(String prefix)

Implements org.relaxng.datatype.ValidationContext.resolveNamespacePrefix.

Resolves a namespace prefix to the corresponding namespace URI.
public void
setDocumentLocator(Locator
an object that can return the location of any SAX document event
loc
)

Implements org.xml.sax.ContentHandler.setDocumentLocator.

Receive an object for locating the origin of SAX document events.
public void
skippedEntity(String
the name of the skipped entity. If it is a parameter entity, the name will begin with '%', and if it is the external DTD subset, it will be the string "[dtd]"
p
)

Implements org.xml.sax.ContentHandler.skippedEntity.

Receive notification of a skipped entity.
public void
startElement(String
the Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed
namespaceUri
,
String
the local name (without prefix), or the empty string if Namespace processing is not being performed
localName
,
String
the qualified name (with prefix), or the empty string if qualified names are not available
qName
,
Attributes
the attributes attached to the element. If there are no attributes, it shall be an empty Attributes object. The value of this object after startElement returns is undefined
atts
)

Implements org.xml.sax.ContentHandler.startElement.

Receive notification of the beginning of an element.
public void
startPrefixMapping(String
the Namespace prefix being declared. An empty string is used for the default element namespace, which has no prefix.
prefix
,
String
the Namespace URI the prefix is mapped to
uri
)

Implements org.xml.sax.ContentHandler.startPrefixMapping.

Begin the scope of a prefix-URI Namespace mapping.
public void
unparsedEntityDecl(String
The unparsed entity's name.
name
,
String
The entity's public identifier, or null if none was given.
publicId
,
String
The entity's system identifier.
systemId
,
String
The name of the associated notation.
notationName
)

Implements org.xml.sax.DTDHandler.unparsedEntityDecl.

Receive notification of an unparsed entity declaration event.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contextPushedback to summary
private boolean contextPushed
dummyLocatorback to summary
protected static final Locator dummyLocator
idrefsback to summary
protected final Set<Object> idrefs

this map remembers every IDREF token encountered in this document

idsback to summary
protected final Map<Object, Object> ids

this map remembers every ID token encountered in this document

locatorback to summary
protected Locator locator

Document Locator that is given by XML reader. Sometimes it doesn't set the locator, so start with a dummy instance.

namespaceSupportback to summary
protected final NamespaceSupport namespaceSupport

namespace prefix to namespace URI resolver. this object memorizes mapping information.

notationsback to summary
private final Set<String> notations

declared notations.

performIDcheckback to summary
protected boolean performIDcheck

set this flag to true to perform ID/IDREF validation. this value cannot be modified in the middle of the validation.

unparsedEntitiesback to summary
private final Set<String> unparsedEntities

unparsed entities found in the document.

Constructor Detail

AbstractVerifierback to summary
public AbstractVerifier()

Method Detail

endElementback to summary
public void endElement(String namespaceUri, String localName, String qName) throws SAXException

Implements org.xml.sax.ContentHandler.endElement.

Doc from org.xml.sax.ContentHandler.endElement.

Receive notification of the end of an element.

The SAX parser will invoke this method at the end of every element in the XML document; there will be a corresponding startElement event for every endElement event (even when the element is empty).

For information on the names, see startElement.

Parameters
namespaceUri:String

the Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed

localName:String

the local name (without prefix), or the empty string if Namespace processing is not being performed

qName:String

the qualified XML name (with prefix), or the empty string if qualified names are not available

Exceptions
SAXException:
any SAX exception, possibly wrapping another exception
endPrefixMappingback to summary
public void endPrefixMapping(String prefix)

Implements org.xml.sax.ContentHandler.endPrefixMapping.

Doc from org.xml.sax.ContentHandler.endPrefixMapping.

End the scope of a prefix-URI mapping.

See startPrefixMapping for details. These events will always occur immediately after the corresponding endElement event, but the order of endPrefixMapping events is not otherwise guaranteed.

Parameters
prefix:String

the prefix that was being mapped. This is the empty string when a default mapping scope ends.

getBaseUriback to summary
public String getBaseUri()

Implements org.relaxng.datatype.ValidationContext.getBaseUri.

Doc from org.relaxng.datatype.ValidationContext.getBaseUri.

Returns the base URI of the context. The null string may be returned if no base URI is known.

getLocatorback to summary
public final Locator getLocator()
initback to summary
protected void init()
isNotationback to summary
public boolean isNotation(String notationName)

Implements org.relaxng.datatype.ValidationContext.isNotation.

Doc from org.relaxng.datatype.ValidationContext.isNotation.

Checks if a notation is declared with the specified name.

Returns:boolean

true if the DTD has a notation declaration for the specified name. false otherwise.

isUnparsedEntityback to summary
public boolean isUnparsedEntity(String entityName)

Implements org.relaxng.datatype.ValidationContext.isUnparsedEntity.

Doc from org.relaxng.datatype.ValidationContext.isUnparsedEntity.

Checks if an unparsed entity is declared with the specified name.

Returns:boolean

true if the DTD has an unparsed entity declaration for the specified name. false otherwise.

notationDeclback to summary
public void notationDecl(String name, String publicId, String systemId)

Implements org.xml.sax.DTDHandler.notationDecl.

Doc from org.xml.sax.DTDHandler.notationDecl.

Receive notification of a notation declaration event.

It is up to the application to record the notation for later reference, if necessary; notations may appear as attribute values and in unparsed entity declarations, and are sometime used with processing instruction target names.

At least one of publicId and systemId must be non-null. If a system identifier is present, and it is a URL, the SAX parser must resolve it fully before passing it to the application through this event.

There is no guarantee that the notation declaration will be reported before any unparsed entities that use it.

Parameters
name:String

The notation name.

publicId:String

The notation's public identifier, or null if none was given.

systemId:String

The notation's system identifier, or null if none was given.

onDuplicateIdback to summary
protected abstract void onDuplicateId(String id)

this method is called when a duplicate id value is found.

onIDback to summary
public void onID(Datatype dt, StringToken token)

Implements com.sun.msv.grammar.IDContextProvider2.onID.

Doc from com.sun.msv.grammar.IDContextProvider2.onID.

this method is called when a type with ID semantics is matched. It is the callee's responsibility that stores ID and checks doubly defined ID, if it is necessary.

processingInstructionback to summary
public void processingInstruction(String name, String data)

Implements org.xml.sax.ContentHandler.processingInstruction.

Doc from org.xml.sax.ContentHandler.processingInstruction.

Receive notification of a processing instruction.

The Parser will invoke this method once for each processing instruction found: note that processing instructions may occur before or after the main document element.

A SAX parser must never report an XML declaration (XML 1.0, section 2.8) or a text declaration (XML 1.0, section 4.3.1) using this method.

Like characters(), processing instruction data may have characters that need more than one char value.

Parameters
name:String

the processing instruction target

data:String

the processing instruction data, or null if none was supplied. The data does not include any whitespace separating it from the target

resolveNamespacePrefixback to summary
public String resolveNamespacePrefix(String prefix)

Implements org.relaxng.datatype.ValidationContext.resolveNamespacePrefix.

Doc from org.relaxng.datatype.ValidationContext.resolveNamespacePrefix.

Resolves a namespace prefix to the corresponding namespace URI. This method is used for validating the QName type, for example.

If the prefix is "" (empty string), it indicates an unprefixed value. The callee should resolve it as for an unprefixed element, rather than for an unprefixed attribute.

If the prefix is "xml", then the callee must resolve this prefix into "http://www.w3.org/XML/1998/namespace", as defined in the XML Namespaces Recommendation.

Returns:String

namespace URI of this prefix. If the specified prefix is not declared, the implementation must return null.

setDocumentLocatorback to summary
public void setDocumentLocator(Locator loc)

Implements org.xml.sax.ContentHandler.setDocumentLocator.

Doc from org.xml.sax.ContentHandler.setDocumentLocator.

Receive an object for locating the origin of SAX document events.

SAX parsers are strongly encouraged (though not absolutely required) to supply a locator: if it does so, it must supply the locator to the application by invoking this method before invoking any of the other methods in the ContentHandler interface.

The locator allows the application to determine the end position of any document-related event, even if the parser is not reporting an error. Typically, the application will use this information for reporting its own errors (such as character content that does not match an application's business rules). The information returned by the locator is probably not sufficient for use with a search engine.

Note that the locator will return correct information only during the invocation SAX event callbacks after startDocument returns and before endDocument is called. The application should not attempt to use it at any other time.

Parameters
loc:Locator

an object that can return the location of any SAX document event

skippedEntityback to summary
public void skippedEntity(String p)

Implements org.xml.sax.ContentHandler.skippedEntity.

Doc from org.xml.sax.ContentHandler.skippedEntity.

Receive notification of a skipped entity. This is not called for entity references within markup constructs such as element start tags or markup declarations. (The XML recommendation requires reporting skipped external entities. SAX also reports internal entity expansion/non-expansion, except within markup constructs.)

The Parser will invoke this method each time the entity is skipped. Non-validating processors may skip entities if they have not seen the declarations (because, for example, the entity was declared in an external DTD subset). All processors may skip external entities, depending on the values of the http://xml.org/sax/features/external-general-entities and the http://xml.org/sax/features/external-parameter-entities properties.

Parameters
p:String

the name of the skipped entity. If it is a parameter entity, the name will begin with '%', and if it is the external DTD subset, it will be the string "[dtd]"

startElementback to summary
public void startElement(String namespaceUri, String localName, String qName, Attributes atts) throws SAXException

Implements org.xml.sax.ContentHandler.startElement.

Doc from org.xml.sax.ContentHandler.startElement.

Receive notification of the beginning of an element.

The Parser will invoke this method at the beginning of every element in the XML document; there will be a corresponding endElement event for every startElement event (even when the element is empty). All of the element's content will be reported, in order, before the corresponding endElement event.

This event allows up to three name components for each element:

  1. the Namespace URI;
  2. the local name; and
  3. the qualified (prefixed) name.

Any or all of these may be provided, depending on the values of the http://xml.org/sax/features/namespaces and the http://xml.org/sax/features/namespace-prefixes properties:

  • the Namespace URI and local name are required when the namespaces property is true (the default), and are optional when the namespaces property is false (if one is specified, both must be);
  • the qualified name is required when the namespace-prefixes property is true, and is optional when the namespace-prefixes property is false (the default).

Note that the attribute list provided will contain only attributes with explicit values (specified or defaulted): #IMPLIED attributes will be omitted. The attribute list will contain attributes used for Namespace declarations (xmlns* attributes) only if the http://xml.org/sax/features/namespace-prefixes property is true (it is false by default, and support for a true value is optional).

Like characters(), attribute values may have characters that need more than one char value.

Parameters
namespaceUri:String

the Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed

localName:String

the local name (without prefix), or the empty string if Namespace processing is not being performed

qName:String

the qualified name (with prefix), or the empty string if qualified names are not available

atts:Attributes

the attributes attached to the element. If there are no attributes, it shall be an empty Attributes object. The value of this object after startElement returns is undefined

Exceptions
SAXException:
any SAX exception, possibly wrapping another exception
startPrefixMappingback to summary
public void startPrefixMapping(String prefix, String uri)

Implements org.xml.sax.ContentHandler.startPrefixMapping.

Doc from org.xml.sax.ContentHandler.startPrefixMapping.

Begin the scope of a prefix-URI Namespace mapping.

The information from this event is not necessary for normal Namespace processing: the SAX XML reader will automatically replace prefixes for element and attribute names when the http://xml.org/sax/features/namespaces feature is true (the default).

There are cases, however, when applications need to use prefixes in character data or in attribute values, where they cannot safely be expanded automatically; the start/endPrefixMapping event supplies the information to the application to expand prefixes in those contexts itself, if necessary.

Note that start/endPrefixMapping events are not guaranteed to be properly nested relative to each other: all startPrefixMapping events will occur immediately before the corresponding startElement event, and all endPrefixMapping events will occur immediately after the corresponding endElement event, but their order is not otherwise guaranteed.

There should never be start/endPrefixMapping events for the "xml" prefix, since it is predeclared and immutable.

Parameters
prefix:String

the Namespace prefix being declared. An empty string is used for the default element namespace, which has no prefix.

uri:String

the Namespace URI the prefix is mapped to

unparsedEntityDeclback to summary
public void unparsedEntityDecl(String name, String publicId, String systemId, String notationName)

Implements org.xml.sax.DTDHandler.unparsedEntityDecl.

Doc from org.xml.sax.DTDHandler.unparsedEntityDecl.

Receive notification of an unparsed entity declaration event.

Note that the notation name corresponds to a notation reported by the notationDecl event. It is up to the application to record the entity for later reference, if necessary; unparsed entities may appear as attribute values.

If the system identifier is a URL, the parser must resolve it fully before passing it to the application.

Parameters
name:String

The unparsed entity's name.

publicId:String

The entity's public identifier, or null if none was given.

systemId:String

The entity's system identifier.

notationName:String

The name of the associated notation.