You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by ig...@apache.org on 2003/10/10 20:42:53 UTC
cvs commit: xml-xalan/java/src/org/apache/xalan/xsltc/dom DOMAdapter.java SAXImpl.java
igorh 2003/10/10 11:42:53
Modified: java/src/org/apache/xalan/xsltc/compiler xpath.cup
XSLTC.java
java/src/org/apache/xalan/xsltc/dom DOMAdapter.java
SAXImpl.java
Log:
Patch for Bugzilla Bug 14607
Revision Changes Path
1.49 +3 -3 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/xpath.cup
Index: xpath.cup
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/xpath.cup,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- xpath.cup 7 Oct 2003 15:44:22 -0000 1.48
+++ xpath.cup 10 Oct 2003 18:42:53 -0000 1.49
@@ -169,7 +169,7 @@
if (axis == Axis.NAMESPACE) {
nodeType = (name.toString().equals("*")) ? -1
- : _xsltc.registerNamespace(name);
+ : _xsltc.registerNamespacePrefix(name);;
}
else {
final String uri = name.getNamespace();
@@ -231,7 +231,7 @@
if (axis == Axis.NAMESPACE) {
return (name.toString().equals("*")) ? -1
- : _xsltc.registerNamespace(name);
+ : _xsltc.registerNamespacePrefix(name);
}
if (name.getNamespace() == null) {
1.56 +24 -10 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/XSLTC.java
Index: XSLTC.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/XSLTC.java,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -r1.55 -r1.56
--- XSLTC.java 3 Oct 2003 16:26:09 -0000 1.55
+++ XSLTC.java 10 Oct 2003 18:42:53 -0000 1.56
@@ -125,6 +125,8 @@
private int _nextNSType; // Next available namespace type
private Vector _namespaceIndex; // Index of all registered namespaces
private Hashtable _namespaces; // Hashtable of all registered namespaces
+ private Hashtable _namespacePrefixes;// Hashtable of all registered namespace prefixes
+
// All literal text in the stylesheet
private Vector m_characterData;
@@ -209,6 +211,7 @@
_namespaces.put("",new Integer(_nextNSType));
_namesIndex = new Vector(128);
_namespaceIndex = new Vector(32);
+ _namespacePrefixes = new Hashtable();
_stylesheet = null;
_parser.init();
//_variableSerial = 1;
@@ -675,15 +678,26 @@
return code.intValue();
}
- /**
- * Registers an element and gives it a type so that it can be mapped to
- * DOM element types at run-time.
- */
- public int registerNamespace(QName name) {
- final SymbolTable stable = _parser.getSymbolTable();
- final String uri = stable.lookupNamespace(name.toString());
- final int code = registerNamespace(uri);
- return code;
+ /**
+ * Registers a namespace prefix and gives it a type so that it can be mapped to
+ * DOM namespace types at run-time.
+ */
+
+ public int registerNamespacePrefix(QName name) {
+
+ Integer code = (Integer)_namespacePrefixes.get(name.toString());
+ if (code == null) {
+ code = new Integer(_nextGType++);
+ _namespacePrefixes.put(name.toString(), code);
+ final String uri = name.getNamespace();
+ if ((uri != null) && (!uri.equals(""))){
+ // namespace::ext2:ped2 will be made empty in TypedNamespaceIterator
+ _namesIndex.addElement("?");
+ } else{
+ _namesIndex.addElement("?"+name.getLocalPart());
+ }
+ }
+ return code.intValue();
}
/**
1.20 +2 -10 xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMAdapter.java
Index: DOMAdapter.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMAdapter.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- DOMAdapter.java 23 Jun 2003 15:58:17 -0000 1.19
+++ DOMAdapter.java 10 Oct 2003 18:42:53 -0000 1.20
@@ -212,15 +212,7 @@
public DTMAxisIterator getTypedAxisIterator(final int axis,
final int type) {
final int[] reverse = getReverse();
-
- if (axis == Axis.NAMESPACE) {
- short[] NSReverse = getNSReverse();
- if (type == NO_TYPE || type > NSReverse.length) {
- return _dom.getAxisIterator(axis);
- } else {
- return _dom.getTypedAxisIterator(axis, NSReverse[type]);
- }
- } else if (_saxImpl != null) {
+ if (_saxImpl != null) {
return _saxImpl.getTypedAxisIterator(axis, reverse[type]);
} else {
return _dom.getTypedAxisIterator(axis, type);
1.10 +17 -15 xml-xalan/java/src/org/apache/xalan/xsltc/dom/SAXImpl.java
Index: SAXImpl.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/SAXImpl.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- SAXImpl.java 6 Oct 2003 18:25:57 -0000 1.9
+++ SAXImpl.java 10 Oct 2003 18:42:53 -0000 1.10
@@ -361,8 +361,8 @@
* model for a given node, filtered by extended type ID.
*/
public class TypedNamespaceIterator extends NamespaceIterator {
- /** The extended type ID that was requested. */
- private final int _nodeType;
+
+ private String _nsPrefix;
/**
* Constructor TypedChildrenIterator
@@ -370,9 +370,14 @@
*
* @param nodeType The extended type ID being requested.
*/
- public TypedNamespaceIterator(int nodeType) {
+ public TypedNamespaceIterator(int nodeType) {
super();
- _nodeType = nodeType;
+ if(m_expandedNameTable != null){
+ final String prefix = m_expandedNameTable.getLocalName(nodeType);
+ if((prefix != null) && (prefix.charAt(0) == '?') ) {
+ _nsPrefix = prefix.substring(1);
+ }
+ }
}
/**
@@ -381,22 +386,21 @@
* @return The next node handle in the iteration, or END.
*/
public int next() {
- int node;
-
+ if((_nsPrefix == null) ||(_nsPrefix.length() == 0) ){
+ return (END);
+ }
+ int node = END;
for (node = super.next(); node != END; node = super.next()) {
- if (getExpandedTypeID(node) == _nodeType
- || getNodeType(node) == _nodeType
- || getIdForNamespace(getStringValueX(node))
- == _nodeType) {
+ if (_nsPrefix.compareTo(getLocalName(node))== 0) {
return returnNode(node);
}
}
-
return (END);
}
} // end of TypedNamespaceIterator
+
/**************************************************************
* This is a specialised iterator for predicates comparing node or
* attribute values to variable or parameter values.
@@ -1209,9 +1213,7 @@
case Axis.PRECEDINGSIBLING:
return new TypedPrecedingSiblingIterator(type);
case Axis.NAMESPACE:
- return (type == DTM.ELEMENT_NODE)
- ? new NamespaceIterator()
- : new TypedNamespaceIterator(type);
+ return new TypedNamespaceIterator(type);
default:
BasisLibrary.runTimeError(BasisLibrary.TYPED_AXIS_SUPPORT_ERR, Axis.names[axis]);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org