zongaro 2002/11/26 07:02:29
Modified: java/src/org/apache/xml/dtm/ref Tag: XSLTC_DTM
DTMDefaultBase.java
Log:
Added a getTypedAttribute method to make the process of finding a particular
attribute quicker than using getFirstAttribute and getNextAttribute. The
getTypedAttribute method will convert at most once to a node identity and
once to a node handle, where getFirstAttribute and getNextAttribute would for
each attribute checked.
Revision Changes Path
No revision
No revision
1.28.2.5 +32 -0
xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDefaultBase.java
Index: DTMDefaultBase.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDefaultBase.java,v
retrieving revision 1.28.2.4
retrieving revision 1.28.2.5
diff -u -r1.28.2.4 -r1.28.2.5
--- DTMDefaultBase.java 13 Nov 2002 17:04:06 -0000 1.28.2.4
+++ DTMDefaultBase.java 26 Nov 2002 15:02:29 -0000 1.28.2.5
@@ -1070,6 +1070,38 @@
}
/**
+ * Given a node handle and an expanded type ID, get the index of the node's
+ * attribute of that type, if any.
+ *
+ * @param nodeHandle int Handle of the node.
+ * @param attType int expanded type ID of the required attribute.
+ * @return Handle of attribute of the required type, or DTM.NULL to
indicate
+ * none exists.
+ */
+ protected int getTypedAttribute(int nodeHandle, int attType) {
+ int type = getNodeType(nodeHandle);
+ if (DTM.ELEMENT_NODE == type) {
+ int identity = makeNodeIdentity(nodeHandle);
+
+ while (DTM.NULL != (identity = getNextNodeIdentity(identity)))
+ {
+ type = _type(identity);
+
+ if (type == DTM.ATTRIBUTE_NODE)
+ {
+ if (_exptype(identity) == attType) return makeNodeHandle(identity);
+ }
+ else if (DTM.NAMESPACE_NODE != type)
+ {
+ break;
+ }
+ }
+ }
+
+ return DTM.NULL;
+ }
+
+ /**
* Given a node handle, advance to its next sibling.
* If not yet resolved, waits for more nodes to be added to the document
and
* tries again.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]