mrglavas 2004/08/31 20:00:15
Modified: java/src/org/apache/xerces/xni XMLLocator.java
java/src/org/apache/xerces/xni/parser XMLParseException.java
Log:
Making XNI changes as per discussion on xerces-j-dev:
1) Add a getCharacterOffset method to XMLLocator which returns
the character offset for the current entity.
2) Add a getVersion method to XMLLocator which returns the XML
version of the current entity.
3) Add a getCharacterOffset method to XMLParseException to
expose the offset from the XMLLocator.
Also preventing an NPE in case of a null locator passed to the
constructor. This had been fixed ages ago for the other
constructor.
Revision Changes Path
1.11 +21 -4 xml-xerces/java/src/org/apache/xerces/xni/XMLLocator.java
Index: XMLLocator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/xni/XMLLocator.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- XMLLocator.java 24 Feb 2004 23:15:54 -0000 1.10
+++ XMLLocator.java 1 Sep 2004 03:00:15 -0000 1.11
@@ -41,13 +41,17 @@
/** Returns the expanded system identifier. */
public String getExpandedSystemId();
- /** Returns the line number. */
+ /** Returns the line number, or <code>-1</code> if no line number is available.
*/
public int getLineNumber();
- /** Returns the column number. */
+ /** Returns the column number, or <code>-1</code> if no column number is
available. */
public int getColumnNumber();
+
+ /** Returns the character offset, or <code>-1</code> if no character offset is
available. */
+ public int getCharacterOffset();
- /** Returns the encoding of the current entity.
+ /**
+ * Returns the encoding of the current entity.
* Note that, for a given entity, this value can only be
* considered final once the encoding declaration has been read (or once it
* has been determined that there is no such declaration) since, no encoding
@@ -55,5 +59,18 @@
* will make an initial "guess" which could be in error.
*/
public String getEncoding();
+
+ /**
+ * Returns the XML version of the current entity. This will normally be the
+ * value from the XML or text declaration or defaulted by the parser. Note that
+ * that this value may be different than the version of the processing rules
+ * applied to the current entity. For instance, an XML 1.1 document may refer to
+ * XML 1.0 entities. In such a case the rules of XML 1.1 are applied to the
entire
+ * document. Also note that, for a given entity, this value can only be
considered
+ * final once the XML or text declaration has been read or once it has been
+ * determined that there is no such declaration.
+ */
+ public String getXMLVersion();
+
} // interface XMLLocator
1.7 +19 -7
xml-xerces/java/src/org/apache/xerces/xni/parser/XMLParseException.java
Index: XMLParseException.java
===================================================================
RCS file:
/home/cvs/xml-xerces/java/src/org/apache/xerces/xni/parser/XMLParseException.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- XMLParseException.java 15 Aug 2004 21:22:15 -0000 1.6
+++ XMLParseException.java 1 Sep 2004 03:00:15 -0000 1.7
@@ -55,6 +55,9 @@
/** Column number. */
protected int fColumnNumber = -1;
+
+ /** Character offset. */
+ protected int fCharacterOffset = -1;
//
// Constructors
@@ -70,6 +73,7 @@
fBaseSystemId = locator.getBaseSystemId();
fLineNumber = locator.getLineNumber();
fColumnNumber = locator.getColumnNumber();
+ fCharacterOffset = locator.getCharacterOffset();
}
} // <init>(XMLLocator,String)
@@ -77,12 +81,15 @@
public XMLParseException(XMLLocator locator,
String message, Exception exception) {
super(message, exception);
- fPublicId = locator.getPublicId();
- fLiteralSystemId = locator.getLiteralSystemId();
- fExpandedSystemId = locator.getExpandedSystemId();
- fBaseSystemId = locator.getBaseSystemId();
- fLineNumber = locator.getLineNumber();
- fColumnNumber = locator.getColumnNumber();
+ if (locator != null) {
+ fPublicId = locator.getPublicId();
+ fLiteralSystemId = locator.getLiteralSystemId();
+ fExpandedSystemId = locator.getExpandedSystemId();
+ fBaseSystemId = locator.getBaseSystemId();
+ fLineNumber = locator.getLineNumber();
+ fColumnNumber = locator.getColumnNumber();
+ fCharacterOffset = locator.getCharacterOffset();
+ }
} // <init>(XMLLocator,String,Exception)
//
@@ -118,6 +125,11 @@
public int getColumnNumber() {
return fColumnNumber;
} // getRowNumber():int
+
+ /** Returns the character offset. */
+ public int getCharacterOffset() {
+ return fCharacterOffset;
+ } // getCharacterOffset():int
//
// Object methods
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]