zongaro 2002/11/13 09:04:01
Modified: java/src/org/apache/xalan/xsltc/dom Tag: XSLTC_DTM
DOMImpl.java SAXImpl.java
Log:
1) Renamed getNodeValue method in XSLTC's DOM to getStringValueX - meaning
"get
the string value of a node according to XPath's definition." The old
getNodeValue overrode DTM's getNodeValue with slightly different semantics and
a slightly higher cost in terms of performance.
2) Reworked copyElement to improve performance of node copying.
Revision Changes Path
No revision
No revision
1.68.2.16 +20 -38
xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMImpl.java
Index: DOMImpl.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMImpl.java,v
retrieving revision 1.68.2.15
retrieving revision 1.68.2.16
diff -u -r1.68.2.15 -r1.68.2.16
--- DOMImpl.java 5 Nov 2002 20:49:08 -0000 1.68.2.15
+++ DOMImpl.java 13 Nov 2002 17:03:48 -0000 1.68.2.16
@@ -328,7 +328,7 @@
namespaces.setStartNode(anode);
while ((nsnode = namespaces.next()) != DTM.NULL) {
if (getLocalName(nsnode).equals(prefix)) {
- return getNodeValue(nsnode);
+ return getStringValueX(nsnode);
}
}
}
@@ -776,7 +776,7 @@
int node;
while ((node = _source.next()) != END)
{
- String val = getNodeValue(node);
+ String val = getStringValueX(node);
if (_value.equals(val) == _op)
{
if (_returnType == RETURN_CURRENT)
@@ -894,7 +894,7 @@
/**
* Returns the (String) value of any node in the tree
*/
- public String getNodeValue(final int node) {
+ public String getStringValueX(final int node) {
if (node == DTM.NULL) return EMPTYSTRING;
switch(getNodeType(node)) {
case DTM.ROOT_NODE:
@@ -1568,7 +1568,7 @@
copyPI(node, handler);
break;
case DTM.COMMENT_NODE:
- handler.comment(getNodeValue(node)/*_text,
+ handler.comment(getStringValueX(node)/*_text,
_offsetOrChild[node],
_lengthOrAttr[node])*/);
break;
@@ -1588,7 +1588,7 @@
// Copy element attribute
for(int a=getFirstAttribute(node); a!=DTM.NULL;
a=getNextAttribute(a)){
final String uri = getNamespaceName(a);
- if (uri != EMPTYSTRING) {
+ if (uri.length() != 0) {
final String prefix = getPrefix(a);
handler.namespace(prefix, uri);
}
@@ -1599,7 +1599,7 @@
a = getNextNamespaceNode(node, a, true))
{
handler.namespace(getNodeNameX(a),
- getNodeValue(a));
+ getStringValueX(a));
}
// Copy element children
@@ -1611,7 +1611,7 @@
// Shallow copy of attribute to output handler
else {
final String uri = getNamespaceName(node);
- if (uri != EMPTYSTRING) {
+ if (uri.length() != 0) {
final String prefix = getPrefix(node);
handler.namespace(prefix, uri);
}
@@ -1667,18 +1667,18 @@
copyPI(node, handler);
return null;
case DTM.COMMENT_NODE:
- final String comment = getNodeValue(node); /*)new String(_text,
+ final String comment = getStringValueX(node); /*)new String(_text,
_offsetOrChild[node],
_lengthOrAttr[node]);*/
handler.comment(comment);
return null;
case DTM.NAMESPACE_NODE:
handler.namespace(getNodeNameX(node), //_prefixArray[_prefix[node]],
- getNodeValue(node)); //makeStringValue(node));
+ getStringValueX(node)); //makeStringValue(node));
return null;
case DTM.ATTRIBUTE_NODE:
final String uri = getNamespaceName(node);
- if (uri != EMPTYSTRING) {
+ if (uri.length() != 0) {
final String prefix = getPrefix(node); //
_prefixArray[_prefix[node]];
handler.namespace(prefix, uri);
}
@@ -1692,7 +1692,7 @@
else
{
final String uri1 = getNamespaceName(node);
- if (uri1 != EMPTYSTRING) {
+ if (uri1.length() != 0) {
final String prefix = getPrefix(node); //
_prefixArray[_prefix[node]];
handler.namespace(prefix, uri1);
}
@@ -1706,35 +1706,17 @@
TransletOutputHandler handler)
throws TransletException
{
-
- String name = null;
- final String prefix = getPrefix(node);
+ final String name = getNodeName(node);
+ final String localName = getLocalName(node);
final String uri = getNamespaceName(node);
- final String local = getLocalName(node);
- name = (prefix.equals(EMPTYSTRING)) ? local : (prefix + ':' + local);
- if (uri != null)
- {
- handler.startElement(name);
- handler.namespace(prefix, uri);
- }
- else
- {
-/*
- * %HZ%: Should prefix be copied when URI is null? The MAIN branch avoids
- * %HZ%: it today.
- */
- handler.startElement(name);
- }
+ handler.startElement(name);
-/* %HZ%: How do namespaces normally get copied?
- // Copy element's namespaces
- for (int a = getFirstNamespaceNode(node, false);
- a != DTM.NULL;
- a = getNextNamespaceNode(node, a, false)) {
- handler.namespace(getPrefix(a), getStringValue(a).toString());
+ if (name.length() != localName.length()) {
+ handler.namespace(getPrefix(node), uri);
+ } else if (uri.length() != 0) {
+ handler.namespace(EMPTYSTRING, uri);
}
-*/
return name;
}
@@ -1820,7 +1802,7 @@
int attribute = getFirstAttribute(element);
while (attribute != DTM.NULL) {
buffer.append(' ').append(getNodeName(attribute))
- .append("=\"").append(getNodeValue(attribute))
+ .append("=\"").append(getStringValueX(attribute))
.append('"');
attribute = getNextAttribute(attribute);
}
@@ -1877,7 +1859,7 @@
if (DTM.NULL != langAttr)
{
- return getNodeValue(langAttr);
+ return getStringValueX(langAttr);
}
}
1.1.2.19 +16 -24
xml-xalan/java/src/org/apache/xalan/xsltc/dom/Attic/SAXImpl.java
Index: SAXImpl.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/Attic/SAXImpl.java,v
retrieving revision 1.1.2.18
retrieving revision 1.1.2.19
diff -u -r1.1.2.18 -r1.1.2.19
--- SAXImpl.java 5 Nov 2002 20:47:33 -0000 1.1.2.18
+++ SAXImpl.java 13 Nov 2002 17:03:54 -0000 1.1.2.19
@@ -642,7 +642,7 @@
int node;
while ((node = _source.next()) != END)
{
- String val = getNodeValue(node);
+ String val = getStringValueX(node);
if (_value.equals(val) == _op)
{
if (_returnType == RETURN_CURRENT)
@@ -829,7 +829,7 @@
/**
* Returns the (String) value of any node in the tree
*/
- public String getNodeValue(final int node)
+ public String getStringValueX(final int node)
{
if (node == DTM.NULL) return EMPTYSTRING;
switch(getNodeType(node)) {
@@ -1724,7 +1724,7 @@
copyPI(node, handler);
break;
case DTM.COMMENT_NODE:
- handler.comment(getNodeValue(node));
+ handler.comment(getStringValueX(node));
break;
case DTM.TEXT_NODE:
boolean oldEscapeSetting = false;
@@ -1757,7 +1757,7 @@
for(int a=getFirstAttribute(node); a!=DTM.NULL;
a=getNextAttribute(a))
{
final String uri = getNamespaceName(a);
- if (uri != EMPTYSTRING) {
+ if (uri.length() != 0) {
final String prefix = getPrefix(a);
handler.namespace(prefix, uri);
}
@@ -1780,7 +1780,7 @@
// Shallow copy of attribute to output handler
else {
final String uri = getNamespaceName(node);
- if (uri != EMPTYSTRING) {
+ if (uri.length() != 0) {
final String prefix = getPrefix(node);
handler.namespace(prefix, uri);
}
@@ -1834,7 +1834,7 @@
copyPI(node, handler);
return null;
case DTM.COMMENT_NODE:
- handler.comment(getNodeValue(node));
+ handler.comment(getStringValueX(node));
return null;
case DTM.NAMESPACE_NODE:
handler.namespace(getNodeNameX(node), //_prefixArray[_prefix[node]],
@@ -1842,7 +1842,7 @@
return null;
case DTM.ATTRIBUTE_NODE:
final String uri = getNamespaceName(node);
- if (uri != EMPTYSTRING) {
+ if (uri.length() != 0) {
final String prefix = getPrefix(node); //
_prefixArray[_prefix[node]];
handler.namespace(prefix, uri);
}
@@ -1856,7 +1856,7 @@
else
{
final String uri1 = getNamespaceName(node);
- if (uri1 != EMPTYSTRING) {
+ if (uri1.length() != 0) {
final String prefix = getPrefix(node); //
_prefixArray[_prefix[node]];
handler.namespace(prefix, uri1);
}
@@ -1870,24 +1870,16 @@
TransletOutputHandler handler)
throws TransletException
{
- String name = null;
- final String prefix = getPrefix(node);
+ final String name = getNodeName(node);
+ final String localName = getLocalName(node);
final String uri = getNamespaceName(node);
- final String local = getLocalName(node);
- name = (prefix.equals(EMPTYSTRING)) ? local : (prefix + ':' + local);
- if (uri != null)
- {
- handler.startElement(name);
- handler.namespace(prefix, uri);
- }
- else
- {
-/*
- * %HZ%: Should prefix be copied when URI is null? The MAIN branch avoids
- * %HZ%: it today.
- */
- handler.startElement(name);
+ handler.startElement(name);
+
+ if (name.length() != localName.length()) {
+ handler.namespace(getPrefix(node), uri);
+ } else if (uri.length() != 0) {
+ handler.namespace(EMPTYSTRING, uri);
}
return name;
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]