1 16 19 package org.apache.xalan.transformer; 20 21 import java.util.Vector ; 22 23 import org.apache.xalan.templates.ElemTemplateElement; 24 import org.apache.xml.utils.PrefixResolver; 25 import org.apache.xml.utils.QName; 26 import org.apache.xml.utils.XMLString; 27 import org.apache.xpath.XPathContext; 28 import org.apache.xpath.objects.XNodeSet; 29 30 33 public class KeyManager 34 { 35 36 40 private transient Vector m_key_tables = null; 41 42 55 public XNodeSet getNodeSetDTMByKey( 56 XPathContext xctxt, int doc, QName name, XMLString ref, PrefixResolver nscontext) 57 throws javax.xml.transform.TransformerException 58 { 59 60 XNodeSet nl = null; 61 ElemTemplateElement template = (ElemTemplateElement) nscontext; 63 if ((null != template) 64 && null != template.getStylesheetRoot().getKeysComposed()) 65 { 66 boolean foundDoc = false; 67 68 if (null == m_key_tables) 69 { 70 m_key_tables = new Vector (4); 71 } 72 else 73 { 74 int nKeyTables = m_key_tables.size(); 75 76 for (int i = 0; i < nKeyTables; i++) 77 { 78 KeyTable kt = (KeyTable) m_key_tables.elementAt(i); 79 80 if (kt.getKeyTableName().equals(name) && doc == kt.getDocKey()) 81 { 82 nl = kt.getNodeSetDTMByKey(name, ref); 83 84 if (nl != null) 85 { 86 foundDoc = true; 87 88 break; 89 } 90 } 91 } 92 } 93 94 if ((null == nl) &&!foundDoc ) 95 { 96 KeyTable kt = 97 new KeyTable(doc, nscontext, name, 98 template.getStylesheetRoot().getKeysComposed(), 99 xctxt); 100 101 m_key_tables.addElement(kt); 102 103 if (doc == kt.getDocKey()) 104 { 105 foundDoc = true; 106 nl = kt.getNodeSetDTMByKey(name, ref); 107 } 108 } 109 } 110 111 return nl; 112 } 113 } 114 | Popular Tags |