bradford 01/12/13 11:42:01
Modified: java/src/org/apache/xindice/core/objects Reflector.java
java/src/org/apache/xindice/core/query
XPathQueryResolver.java
java/src/org/apache/xindice/xml/dom DOMParser.java
Log:
Submitted a work-around for a Xerces 2 bug in which the URI for a namespace
definition (xmlns:blah) is being reported as null instead of empty string.
Also added to the list of filtered methods in XMLObjects.
Revision Changes Path
1.2 +4 -1
xml-xindice/java/src/org/apache/xindice/core/objects/Reflector.java
Index: Reflector.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/src/org/apache/xindice/core/objects/Reflector.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Reflector.java 2001/12/06 21:00:13 1.1
+++ Reflector.java 2001/12/13 19:42:01 1.2
@@ -56,7 +56,7 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
- * $Id: Reflector.java,v 1.1 2001/12/06 21:00:13 bradford Exp $
+ * $Id: Reflector.java,v 1.2 2001/12/13 19:42:01 bradford Exp $
*/
import org.apache.xindice.core.*;
@@ -152,11 +152,14 @@
)
|| name.equals("reclaim")
// Java Stuff
+ || name.equals("clone")
|| name.equals("equals")
|| name.equals("finalize")
+ || name.equals("getClass")
|| name.equals("hashCode")
|| name.equals("notify")
|| name.equals("notifyAll")
+ || name.equals("toString")
|| name.equals("wait") )
continue;
1.4 +7 -1
xml-xindice/java/src/org/apache/xindice/core/query/XPathQueryResolver.java
Index: XPathQueryResolver.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/src/org/apache/xindice/core/query/XPathQueryResolver.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- XPathQueryResolver.java 2001/12/10 21:48:19 1.3
+++ XPathQueryResolver.java 2001/12/13 19:42:01 1.4
@@ -56,7 +56,7 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
- * $Id: XPathQueryResolver.java,v 1.3 2001/12/10 21:48:19 bradford Exp $
+ * $Id: XPathQueryResolver.java,v 1.4 2001/12/13 19:42:01 bradford Exp $
*/
import org.apache.xindice.core.*;
@@ -839,6 +839,11 @@
*/
private Object queryIndexes(NamedKeys nk, IndexQuery iq, String ps,
int objType) {
try {
+ // TODO: Add logic to use an EmptyKeySet if a name doesn't
already
+ // exist in the SymbolTable. This will eliminate the need
+ // to do a collection scan in those cases where somebody
+ // typed an element or attribute name incorrectly.
+
IndexPattern pattern = iq.getPattern();
Indexer idx =
context.getIndexManager().getBestIndexer(Indexer.STYLE_NODEVALUE, pattern);
@@ -1040,6 +1045,7 @@
}
}
}
+
1.3 +32 -11
xml-xindice/java/src/org/apache/xindice/xml/dom/DOMParser.java
Index: DOMParser.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/src/org/apache/xindice/xml/dom/DOMParser.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DOMParser.java 2001/12/07 23:28:11 1.2
+++ DOMParser.java 2001/12/13 19:42:01 1.3
@@ -56,7 +56,7 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
- * $Id: DOMParser.java,v 1.2 2001/12/07 23:28:11 bradford Exp $
+ * $Id: DOMParser.java,v 1.3 2001/12/13 19:42:01 bradford Exp $
*/
import java.io.*;
@@ -64,6 +64,7 @@
import org.apache.xindice.core.data.*;
import org.apache.xindice.util.*;
+import org.apache.xindice.xml.*;
import javax.xml.parsers.*;
@@ -83,6 +84,7 @@
private Document doc;
private Node context;
+ private Map nsMap = new HashMap();
private int state = -1;
private StringBuffer buf;
private ObjectStack states = new ObjectStack();
@@ -291,14 +293,10 @@
}
public void startPrefixMapping(String prefix, String uri) throws
SAXException {
- // Is defining this method even necessary?
- if ( context instanceof Element ) {
- Element e = (Element)context;
- if ( prefix == null || prefix.length() == 0 )
- e.setAttribute("xmlns", uri);
- else
- e.setAttribute("xmlns:"+prefix, uri);
- }
+ if ( prefix == null || prefix.length() == 0 )
+ nsMap.put("", uri);
+ else
+ nsMap.put(prefix, uri);
}
public void startElement(String uri, String localName, String qName,
Attributes attributes) throws SAXException {
@@ -307,13 +305,36 @@
e = doc.createElementNS(uri, qName);
else
e = doc.createElement(localName);
+
for ( int i = 0; i < attributes.getLength(); i++ ) {
String attrURI = attributes.getURI(i);
- if ( attrURI != null && uri.length() > 0 )
- e.setAttributeNS(attrURI, attributes.getQName(i),
attributes.getValue(i));
+
+ // TODO: this is a work-around for a broken Xerces 2
+ String aqName = attributes.getQName(i);
+ boolean isNamespace = aqName != null &&
(aqName.startsWith("xmlns:") || aqName.equals("xmlns"));
+
+ if ( isNamespace || (attrURI != null && uri.length() > 0) )
+ e.setAttributeNS(attrURI, aqName, attributes.getValue(i));
else
e.setAttribute(attributes.getLocalName(i),
attributes.getValue(i));
}
+
+ // TODO: This code won't be necessary if prefixes are being reported
+ // correctly as attributes
+ if ( nsMap.size() > 0 ) {
+ Iterator i = nsMap.entrySet().iterator();
+ while ( i.hasNext() ) {
+ Map.Entry entry = (Map.Entry)i.next();
+ String prefix = (String)entry.getKey();
+ String nsUri = (String)entry.getValue();
+ if ( prefix.length() == 0 )
+ e.setAttribute("xmlns", uri);
+ else
+ e.setAttribute("xmlns:"+prefix, uri);
+ }
+ nsMap.clear();
+ }
+
context.appendChild(e);
pushState(Node.ELEMENT_NODE);
context = e;