001: /* IXMLValidator.java NanoXML/Java
002: *
003: * $Revision: 1.3 $
004: * $Date: 2002/01/04 21:03:28 $
005: * $Name: RELEASE_2_2_1 $
006: *
007: * This file is part of NanoXML 2 for Java.
008: * Copyright (C) 2000-2002 Marc De Scheemaecker, All Rights Reserved.
009: *
010: * This software is provided 'as-is', without any express or implied warranty.
011: * In no event will the authors be held liable for any damages arising from the
012: * use of this software.
013: *
014: * Permission is granted to anyone to use this software for any purpose,
015: * including commercial applications, and to alter it and redistribute it
016: * freely, subject to the following restrictions:
017: *
018: * 1. The origin of this software must not be misrepresented; you must not
019: * claim that you wrote the original software. If you use this software in
020: * a product, an acknowledgment in the product documentation would be
021: * appreciated but is not required.
022: *
023: * 2. Altered source versions must be plainly marked as such, and must not be
024: * misrepresented as being the original software.
025: *
026: * 3. This notice may not be removed or altered from any source distribution.
027: */
028:
029: package net.n3.nanoxml;
030:
031: import java.io.Reader;
032: import java.io.IOException;
033: import java.util.Properties;
034:
035: /**
036: * IXMLValidator processes the DTD and handles entity references.
037: *
038: * @author Marc De Scheemaecker
039: * @version $Name: RELEASE_2_2_1 $, $Revision: 1.3 $
040: */
041: public interface IXMLValidator {
042:
043: /**
044: * Sets the parameter entity resolver.
045: *
046: * @param resolver the entity resolver.
047: */
048: public void setParameterEntityResolver(IXMLEntityResolver resolver);
049:
050: /**
051: * Returns the parameter entity resolver.
052: *
053: * @return the entity resolver.
054: */
055: public IXMLEntityResolver getParameterEntityResolver();
056:
057: /**
058: * Parses the DTD. The validator object is responsible for reading the
059: * full DTD.
060: *
061: * @param publicID the public ID, which may be null.
062: * @param reader the reader to read the DTD from.
063: * @param entityResolver the entity resolver.
064: * @param external true if the DTD is external.
065: *
066: * @throws java.lang.Exception
067: * If something went wrong.
068: */
069: public void parseDTD(String publicID, IXMLReader reader,
070: IXMLEntityResolver entityResolver, boolean external)
071: throws Exception;
072:
073: /**
074: * Indicates that an element has been started.
075: *
076: * @param name the name of the element.
077: * @param systemId the system ID of the XML data of the element.
078: * @param lineNr the line number in the XML data of the element.
079: *
080: * @throws java.lang.Exception
081: * If the element could not be validated.
082: */
083: public void elementStarted(String name, String systemId, int lineNr)
084: throws Exception;
085:
086: /**
087: * Indicates that the current element has ended.
088: *
089: * @param name the name of the element.
090: * @param systemId the system ID of the XML data of the element.
091: * @param lineNr the line number in the XML data of the element.
092: *
093: * @throws java.lang.Exception
094: * If the element could not be validated.
095: */
096: public void elementEnded(String name, String systemId, int lineNr)
097: throws Exception;
098:
099: /**
100: * Indicates that an attribute has been added to the current element.
101: *
102: * @param key the name of the attribute.
103: * @param value the value of the attribute.
104: * @param systemId the system ID of the XML data of the element.
105: * @param lineNr the line number in the XML data of the element.
106: *
107: * @throws java.lang.Exception
108: * If the attribute could not be validated.
109: */
110: public void attributeAdded(String key, String value,
111: String systemId, int lineNr) throws Exception;
112:
113: /**
114: * This method is called when the attributes of an XML element have been
115: * processed.
116: * If there are attributes with a default value which have not been
117: * specified yet, they have to be put into <I>extraAttributes</I>.
118: *
119: * @param name the name of the element.
120: * @param extraAttributes where to put extra attributes.
121: * @param systemId the system ID of the XML data of the element.
122: * @param lineNr the line number in the XML data of the element.
123: *
124: * @throws java.lang.Exception
125: * if the element could not be validated.
126: */
127: public void elementAttributesProcessed(String name,
128: Properties extraAttributes, String systemId, int lineNr)
129: throws Exception;
130:
131: /**
132: * Indicates that a new #PCDATA element has been encountered.
133: *
134: * @param systemId the system ID of the XML data of the element.
135: * @param lineNr the line number in the XML data of the element.
136: *
137: * @throws java.lang.Exception
138: * if the element could not be validated.
139: */
140: public void PCDataAdded(String systemId, int lineNr)
141: throws Exception;
142:
143: }
|