[kaffe] CVS kaffe (robilad): Resynced with GNU JAXP: fixes for parser lookup and XSLT
Kaffe CVS
cvs-commits at kaffe.org
Mon Nov 1 07:42:08 PST 2004
PatchSet 5394
Date: 2004/11/01 15:37:56
Author: robilad
Branch: HEAD
Tag: (none)
Log:
Resynced with GNU JAXP: fixes for parser lookup and XSLT
2004-11-01 Dalibor Topic <robilad at kaffe.org>
* libraries/javalib/gnu/xml/transform/DOMResultWrapper.java,
libraries/javalib/gnu/xml/transform/DOMSerializer.java,
libraries/javalib/gnu/xml/transform/DOMSourceLocator.java,
libraries/javalib/gnu/xml/transform/DOMSourceWrapper.java,
libraries/javalib/gnu/xml/transform/ErrorListenerErrorHandler.java,
libraries/javalib/gnu/xml/transform/Stylesheet.java,
libraries/javalib/gnu/xml/transform/Template.java,
libraries/javalib/gnu/xml/transform/TemplatesImpl.java,
libraries/javalib/gnu/xml/transform/TransformerFactoryImpl.java,
libraries/javalib/gnu/xml/transform/TransformerImpl.java,
libraries/javalib/gnu/xml/transform/URIResolverEntityResolver.java,
libraries/javalib/gnu/xml/xpath/XPathTest.java:
New files taken from GNU JAXP.
* libraries/javalib/Makefile.am,
libraries/javalib/Makefile.in,
libraries/javalib/all.files:
Regenerated.
* libraries/clib/libxmlj/xmlj_sax.c,
libraries/clib/libxmlj/xmlj_transform.c,
libraries/javalib/gnu/xml/dom/DomDocument.java,
libraries/javalib/gnu/xml/dom/DomNode.java,
libraries/javalib/gnu/xml/dom/DomXPathResult.java,
libraries/javalib/gnu/xml/libxmlj/transform/GnomeTransformer.java,
libraries/javalib/gnu/xml/libxmlj/transform/TransformTest.java,
libraries/javalib/gnu/xml/libxmlj/util/XMLJ.java,
libraries/javalib/gnu/xml/xpath/Expr.java,
libraries/javalib/gnu/xml/xpath/NameTest.java,
libraries/javalib/gnu/xml/xpath/NodeTypeTest.java,
libraries/javalib/gnu/xml/xpath/Root.java,
libraries/javalib/gnu/xml/xpath/Selector.java,
libraries/javalib/gnu/xml/xpath/Step.java,
libraries/javalib/gnu/xml/xpath/Test.java,
libraries/javalib/gnu/xml/xpath/UnionExpr.java,
libraries/javalib/gnu/xml/xpath/XPathImpl.java,
libraries/javalib/javax/xml/parsers/DocumentBuilderFactory.java,
libraries/javalib/javax/xml/parsers/SAXParserFactory.java,
libraries/javalib/javax/xml/transform/TransformerException.java,
libraries/javalib/javax/xml/transform/TransformerFactory.java,
libraries/javalib/javax/xml/xpath/XPathFactory.java:
Resynced with GNU JAXP.
2004-10-31 Chris Burdess <dog at gnu.org>
* DomNode.java: Implement Comparable using natural document order.
* xpath: Use natural document ordering in DomNode.
2004-10-30 Chris Burdess <dog at gnu.org>
* transform: Experimental XSLT transformer using XPath
implementation.
2004-11-01 Chris Burdess <dog at gnu.org>
* xmlj_sax.c: Fixed segfault with external entities in transform.
Members:
ChangeLog:1.2944->1.2945
libraries/clib/libxmlj/xmlj_sax.c:1.5->1.6
libraries/clib/libxmlj/xmlj_transform.c:1.6->1.7
libraries/javalib/Makefile.am:1.258->1.259
libraries/javalib/Makefile.in:1.338->1.339
libraries/javalib/all.files:1.46->1.47
libraries/javalib/gnu/xml/dom/DomDocument.java:1.6->1.7
libraries/javalib/gnu/xml/dom/DomNode.java:1.5->1.6
libraries/javalib/gnu/xml/dom/DomXPathResult.java:1.2->1.3
libraries/javalib/gnu/xml/libxmlj/transform/GnomeTransformer.java:1.5->1.6
libraries/javalib/gnu/xml/libxmlj/transform/TransformTest.java:1.5->1.6
libraries/javalib/gnu/xml/libxmlj/util/XMLJ.java:1.5->1.6
libraries/javalib/gnu/xml/transform/DOMResultWrapper.java:INITIAL->1.1
libraries/javalib/gnu/xml/transform/DOMSerializer.java:INITIAL->1.1
libraries/javalib/gnu/xml/transform/DOMSourceLocator.java:INITIAL->1.1
libraries/javalib/gnu/xml/transform/DOMSourceWrapper.java:INITIAL->1.1
libraries/javalib/gnu/xml/transform/ErrorListenerErrorHandler.java:INITIAL->1.1
libraries/javalib/gnu/xml/transform/Stylesheet.java:INITIAL->1.1
libraries/javalib/gnu/xml/transform/Template.java:INITIAL->1.1
libraries/javalib/gnu/xml/transform/TemplatesImpl.java:INITIAL->1.1
libraries/javalib/gnu/xml/transform/TransformerFactoryImpl.java:INITIAL->1.1
libraries/javalib/gnu/xml/transform/TransformerImpl.java:INITIAL->1.1
libraries/javalib/gnu/xml/transform/URIResolverEntityResolver.java:INITIAL->1.1
libraries/javalib/gnu/xml/xpath/Expr.java:1.3->1.4
libraries/javalib/gnu/xml/xpath/NameTest.java:1.2->1.3
libraries/javalib/gnu/xml/xpath/NodeTypeTest.java:1.1->1.2
libraries/javalib/gnu/xml/xpath/Root.java:1.1->1.2
libraries/javalib/gnu/xml/xpath/Selector.java:1.1->1.2
libraries/javalib/gnu/xml/xpath/Step.java:1.1->1.2
libraries/javalib/gnu/xml/xpath/Test.java:1.1->1.2
libraries/javalib/gnu/xml/xpath/UnionExpr.java:1.1->1.2
libraries/javalib/gnu/xml/xpath/XPathImpl.java:1.1->1.2
libraries/javalib/gnu/xml/xpath/XPathTest.java:INITIAL->1.1
libraries/javalib/javax/xml/parsers/DocumentBuilderFactory.java:1.8->1.9
libraries/javalib/javax/xml/parsers/SAXParserFactory.java:1.7->1.8
libraries/javalib/javax/xml/transform/TransformerException.java:1.8->1.9
libraries/javalib/javax/xml/transform/TransformerFactory.java:1.8->1.9
libraries/javalib/javax/xml/xpath/XPathFactory.java:1.2->1.3
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2944 kaffe/ChangeLog:1.2945
--- kaffe/ChangeLog:1.2944 Mon Nov 1 10:13:19 2004
+++ kaffe/ChangeLog Mon Nov 1 15:37:56 2004
@@ -1,5 +1,64 @@
2004-11-01 Dalibor Topic <robilad at kaffe.org>
+ * libraries/javalib/gnu/xml/transform/DOMResultWrapper.java,
+ libraries/javalib/gnu/xml/transform/DOMSerializer.java,
+ libraries/javalib/gnu/xml/transform/DOMSourceLocator.java,
+ libraries/javalib/gnu/xml/transform/DOMSourceWrapper.java,
+ libraries/javalib/gnu/xml/transform/ErrorListenerErrorHandler.java,
+ libraries/javalib/gnu/xml/transform/Stylesheet.java,
+ libraries/javalib/gnu/xml/transform/Template.java,
+ libraries/javalib/gnu/xml/transform/TemplatesImpl.java,
+ libraries/javalib/gnu/xml/transform/TransformerFactoryImpl.java,
+ libraries/javalib/gnu/xml/transform/TransformerImpl.java,
+ libraries/javalib/gnu/xml/transform/URIResolverEntityResolver.java,
+ libraries/javalib/gnu/xml/xpath/XPathTest.java:
+ New files taken from GNU JAXP.
+
+ * libraries/javalib/Makefile.am,
+ libraries/javalib/Makefile.in,
+ libraries/javalib/all.files:
+ Regenerated.
+
+ * libraries/clib/libxmlj/xmlj_sax.c,
+ libraries/clib/libxmlj/xmlj_transform.c,
+ libraries/javalib/gnu/xml/dom/DomDocument.java,
+ libraries/javalib/gnu/xml/dom/DomNode.java,
+ libraries/javalib/gnu/xml/dom/DomXPathResult.java,
+ libraries/javalib/gnu/xml/libxmlj/transform/GnomeTransformer.java,
+ libraries/javalib/gnu/xml/libxmlj/transform/TransformTest.java,
+ libraries/javalib/gnu/xml/libxmlj/util/XMLJ.java,
+ libraries/javalib/gnu/xml/xpath/Expr.java,
+ libraries/javalib/gnu/xml/xpath/NameTest.java,
+ libraries/javalib/gnu/xml/xpath/NodeTypeTest.java,
+ libraries/javalib/gnu/xml/xpath/Root.java,
+ libraries/javalib/gnu/xml/xpath/Selector.java,
+ libraries/javalib/gnu/xml/xpath/Step.java,
+ libraries/javalib/gnu/xml/xpath/Test.java,
+ libraries/javalib/gnu/xml/xpath/UnionExpr.java,
+ libraries/javalib/gnu/xml/xpath/XPathImpl.java,
+ libraries/javalib/javax/xml/parsers/DocumentBuilderFactory.java,
+ libraries/javalib/javax/xml/parsers/SAXParserFactory.java,
+ libraries/javalib/javax/xml/transform/TransformerException.java,
+ libraries/javalib/javax/xml/transform/TransformerFactory.java,
+ libraries/javalib/javax/xml/xpath/XPathFactory.java:
+ Resynced with GNU JAXP.
+
+ 2004-10-31 Chris Burdess <dog at gnu.org>
+
+ * DomNode.java: Implement Comparable using natural document order.
+ * xpath: Use natural document ordering in DomNode.
+
+ 2004-10-30 Chris Burdess <dog at gnu.org>
+
+ * transform: Experimental XSLT transformer using XPath
+ implementation.
+
+ 2004-11-01 Chris Burdess <dog at gnu.org>
+
+ * xmlj_sax.c: Fixed segfault with external entities in transform.
+
+2004-11-01 Dalibor Topic <robilad at kaffe.org>
+
* libraries/javalib/java/beans/PropertyEditorSupport.java:
Resynced with GNU Classpath.
Index: kaffe/libraries/clib/libxmlj/xmlj_sax.c
diff -u kaffe/libraries/clib/libxmlj/xmlj_sax.c:1.5 kaffe/libraries/clib/libxmlj/xmlj_sax.c:1.6
--- kaffe/libraries/clib/libxmlj/xmlj_sax.c:1.5 Mon Aug 16 02:43:43 2004
+++ kaffe/libraries/clib/libxmlj/xmlj_sax.c Mon Nov 1 15:37:57 2004
@@ -709,6 +709,12 @@
env = sax->env;
target = sax->obj;
+ if (target == NULL)
+ {
+ /* No Java parse context */
+ return;
+ }
+
/* Update locator on sax context */
sax->loc = loc;
if ((*env)->ExceptionOccurred (env))
Index: kaffe/libraries/clib/libxmlj/xmlj_transform.c
diff -u kaffe/libraries/clib/libxmlj/xmlj_transform.c:1.6 kaffe/libraries/clib/libxmlj/xmlj_transform.c:1.7
--- kaffe/libraries/clib/libxmlj/xmlj_transform.c:1.6 Sun Oct 31 13:36:31 2004
+++ kaffe/libraries/clib/libxmlj/xmlj_transform.c Mon Nov 1 15:37:57 2004
@@ -609,7 +609,7 @@
jobject inputStream;
jbyteArray detectBuffer;
- fprintf(stderr,"xmljDocLoader:2\n");
+ /*fprintf(stderr,"xmljDocLoader:1\n");*/
fflush(stdout);
env = xmljGetJNIEnv ();
if (!env)
@@ -622,8 +622,8 @@
return NULL;
}
getInputStream =
- (*env)->GetMethodID (env, xmljClass, "getInputStream",
- "(Ljava/lang/String;Ljava/lang/String;)Lgnu/xml/libxmlj/util/NamedInputStream;");
+ (*env)->GetStaticMethodID (env, xmljClass, "xmljGetInputStream",
+ "(Ljava/lang/String;Ljava/lang/String;)Lgnu/xml/libxmlj/util/NamedInputStream;");
if (!getInputStream)
{
return NULL;
Index: kaffe/libraries/javalib/Makefile.am
diff -u kaffe/libraries/javalib/Makefile.am:1.258 kaffe/libraries/javalib/Makefile.am:1.259
--- kaffe/libraries/javalib/Makefile.am:1.258 Sun Oct 31 13:36:31 2004
+++ kaffe/libraries/javalib/Makefile.am Mon Nov 1 15:37:58 2004
@@ -160,6 +160,7 @@
$(gnu_xml_libxmlj_transform_SRCS) \
$(gnu_xml_libxmlj_util_SRCS) \
$(gnu_xml_pipeline_SRCS) \
+ $(gnu_xml_transform_SRCS) \
$(gnu_xml_util_SRCS) \
$(gnu_xml_xpath_SRCS) \
$(java_applet_SRCS) \
@@ -1475,6 +1476,18 @@
gnu/xml/pipeline/WellFormednessFilter.java \
gnu/xml/pipeline/XIncludeFilter.java \
gnu/xml/pipeline/XsltFilter.java
+gnu_xml_transform_SRCS = \
+ gnu/xml/transform/DOMResultWrapper.java \
+ gnu/xml/transform/DOMSerializer.java \
+ gnu/xml/transform/DOMSourceLocator.java \
+ gnu/xml/transform/DOMSourceWrapper.java \
+ gnu/xml/transform/ErrorListenerErrorHandler.java \
+ gnu/xml/transform/Stylesheet.java \
+ gnu/xml/transform/Template.java \
+ gnu/xml/transform/TemplatesImpl.java \
+ gnu/xml/transform/TransformerFactoryImpl.java \
+ gnu/xml/transform/TransformerImpl.java \
+ gnu/xml/transform/URIResolverEntityResolver.java
gnu_xml_util_SRCS = \
gnu/xml/util/DoParse.java \
gnu/xml/util/DomParser.java \
@@ -1507,6 +1520,7 @@
gnu/xml/xpath/XPathFactoryImpl.java \
gnu/xml/xpath/XPathImpl.java \
gnu/xml/xpath/XPathParser.java \
+ gnu/xml/xpath/XPathTest.java \
gnu/xml/xpath/XPathTokenizer.java
java_applet_SRCS = \
java/applet/Applet.java \
Index: kaffe/libraries/javalib/Makefile.in
diff -u kaffe/libraries/javalib/Makefile.in:1.338 kaffe/libraries/javalib/Makefile.in:1.339
--- kaffe/libraries/javalib/Makefile.in:1.338 Sun Oct 31 13:36:32 2004
+++ kaffe/libraries/javalib/Makefile.in Mon Nov 1 15:37:58 2004
@@ -501,6 +501,7 @@
$(gnu_xml_libxmlj_transform_SRCS) \
$(gnu_xml_libxmlj_util_SRCS) \
$(gnu_xml_pipeline_SRCS) \
+ $(gnu_xml_transform_SRCS) \
$(gnu_xml_util_SRCS) \
$(gnu_xml_xpath_SRCS) \
$(java_applet_SRCS) \
@@ -1923,6 +1924,19 @@
gnu/xml/pipeline/XIncludeFilter.java \
gnu/xml/pipeline/XsltFilter.java
+gnu_xml_transform_SRCS = \
+ gnu/xml/transform/DOMResultWrapper.java \
+ gnu/xml/transform/DOMSerializer.java \
+ gnu/xml/transform/DOMSourceLocator.java \
+ gnu/xml/transform/DOMSourceWrapper.java \
+ gnu/xml/transform/ErrorListenerErrorHandler.java \
+ gnu/xml/transform/Stylesheet.java \
+ gnu/xml/transform/Template.java \
+ gnu/xml/transform/TemplatesImpl.java \
+ gnu/xml/transform/TransformerFactoryImpl.java \
+ gnu/xml/transform/TransformerImpl.java \
+ gnu/xml/transform/URIResolverEntityResolver.java
+
gnu_xml_util_SRCS = \
gnu/xml/util/DoParse.java \
gnu/xml/util/DomParser.java \
@@ -1956,6 +1970,7 @@
gnu/xml/xpath/XPathFactoryImpl.java \
gnu/xml/xpath/XPathImpl.java \
gnu/xml/xpath/XPathParser.java \
+ gnu/xml/xpath/XPathTest.java \
gnu/xml/xpath/XPathTokenizer.java
java_applet_SRCS = \
Index: kaffe/libraries/javalib/all.files
diff -u kaffe/libraries/javalib/all.files:1.46 kaffe/libraries/javalib/all.files:1.47
--- kaffe/libraries/javalib/all.files:1.46 Sun Oct 31 13:36:33 2004
+++ kaffe/libraries/javalib/all.files Mon Nov 1 15:37:59 2004
@@ -1043,6 +1043,17 @@
gnu/xml/pipeline/WellFormednessFilter.java
gnu/xml/pipeline/XIncludeFilter.java
gnu/xml/pipeline/XsltFilter.java
+gnu/xml/transform/DOMResultWrapper.java
+gnu/xml/transform/DOMSerializer.java
+gnu/xml/transform/DOMSourceLocator.java
+gnu/xml/transform/DOMSourceWrapper.java
+gnu/xml/transform/ErrorListenerErrorHandler.java
+gnu/xml/transform/Stylesheet.java
+gnu/xml/transform/Template.java
+gnu/xml/transform/TemplatesImpl.java
+gnu/xml/transform/TransformerFactoryImpl.java
+gnu/xml/transform/TransformerImpl.java
+gnu/xml/transform/URIResolverEntityResolver.java
gnu/xml/util/DoParse.java
gnu/xml/util/DomParser.java
gnu/xml/util/Resolver.java
@@ -1073,6 +1084,7 @@
gnu/xml/xpath/XPathFactoryImpl.java
gnu/xml/xpath/XPathImpl.java
gnu/xml/xpath/XPathParser.java
+gnu/xml/xpath/XPathTest.java
gnu/xml/xpath/XPathTokenizer.java
java/applet/Applet.java
java/applet/AppletContext.java
Index: kaffe/libraries/javalib/gnu/xml/dom/DomDocument.java
diff -u kaffe/libraries/javalib/gnu/xml/dom/DomDocument.java:1.6 kaffe/libraries/javalib/gnu/xml/dom/DomDocument.java:1.7
--- kaffe/libraries/javalib/gnu/xml/dom/DomDocument.java:1.6 Sun Oct 10 18:43:17 2004
+++ kaffe/libraries/javalib/gnu/xml/dom/DomDocument.java Mon Nov 1 15:38:00 2004
@@ -863,7 +863,16 @@
public Node adoptNode (Node source)
{
- // TODO
+ if (source instanceof DomNode)
+ {
+ DomNode node = (DomNode) source;
+ if (node.parent != null)
+ {
+ return null;
+ }
+ node.owner = this;
+ return node;
+ }
return null;
}
Index: kaffe/libraries/javalib/gnu/xml/dom/DomNode.java
diff -u kaffe/libraries/javalib/gnu/xml/dom/DomNode.java:1.5 kaffe/libraries/javalib/gnu/xml/dom/DomNode.java:1.6
--- kaffe/libraries/javalib/gnu/xml/dom/DomNode.java:1.5 Fri Sep 17 21:02:02 2004
+++ kaffe/libraries/javalib/gnu/xml/dom/DomNode.java Mon Nov 1 15:38:02 2004
@@ -78,7 +78,7 @@
* @author David Brownell
*/
public abstract class DomNode
- implements Node, NodeList, EventTarget, DocumentEvent, Cloneable
+ implements Node, NodeList, EventTarget, DocumentEvent, Cloneable, Comparable
{
//
// CLASS DATA
@@ -125,8 +125,8 @@
// PER-INSTANCE DATA
//
- private Document owner;
- private DomNode parent;
+ Document owner;
+ DomNode parent;
// Bleech ... "package private" so a builder can populate entity refs.
// writable during construction. DOM spec is nasty.
@@ -141,11 +141,57 @@
private int nListeners;
// Optimize access to siblings by caching indices.
- private transient int parentIndex;
+ private transient int index;
+
+ // Optimize document order comparison by caching the depth of this node
+ // in the tree.
+ private transient int depth;
// DOM Level 3 userData dictionary.
private Map userData;
+ /**
+ * DOM nodes have a natural ordering: document order.
+ */
+ public final int compareTo(Object other)
+ {
+ if (other instanceof DomNode)
+ {
+ DomNode n1 = this;
+ DomNode n2 = (DomNode) other;
+ if (n1.owner != n2.owner)
+ {
+ return 0;
+ }
+ int d1 = n1.depth, d2 = n2.depth;
+ int delta = d1 - d2;
+ while (d1 > d2) {
+ n1 = n1.parent;
+ d1--;
+ }
+ while (d2 > d1) {
+ n2 = n2.parent;
+ d2--;
+ }
+ int c = compareTo2(n1, n2);
+ return (c != 0) ? c : delta;
+ }
+ return 0;
+ }
+
+ /**
+ * Compare two nodes at the same depth.
+ */
+ final int compareTo2(DomNode n1, DomNode n2)
+ {
+ if (n1.depth == 0 || n1 == n2)
+ {
+ return 0;
+ }
+ int c = compareTo2(n1.parent, n2.parent);
+ return (c != 0) ? c : n1.index - n2.index;
+ }
+
//
// Some of the methods here are declared 'final' because
// knowledge about their implementation is built into this
@@ -312,9 +358,7 @@
n += children.length;
DomNode newKids [] = new DomNode [n];
-
- for (int i = 0; i < length; i++)
- newKids [i] = children [i];
+ System.arraycopy(children, 0, newKids, 0, length);
children = newKids;
}
@@ -423,6 +467,7 @@
if (childType != ATTRIBUTE_NODE)
newChild.parent = this;
+ newChild.depth = depth + 1;
}
@@ -550,7 +595,8 @@
if (!(length < children.length))
ensureEnough (1);
reparent (child);
- children [length++] = child;
+ child.index = length++;
+ children [child.index] = child;
if (reportMutations)
insertionEvent (null, child);
} else {
@@ -607,7 +653,11 @@
if (children [i] != refChild)
i--;
for (int j = ++length; j > i; j--)
+ {
+ children [j - 1].index = j;
children [j] = children [j - 1];
+ }
+ child.index = i;
children [i] = child;
if (reportMutations)
insertionEvent (null, child);
@@ -685,6 +735,7 @@
reparent (child);
if (children [i] != refChild)
i--;
+ child.index = i;
children [i] = child;
rmchild.parent = null;
if (reportMutations)
@@ -732,7 +783,10 @@
if (reportMutations)
removalEvent (null, child);
for (int j = i + 1; j < length; j++, i++)
+ {
+ children [j].index = i;
children [i] = children [j];
+ }
children [i] = null;
child.parent = null;
length--;
@@ -805,30 +859,7 @@
{
if (parent == null || getNodeType() == ATTRIBUTE_NODE)
return null;
-
- // we know parent.getChildNodes () returns itself
- // ... and that we're somewhere in parent.children[]
- int index;
-
- if (parentIndex < parent.length
- && parent.children [parentIndex] == this) {
- index = parentIndex + 1;
- if (index < parent.length)
- return parent.children [index];
- else
- return null;
- }
-
- for (index = 0; index < parent.length; index++) {
- if (parent.children [index] == this) {
- parentIndex = index++;
- if (index < parent.length)
- return parent.children [index];
- else
- break;
- }
- }
- return null;
+ return (index < parent.length) ? parent.children[index + 1] : null;
}
@@ -840,19 +871,7 @@
{
if (parent == null || getNodeType () == ATTRIBUTE_NODE)
return null;
-
- NodeList siblings = parent.getChildNodes ();
- int len = siblings.getLength ();
-
- if (siblings.item (parentIndex) == this)
- return siblings.item (parentIndex - 1);
-
- for (int i = 0; i < len; i++)
- if (siblings.item (i) == this) {
- parentIndex = i;
- return siblings.item (--i);
- }
- return null;
+ return (index > 0) ? parent.children[index - 1] : null;
}
@@ -1755,5 +1774,29 @@
}
return userData.get (key);
}
+
+ public String toString()
+ {
+ String nodeName = getNodeName();
+ String nodeValue = getNodeValue();
+ StringBuffer buf = new StringBuffer(getClass().getName());
+ buf.append('[');
+ if (nodeName != null)
+ {
+ buf.append(nodeName);
+ }
+ if (nodeValue != null)
+ {
+ if (nodeName != null)
+ {
+ buf.append('=');
+ }
+ buf.append('\'');
+ buf.append(nodeValue);
+ buf.append('\'');
+ }
+ buf.append(']');
+ return buf.toString();
+ }
}
Index: kaffe/libraries/javalib/gnu/xml/dom/DomXPathResult.java
diff -u kaffe/libraries/javalib/gnu/xml/dom/DomXPathResult.java:1.2 kaffe/libraries/javalib/gnu/xml/dom/DomXPathResult.java:1.3
--- kaffe/libraries/javalib/gnu/xml/dom/DomXPathResult.java:1.2 Wed Oct 20 18:04:46 2004
+++ kaffe/libraries/javalib/gnu/xml/dom/DomXPathResult.java Mon Nov 1 15:38:02 2004
@@ -82,7 +82,7 @@
case XPathResult.ANY_TYPE:
case XPathResult.ANY_UNORDERED_NODE_TYPE:
type = (ns.size () == 1) ? XPathResult.FIRST_ORDERED_NODE_TYPE :
- XPathResult.UNORDERED_NODE_ITERATOR_TYPE;
+ XPathResult.ORDERED_NODE_ITERATOR_TYPE;
break;
default:
type = requestedType;
@@ -128,6 +128,8 @@
switch (type)
{
case XPathResult.FIRST_ORDERED_NODE_TYPE:
+ case XPathResult.ORDERED_NODE_ITERATOR_TYPE:
+ case XPathResult.ORDERED_NODE_SNAPSHOT_TYPE:
case XPathResult.UNORDERED_NODE_ITERATOR_TYPE:
case XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE:
Collection ns = (Collection) value;
@@ -148,6 +150,8 @@
switch (type)
{
case XPathResult.FIRST_ORDERED_NODE_TYPE:
+ case XPathResult.ORDERED_NODE_ITERATOR_TYPE:
+ case XPathResult.ORDERED_NODE_SNAPSHOT_TYPE:
case XPathResult.UNORDERED_NODE_ITERATOR_TYPE:
case XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE:
return ((Collection) value).size ();
@@ -186,6 +190,8 @@
switch (type)
{
case XPathResult.FIRST_ORDERED_NODE_TYPE:
+ case XPathResult.ORDERED_NODE_ITERATOR_TYPE:
+ case XPathResult.ORDERED_NODE_SNAPSHOT_TYPE:
case XPathResult.UNORDERED_NODE_ITERATOR_TYPE:
case XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE:
Collection ns = (Collection) value;
@@ -214,6 +220,10 @@
return "STRING_TYPE";
case XPathResult.FIRST_ORDERED_NODE_TYPE:
return "FIRST_ORDERED_NODE_TYPE";
+ case XPathResult.ORDERED_NODE_ITERATOR_TYPE:
+ return "ORDERED_NODE_ITERATOR_TYPE";
+ case XPathResult.ORDERED_NODE_SNAPSHOT_TYPE:
+ return "ORDERED_NODE_SNAPSHOT_TYPE";
case XPathResult.UNORDERED_NODE_ITERATOR_TYPE:
return "UNORDERED_NODE_ITERATOR_TYPE";
case XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE:
Index: kaffe/libraries/javalib/gnu/xml/libxmlj/transform/GnomeTransformer.java
diff -u kaffe/libraries/javalib/gnu/xml/libxmlj/transform/GnomeTransformer.java:1.5 kaffe/libraries/javalib/gnu/xml/libxmlj/transform/GnomeTransformer.java:1.6
--- kaffe/libraries/javalib/gnu/xml/libxmlj/transform/GnomeTransformer.java:1.5 Sun Oct 31 13:36:34 2004
+++ kaffe/libraries/javalib/gnu/xml/libxmlj/transform/GnomeTransformer.java Mon Nov 1 15:38:02 2004
@@ -1,5 +1,5 @@
/*
- * $Id: GnomeTransformer.java,v 1.5 2004/10/31 13:36:34 robilad Exp $
+ * $Id: GnomeTransformer.java,v 1.6 2004/11/01 15:38:02 robilad Exp $
* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
*
* This file is part of GNU Classpathx/jaxp.
Index: kaffe/libraries/javalib/gnu/xml/libxmlj/transform/TransformTest.java
diff -u kaffe/libraries/javalib/gnu/xml/libxmlj/transform/TransformTest.java:1.5 kaffe/libraries/javalib/gnu/xml/libxmlj/transform/TransformTest.java:1.6
--- kaffe/libraries/javalib/gnu/xml/libxmlj/transform/TransformTest.java:1.5 Sun Oct 31 13:36:34 2004
+++ kaffe/libraries/javalib/gnu/xml/libxmlj/transform/TransformTest.java Mon Nov 1 15:38:03 2004
@@ -70,14 +70,15 @@
{
// Force use of Libxsltj
- System.setProperty ("javax.xml.transform.TransformerFactory",
- "gnu.xml.libxmlj.transform.GnomeTransformerFactory");
+ /*System.setProperty ("javax.xml.transform.TransformerFactory",
+ "gnu.xml.libxmlj.transform.GnomeTransformerFactory");*/
// Read arguments
if (args.length < 1)
{
System.err.println ("Usage: java " + TransformTest.class.getName ()
- + " <stylesheet> <source> <result>");
+ + " <stylesheet> [<source> [<result>]]");
+ System.exit(1);
}
Source xsltSource = new StreamSource (args[0]);
Source source = new StreamSource (System.in);
Index: kaffe/libraries/javalib/gnu/xml/libxmlj/util/XMLJ.java
diff -u kaffe/libraries/javalib/gnu/xml/libxmlj/util/XMLJ.java:1.5 kaffe/libraries/javalib/gnu/xml/libxmlj/util/XMLJ.java:1.6
--- kaffe/libraries/javalib/gnu/xml/libxmlj/util/XMLJ.java:1.5 Sun Oct 31 13:36:35 2004
+++ kaffe/libraries/javalib/gnu/xml/libxmlj/util/XMLJ.java Mon Nov 1 15:38:03 2004
@@ -107,18 +107,7 @@
String systemId = input.getSystemId ();
if (in == null)
{
- if (systemId == null)
- {
- throw new IOException ("no system ID");
- }
- try
- {
- in = new URL (systemId).openStream ();
- }
- catch (MalformedURLException e)
- {
- in = new FileInputStream (systemId);
- }
+ in = getInputStream(systemId);
}
return new NamedInputStream (systemId, in, LOOKAHEAD);
}
@@ -143,22 +132,28 @@
}
if (in == null)
{
- if (systemId == null)
- {
- throw new IOException ("no system ID");
- }
- try
- {
- in = new URL (systemId).openStream ();
- }
- catch (MalformedURLException e)
- {
- in = new FileInputStream (systemId);
- }
+ in = getInputStream(systemId);
}
return new NamedInputStream (systemId, in, LOOKAHEAD);
}
+ private static InputStream getInputStream(String systemId)
+ throws IOException
+ {
+ if (systemId == null)
+ {
+ throw new IOException("no system ID");
+ }
+ try
+ {
+ return new URL(systemId).openStream();
+ }
+ catch (MalformedURLException e)
+ {
+ return new FileInputStream(systemId);
+ }
+ }
+
/**
* Returns an input stream for the specified URL.
* This returns a pushback stream that libxmlj can use to detect the
@@ -174,11 +169,21 @@
/**
* Convenience method for xmljDocLoader
*/
- static NamedInputStream getInputStream (String base, String url)
+ static NamedInputStream xmljGetInputStream(String base, String url)
throws IOException
{
- URL u = (base == null) ? new URL (url) : new URL (new URL (base), url);
- return getInputStream (u);
+ try
+ {
+ if (base != null)
+ {
+ url = new URL(new URL(base), url).toString();
+ }
+ }
+ catch (MalformedURLException e)
+ {
+ }
+ InputStream in = getInputStream(url);
+ return new NamedInputStream(url, in, LOOKAHEAD);
}
/**
===================================================================
Checking out kaffe/libraries/javalib/gnu/xml/transform/DOMResultWrapper.java
RCS: /home/cvs/kaffe/kaffe/libraries/javalib/gnu/xml/transform/DOMResultWrapper.java,v
VERS: 1.1
***************
--- /dev/null Sun Aug 4 19:57:58 2002
+++ kaffe/libraries/javalib/gnu/xml/transform/DOMResultWrapper.java Mon Nov 1 15:42:08 2004
@@ -0,0 +1,125 @@
+/*
+ * DOMResultWrapper.java
+ * Copyright (C) 2004 The Free Software Foundation
+ *
+ * This file is part of GNU JAXP, a library.
+ *
+ * GNU JAXP is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GNU JAXP is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Linking this library statically or dynamically with other modules is
+ * making a combined work based on this library. Thus, the terms and
+ * conditions of the GNU General Public License cover the whole
+ * combination.
+ *
+ * As a special exception, the copyright holders of this library give you
+ * permission to link this library with independent modules to produce an
+ * executable, regardless of the license terms of these independent
+ * modules, and to copy and distribute the resulting executable under
+ * terms of your choice, provided that you also meet, for each linked
+ * independent module, the terms and conditions of the license of that
+ * module. An independent module is a module which is not derived from
+ * or based on this library. If you modify this library, you may extend
+ * this exception to your version of the library, but you are not
+ * obliged to do so. If you do not wish to do so, delete this
+ * exception statement from your version.
+ */
+
+package gnu.xml.transform;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import javax.xml.transform.Result;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.sax.SAXResult;
+import javax.xml.transform.stream.StreamResult;
+import org.w3c.dom.Node;
+
+/**
+ * A DOM result that wraps an underlying result.
+ *
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+class DOMResultWrapper
+ extends DOMResult
+{
+
+ final Result result;
+
+ DOMResultWrapper(Result result)
+ {
+ this.result = result;
+ }
+
+ public Node getNode()
+ {
+ if (result instanceof DOMResult)
+ {
+ return ((DOMResult) result).getNode();
+ }
+ return null;
+ }
+
+ public Node getNextSibling()
+ {
+ if (result instanceof DOMResult)
+ {
+ return ((DOMResult) result).getNextSibling();
+ }
+ return null;
+ }
+
+ public String getSystemId()
+ {
+ return result.getSystemId();
+ }
+
+ public void setSystemId(String systemId)
+ {
+ result.setSystemId(systemId);
+ }
+
+ public void setNode(Node node)
+ {
+ if (result instanceof DOMResult)
+ {
+ ((DOMResult) result).setNode(node);
+ }
+ else if (result instanceof StreamResult)
+ {
+ try
+ {
+ StreamResult sr = (StreamResult) result;
+ OutputStream out = sr.getOutputStream();
+ DOMSerializer.serialize(node, out);
+ out.close();
+ }
+ catch (IOException e)
+ {
+ // TODO
+ e.printStackTrace();
+ }
+ }
+ else if (result instanceof SAXResult)
+ {
+ // TODO
+ }
+ }
+
+ public void setNextSibling(Node node)
+ {
+ // Will never be called by transform
+ }
+
+}
===================================================================
Checking out kaffe/libraries/javalib/gnu/xml/transform/DOMSerializer.java
RCS: /home/cvs/kaffe/kaffe/libraries/javalib/gnu/xml/transform/DOMSerializer.java,v
VERS: 1.1
***************
--- /dev/null Sun Aug 4 19:57:58 2002
+++ kaffe/libraries/javalib/gnu/xml/transform/DOMSerializer.java Mon Nov 1 15:42:08 2004
@@ -0,0 +1,299 @@
+/*
+ * DOMSerializer.java
+ * Copyright (C) 2004 The Free Software Foundation
+ *
+ * This file is part of GNU JAXP, a library.
+ *
+ * GNU JAXP is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GNU JAXP is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Linking this library statically or dynamically with other modules is
+ * making a combined work based on this library. Thus, the terms and
+ * conditions of the GNU General Public License cover the whole
+ * combination.
+ *
+ * As a special exception, the copyright holders of this library give you
+ * permission to link this library with independent modules to produce an
+ * executable, regardless of the license terms of these independent
+ * modules, and to copy and distribute the resulting executable under
+ * terms of your choice, provided that you also meet, for each linked
+ * independent module, the terms and conditions of the license of that
+ * module. An independent module is a module which is not derived from
+ * or based on this library. If you modify this library, you may extend
+ * this exception to your version of the library, but you are not
+ * obliged to do so. If you do not wish to do so, delete this
+ * exception statement from your version.
+ */
+
+package gnu.xml.transform;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import org.w3c.dom.Attr;
+import org.w3c.dom.CDATASection;
+import org.w3c.dom.Comment;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.DocumentType;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+/**
+ * Serializer for a DOM node.
+ *
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+class DOMSerializer
+{
+
+ static final int SPACE = 0x20;
+ static final int BANG = 0x21; // !
+ static final int APOS = 0x27; // '
+ static final int SLASH = 0x2f; // /
+ static final int BRA = 0x3c; // <
+ static final int KET = 0x3e; // >
+ static final int EQ = 0x3d; // =
+
+ static void serialize(Node node, OutputStream out)
+ throws IOException
+ {
+ final String charset = "UTF-8";
+ NodeList children;
+ int len;
+ String qName, value;
+ byte[] buf;
+ switch (node.getNodeType())
+ {
+ case Node.ATTRIBUTE_NODE:
+ Attr attr = (Attr) node;
+ // TODO namespaces
+ qName = attr.getNodeName();
+ buf = qName.getBytes(charset);
+ out.write(SPACE);
+ out.write(buf);
+ out.write(EQ);
+ value = "'" + encode(attr.getValue()) + "'";
+ buf = value.getBytes(charset);
+ out.write(buf);
+ break;
+ case Node.ELEMENT_NODE:
+ Element element = (Element) node;
+ // TODO namespaces
+ qName = element.getNodeName();
+ buf = qName.getBytes(charset);
+ out.write(BRA);
+ out.write(buf);
+ NamedNodeMap attrs = element.getAttributes();
+ if (attrs != null)
+ {
+ len = attrs.getLength();
+ for (int i = 0; i < len; i++)
+ {
+ Node child = attrs.item(i);
+ serialize(child, out);
+ }
*** Patch too long, truncated ***
More information about the kaffe
mailing list