1 package com.icl.saxon.exslt; 2 import com.icl.saxon.Context; 3 import com.icl.saxon.Controller; 4 import com.icl.saxon.expr.*; 5 import com.icl.saxon.om.NodeInfo; 6 import com.icl.saxon.om.NodeEnumeration; 7 import java.util.Hashtable ; 8 import java.util.Vector ; 9 10 14 15 public abstract class Sets { 16 17 23 24 public static NodeEnumeration intersection(Context c, NodeEnumeration p1, NodeEnumeration p2) throws XPathException { 25 return new IntersectionEnumeration(p1, p2, c.getController()); 26 } 27 28 34 35 public static NodeEnumeration difference(Context c, NodeEnumeration p1, NodeEnumeration p2) throws XPathException { 36 return new DifferenceEnumeration(p1, p2, c.getController()); 37 } 38 39 46 47 public static boolean hasSameNode(Context c, NodeEnumeration p1, NodeEnumeration p2) throws XPathException { 48 NodeEnumeration intersection = 49 new IntersectionEnumeration(p1, p2, c.getController()); 50 return intersection.hasMoreElements(); 51 } 52 53 56 57 public static NodeEnumeration distinct(Context c, NodeEnumeration in) throws XPathException { 58 return new DistinctEnumeration(in, c.getController()); 59 } 60 61 65 66 public static NodeSetValue leading ( 67 Context c, 68 NodeEnumeration ns1, NodeEnumeration ns2) throws XPathException { 69 70 Controller controller = c.getController(); 71 if (!ns2.hasMoreElements()) { 72 return new NodeSetExtent(ns1, controller); 73 } 74 NodeInfo test = ns2.nextElement(); 75 76 Vector v = new Vector (); 77 while (ns1.hasMoreElements()) { 78 NodeInfo node = ns1.nextElement(); 79 if (controller.compare(node, test) < 0) { 80 v.addElement(node); 81 } else { 82 break; 83 } 84 } 85 return new NodeSetExtent(v, controller); 86 87 } 88 89 93 94 public static NodeSetValue trailing ( 95 Context c, 96 NodeEnumeration ns1, NodeEnumeration ns2) throws XPathException { 97 98 if (!ns2.hasMoreElements()) { 99 return new EmptyNodeSet(); 100 } 101 NodeInfo test = ns2.nextElement(); 102 Controller controller = c.getController(); 103 104 Vector v = new Vector (); 105 boolean pastLimit = false; 106 while (ns1.hasMoreElements()) { 107 NodeInfo node = ns1.nextElement(); 108 if (pastLimit) { 109 v.addElement(node); 110 } else if (controller.compare(node, test) > 0) { 111 pastLimit = true; 112 v.addElement(node); 113 } 114 } 115 return new NodeSetExtent(v, controller); 116 } 117 118 } 119 120 121 122 123 124 | Popular Tags |