jkesselm 02/01/30 09:54:56
Modified: java/src/org/apache/xml/dtm/ref/sax2dtm SAX2DTM.java
Log:
Bugzilla 2617, part 1: Construct the data structures and access them
correctly.
Ignore too-late-to-be-safe requests to enable this feature.
This doesn't resolve how to rewrite higher-level code so it makes the
request early enough to be useful.
Revision Changes Path
1.25 +43 -10
xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/SAX2DTM.java
Index: SAX2DTM.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/SAX2DTM.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- SAX2DTM.java 23 Jan 2002 22:53:47 -0000 1.24
+++ SAX2DTM.java 30 Jan 2002 17:54:56 -0000 1.25
@@ -866,6 +866,25 @@
m_exptype.addElement(expandedTypeID);
m_dataOrQName.addElement(dataOrPrefix);
+ if (m_useSourceLocationProperty && m_locator != null)
+ {
+ m_sourceSystemId.addElement(m_locator.getSystemId());
+ m_sourceLine.addElement(m_locator.getLineNumber());
+ m_sourceColumn.addElement(m_locator.getColumnNumber());
+
+ //%REVIEW% %BUG% Prevent this from arising in the first place
+ // by not allowing the enabling conditions to change after we
start
+ // building the document.
+ if (m_sourceSystemId.size() != m_size)
+ {
+ System.err.println("CODING ERROR in Source Location: "
+ m_size
+ + " != "
+ + m_sourceSystemId.size());
+ System.exit(1);
+ }
+ }
+
+
if (DTM.NULL != previousSibling)
m_nextsib.setElementAt(nodeIndex,previousSibling);
@@ -1886,9 +1905,6 @@
*/
public void characters(char ch[], int start, int length) throws
SAXException
{
- if (DEBUG)
- System.out.println("characters: " + new String(ch,start,length));
-
if (m_textPendingStart == -1) // First one in this block
{
m_textPendingStart = m_chars.size();
@@ -2289,23 +2305,40 @@
*/
public void setProperty(String property, Object value)
{
- if (property.equals(XalanProperties.SOURCE_LOCATION)) {
+ if (property.equals(XalanProperties.SOURCE_LOCATION))
+ {
if (!(value instanceof Boolean))
throw new
RuntimeException(XSLMessages.createMessage(XSLTErrorResources.ER_PROPERTY_VALUE_BOOLEAN,
new Object[]{XalanProperties.SOURCE_LOCATION})); //"Value for property "
// + XalanProperties.SOURCE_LOCATION
// + " should be a Boolean instance");
- m_useSourceLocationProperty = ((Boolean)value).booleanValue();
- m_sourceSystemId = new StringVector();
- m_sourceLine = new IntVector();
- m_sourceColumn = new IntVector();
- }
+ // %REVIEW%
+ // This MUST NOT be set true after document construction has begun,
+ // since that will leave us with incomplete data structures and cause
+ // malfunctions. Easier to just say "don't change at all once in
progress"
+ if(m_size<=0)
+ {
+ m_useSourceLocationProperty = ((Boolean)value).booleanValue();
+ if(m_useSourceLocationProperty)
+ {
+ m_sourceSystemId = new StringVector();
+ m_sourceLine = new IntVector();
+ m_sourceColumn = new IntVector();
+ }
+ }
+ }
}
+ /** Retrieve the SourceLocator associated with a specific node.
+ * This is only meaningful if the XalanProperties.SOURCE_LOCATION flag was
+ * set True using setProperty; if it was never set, or was set false, we
+ * will return null. (We _could_ return a locator with the document's
+ * base URI and bogus line/column information. Should we?)
+ * */
public SourceLocator getSourceLocatorFor(int node)
{
if (m_useSourceLocationProperty)
{
- node = node & ExpandedNameTable.MASK_NODEHANDLE;
+ node = makeNodeIdentity(node);
return new NodeLocator(null,
m_sourceSystemId.elementAt(node),
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]