1 package com.icl.saxon.pattern; 2 import com.icl.saxon.*; 3 import com.icl.saxon.om.*; 4 import com.icl.saxon.om.NodeEnumeration; 5 import com.icl.saxon.expr.XPathException; 6 7 import java.util.*; 8 9 12 13 public final class KeyPattern extends Pattern { 14 15 private int keyfingerprint; private String keyvalue; 18 23 24 public KeyPattern(int namecode, String value) { 25 keyfingerprint = namecode & 0xfffff; 26 keyvalue = value; 27 } 28 29 34 35 public boolean matches(NodeInfo e, Context c) throws XPathException { 36 DocumentInfo doc = e.getDocumentRoot(); 37 Controller controller = c.getController(); 38 KeyManager km = controller.getKeyManager(); 39 NodeEnumeration nodes = km.selectByKey(keyfingerprint, doc, keyvalue, controller); 40 while(nodes.hasMoreElements()) { 41 if (nodes.nextElement().isSameNode(e)) { 42 return true; 43 } 44 } 45 return false; 46 } 47 48 } 49 50 | Popular Tags |