Package net.n3.nanoxml
Class ValidatorPlugin
java.lang.Object
net.n3.nanoxml.ValidatorPlugin
- All Implemented Interfaces:
IXMLValidator
ValidatorPlugin allows the application to insert additional validators into
NanoXML.
- Author:
- Marc De Scheemaecker
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
attributeAdded
(String key, String value, String systemId, int lineNr) This method is called when the attributes of an XML element have been processed.void
elementAttributesProcessed
(String name, Properties extraAttributes, String systemId, int lineNr) Indicates that an attribute has been added to the current element.void
elementEnded
(String name, String systemId, int lineNr) Indicates that the current element has ended.void
elementStarted
(String name, String systemId, int lineNr) Indicates that an element has been started.protected void
finalize()
Cleans up the object when it's destroyed.Returns the delegate.Returns the parameter entity resolver.void
invalidAttributeValue
(String systemID, int lineNr, String elementName, String attributeName, String attributeValue) Throws an XMLValidationException to indicate that an attribute has an invalid value.void
missingAttribute
(String systemID, int lineNr, String elementName, String attributeName) Throws an XMLValidationException to indicate that an attribute is missing.void
missingElement
(String systemID, int lineNr, String parentElementName, String missingElementName) Throws an XMLValidationException to indicate that an element is missing.void
missingPCData
(String systemID, int lineNr, String parentElementName) Throws an XMLValidationException to indicate that a #PCDATA element was missing.void
parseDTD
(String publicID, IXMLReader reader, IXMLEntityResolver entityResolver, boolean external) Parses the DTD.void
PCDataAdded
(String systemId, int lineNr) Indicates that a new #PCDATA element has been encountered.void
setDelegate
(IXMLValidator delegate) Sets the delegate.void
setParameterEntityResolver
(IXMLEntityResolver resolver) Sets the parameter entity resolver.void
unexpectedAttribute
(String systemID, int lineNr, String elementName, String attributeName) Throws an XMLValidationException to indicate that an attribute is unexpected.void
unexpectedElement
(String systemID, int lineNr, String parentElementName, String unexpectedElementName) Throws an XMLValidationException to indicate that an element is unexpected.void
unexpectedPCData
(String systemID, int lineNr, String parentElementName) Throws an XMLValidationException to indicate that a #PCDATA element was unexpected.void
validationError
(String systemID, int lineNr, String message, String elementName, String attributeName, String attributeValue) Throws an XMLValidationException.
-
Constructor Details
-
ValidatorPlugin
public ValidatorPlugin()Initializes the plugin.
-
-
Method Details
-
finalize
Cleans up the object when it's destroyed. -
getDelegate
Returns the delegate. -
setDelegate
Sets the delegate.- Parameters:
delegate
- the delegate
-
setParameterEntityResolver
Sets the parameter entity resolver.- Specified by:
setParameterEntityResolver
in interfaceIXMLValidator
- Parameters:
resolver
- the entity resolver.
-
getParameterEntityResolver
Returns the parameter entity resolver.- Specified by:
getParameterEntityResolver
in interfaceIXMLValidator
- Returns:
- the entity resolver.
-
parseDTD
public void parseDTD(String publicID, IXMLReader reader, IXMLEntityResolver entityResolver, boolean external) throws Exception Parses the DTD. The validator object is responsible for reading the full DTD.- Specified by:
parseDTD
in interfaceIXMLValidator
- Parameters:
publicID
- the public ID, which may be null.reader
- the reader to read the DTD from.entityResolver
- the entity resolver.external
- true if the DTD is external.- Throws:
Exception
- if something went wrong.
-
elementStarted
Indicates that an element has been started.- Specified by:
elementStarted
in interfaceIXMLValidator
- Parameters:
name
- the name of the element.systemId
- the system ID of the XML data of the element.lineNr
- the line number in the XML data of the element.- Throws:
Exception
- if the element could not be validated.
-
elementEnded
Indicates that the current element has ended.- Specified by:
elementEnded
in interfaceIXMLValidator
- Parameters:
name
- the name of the element.systemId
- the system ID of the XML data of the element.lineNr
- the line number in the XML data of the element.- Throws:
Exception
- if the element could not be validated.
-
elementAttributesProcessed
public void elementAttributesProcessed(String name, Properties extraAttributes, String systemId, int lineNr) throws Exception Indicates that an attribute has been added to the current element.- Specified by:
elementAttributesProcessed
in interfaceIXMLValidator
- Parameters:
name
- the name of the element.extraAttributes
- where to put extra attributes.systemId
- the system ID of the XML data of the element.lineNr
- the line number in the XML data of the element.key
- the name of the attribute.value
- the value of the attribute.- Throws:
Exception
- if the attribute could not be validated.
-
attributeAdded
This method is called when the attributes of an XML element have been processed. If there are attributes with a default value which have not been specified yet, they have to be put into extraAttributes.- Specified by:
attributeAdded
in interfaceIXMLValidator
- Parameters:
key
- the name of the attribute.value
- the value of the attribute.systemId
- the system ID of the XML data of the element.lineNr
- the line number in the XML data of the element.name
- the name of the element.extraAttributes
- where to put extra attributes.- Throws:
Exception
- if the element could not be validated.
-
PCDataAdded
Indicates that a new #PCDATA element has been encountered.- Specified by:
PCDataAdded
in interfaceIXMLValidator
- Parameters:
systemId
- the system ID of the XML data of the element.lineNr
- the line number in the XML data of the element.- Throws:
Exception
- if the element could not be validated.
-
missingElement
public void missingElement(String systemID, int lineNr, String parentElementName, String missingElementName) throws XMLValidationException Throws an XMLValidationException to indicate that an element is missing.- Parameters:
systemID
- the system ID of the XML data of the elementlineNr
- the line number in the XML data of the elementparentElementName
- the name of the parent elementmissingElementName
- the name of the missing element- Throws:
XMLValidationException
- of course :-)
-
unexpectedElement
public void unexpectedElement(String systemID, int lineNr, String parentElementName, String unexpectedElementName) throws XMLValidationException Throws an XMLValidationException to indicate that an element is unexpected.- Parameters:
systemID
- the system ID of the XML data of the elementlineNr
- the line number in the XML data of the elementparentElementName
- the name of the parent elementunexpectedElementName
- the name of the missing element- Throws:
XMLValidationException
- of course :-)
-
missingAttribute
public void missingAttribute(String systemID, int lineNr, String elementName, String attributeName) throws XMLValidationException Throws an XMLValidationException to indicate that an attribute is missing.- Parameters:
systemID
- the system ID of the XML data of the elementlineNr
- the line number in the XML data of the elementelementName
- the name of the elementattributeName
- the name of the missing attribute- Throws:
XMLValidationException
- of course :-)
-
unexpectedAttribute
public void unexpectedAttribute(String systemID, int lineNr, String elementName, String attributeName) throws XMLValidationException Throws an XMLValidationException to indicate that an attribute is unexpected.- Parameters:
systemID
- the system ID of the XML data of the elementlineNr
- the line number in the XML data of the elementelementName
- the name of the elementattributeName
- the name of the unexpected attribute- Throws:
XMLValidationException
- of course :-)
-
invalidAttributeValue
public void invalidAttributeValue(String systemID, int lineNr, String elementName, String attributeName, String attributeValue) throws XMLValidationException Throws an XMLValidationException to indicate that an attribute has an invalid value.- Parameters:
systemID
- the system ID of the XML data of the elementlineNr
- the line number in the XML data of the elementelementName
- the name of the elementattributeName
- the name of the attributeattributeValue
- the value of the attribute- Throws:
XMLValidationException
- of course :-)
-
missingPCData
public void missingPCData(String systemID, int lineNr, String parentElementName) throws XMLValidationException Throws an XMLValidationException to indicate that a #PCDATA element was missing.- Parameters:
systemID
- the system ID of the XML data of the elementlineNr
- the line number in the XML data of the elementparentElementName
- the name of the parent element- Throws:
XMLValidationException
- of course :-)
-
unexpectedPCData
public void unexpectedPCData(String systemID, int lineNr, String parentElementName) throws XMLValidationException Throws an XMLValidationException to indicate that a #PCDATA element was unexpected.- Parameters:
systemID
- the system ID of the XML data of the elementlineNr
- the line number in the XML data of the elementparentElementName
- the name of the parent element- Throws:
XMLValidationException
- of course :-)
-
validationError
public void validationError(String systemID, int lineNr, String message, String elementName, String attributeName, String attributeValue) throws XMLValidationException Throws an XMLValidationException.- Parameters:
systemID
- the system ID of the XML data of the elementlineNr
- the line number in the XML data of the elementmessage
- the error messageelementName
- the name of the element (may be null)attributeName
- the name of the attribute (may be null)attributeValue
- the value of the attribute (may be null)- Throws:
XMLValidationException
- of course :-)
-