You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mo...@apache.org on 2001/09/19 15:22:51 UTC
cvs commit: xml-xalan/java/src/org/apache/xalan/xsltc/dom DOMImpl.java MatchingIterator.java StepIterator.java
morten 01/09/19 06:22:51
Modified: java/src/org/apache/xalan/xsltc/dom DOMImpl.java
MatchingIterator.java StepIterator.java
Log:
Verious fixes for iterators.
PR: n/a
Obtained from: n/a
Submitted by: morten@xml.apache.org
Reviewed by: morten@xml.apache.org
Revision Changes Path
1.26 +26 -7 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.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- DOMImpl.java 2001/09/17 08:20:55 1.25
+++ DOMImpl.java 2001/09/19 13:22:51 1.26
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: DOMImpl.java,v 1.25 2001/09/17 08:20:55 morten Exp $
+ * @(#)$Id: DOMImpl.java,v 1.26 2001/09/19 13:22:51 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -1416,7 +1416,8 @@
}
_source.setStartNode(node);
- return resetPosition();
+ //return resetPosition();
+ return(this);
}
public int next() {
@@ -1429,6 +1430,7 @@
case PRESERVE_SPACE:
return returnNode(node);
case USE_PREDICATE:
+ default:
if (_whitespace.getBit(node) &&
_filter.stripSpace((DOM)DOMImpl.this, node,
_mapping[_type[_parent[node]]]))
@@ -1470,6 +1472,7 @@
count++;
break;
case USE_PREDICATE:
+ default:
if (_whitespace.getBit(node) &&
_filter.stripSpace((DOM)DOMImpl.this, node,
_mapping[_type[_parent[node]]]))
@@ -2339,8 +2342,14 @@
// Start element definition
final String name = copyElement(node, type, handler);
// Copy element attribute
- for (int a=_lengthOrAttr[node]; a!=NULL; a=_nextSibling[a])
+ for (int a=_lengthOrAttr[node]; a!=NULL; a=_nextSibling[a]) {
+ final String uri = getNamespaceName(a);
+ if (uri != EMPTYSTRING) {
+ final String prefix = _prefixArray[_prefix[a]];
+ handler.namespace(prefix, uri);
+ }
handler.attribute(getNodeName(a), makeStringValue(a));
+ }
// Copy element children
for (int c=_offsetOrChild[node]; c!=NULL; c=_nextSibling[c])
copy(c, handler);
@@ -2349,6 +2358,11 @@
}
// Shallow copy of attribute to output handler
else {
+ final String uri = getNamespaceName(node);
+ if (uri != EMPTYSTRING) {
+ final String prefix = _prefixArray[_prefix[node]];
+ handler.namespace(prefix, uri);
+ }
handler.attribute(getNodeName(node), makeStringValue(node));
}
break;
@@ -2405,9 +2419,12 @@
return(copyElement(node, type, handler));
}
else {
- String name = getNodeName(node);
- final String value = makeStringValue(node);
- handler.attribute(name, value);
+ final String uri = getNamespaceName(node);
+ if (uri != EMPTYSTRING) {
+ final String prefix = _prefixArray[_prefix[node]];
+ handler.namespace(prefix, uri);
+ }
+ handler.attribute(getNodeName(node), makeStringValue(node));
return null;
}
}
@@ -2773,8 +2790,9 @@
else if (!_preserve) {
int i = _baseOffset;
while (isWhitespaceChar(_text[i++]) && i < limit) ;
- if ((i == limit) && isWhitespaceChar(_text[i-1]))
+ if ((i == limit) && isWhitespaceChar(_text[i-1])) {
_whitespace.setBit(node);
+ }
}
_type[node] = TEXT;
@@ -2982,6 +3000,7 @@
public void endElement(String namespaceURI, String localName,
String qname) {
makeTextNode(false);
+
// Revert to strip/preserve-space setting from before this element
xmlSpaceRevert(_parentStack[_sp]);
_previousSiblingStack[_sp--] = 0;
1.3 +6 -15 xml-xalan/java/src/org/apache/xalan/xsltc/dom/MatchingIterator.java
Index: MatchingIterator.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/MatchingIterator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MatchingIterator.java 2001/09/17 08:20:55 1.2
+++ MatchingIterator.java 2001/09/19 13:22:51 1.3
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: MatchingIterator.java,v 1.2 2001/09/17 08:20:55 morten Exp $
+ * @(#)$Id: MatchingIterator.java,v 1.3 2001/09/19 13:22:51 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -95,13 +95,10 @@
_source.setStartNode(node);
// Calculate the position of the node in the set
- final int match = _match;
- int i = 1;
- while ((node = _source.next()) != END && node != match) {
- ++i;
- }
- _matchPos = i;
+ _matchPos = 1;
_matchLast = -1;
+ while ( ((node = _source.next()) != END) && (node != _match) )
+ _matchPos++;
}
return this;
}
@@ -116,14 +113,8 @@
}
public int getLast() {
- if (_matchLast == -1) {
- _source.reset();
- int i = 1, node;
- while ((node = _source.next()) != END) {
- ++i;
- }
- _matchLast = i - 1;
- }
+ if (_matchLast == -1)
+ _matchLast = _source.getLast();
return _matchLast;
}
1.5 +7 -7 xml-xalan/java/src/org/apache/xalan/xsltc/dom/StepIterator.java
Index: StepIterator.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/StepIterator.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- StepIterator.java 2001/09/17 08:20:55 1.4
+++ StepIterator.java 2001/09/19 13:22:51 1.5
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: StepIterator.java,v 1.4 2001/09/17 08:20:55 morten Exp $
+ * @(#)$Id: StepIterator.java,v 1.5 2001/09/19 13:22:51 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -96,8 +96,9 @@
public NodeIterator setStartNode(int node) {
if (_isRestartable) {
- // iterator is not a clone
+ // Set start node for left-hand iterator...
_source.setStartNode(_startNode = node);
+ // ... and get start node for right-hand iterator from left-hand.
_iterator.setStartNode(_source.next());
return resetPosition();
}
@@ -105,23 +106,22 @@
}
public NodeIterator reset() {
- //_source.setStartNode(_startNode);
_source.reset();
- int node = _source.next();
- _iterator.setStartNode(node);
+ _iterator.setStartNode(_source.next());
return resetPosition();
}
public int next() {
for (int node;;) {
+ // Try to get another node from the right-hand iterator
if ((node = _iterator.next()) != END) {
return returnNode(node);
}
- // local iterator ran out of nodes
- // try to get new start node from source
+ // If not, get the next starting point from left-hand iterator...
else if ((node = _source.next()) == END) {
return END;
}
+ // ...and pass it on to the right-hand iterator
else {
_iterator.setStartNode(node);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org