1 28 29 package com.caucho.xpath.pattern; 30 31 import com.caucho.xpath.ExprEnvironment; 32 import com.caucho.xpath.XPathException; 33 34 import org.w3c.dom.Node ; 35 36 public class FromParent extends Axis { 37 public FromParent(AbstractPattern parent) 38 { 39 super(parent); 40 41 if (parent == null) 42 throw new RuntimeException (); 43 } 44 45 53 public boolean match(Node node, ExprEnvironment env) 54 throws XPathException 55 { 56 if (node == null) 57 return false; 58 59 if (node.getNodeType() != node.ELEMENT_NODE && 60 node.getNodeType() != node.DOCUMENT_NODE) 61 return false; 62 63 for (node = node.getFirstChild(); 64 node != null; 65 node = node.getNextSibling()) { 66 if (_parent.match(node, env)) 67 return true; 68 } 69 70 return false; 71 } 72 73 76 public boolean isStrictlyAscending() 77 { 78 return isSingleSelect(); 79 } 80 81 84 boolean isSingleSelect() 85 { 86 return _parent == null ? true : _parent.isSingleSelect(); 87 } 88 89 96 public Node firstNode(Node node, ExprEnvironment env) 97 { 98 return node.getParentNode(); 99 } 100 101 109 public Node nextNode(Node node, Node lastNode) 110 { 111 return null; 112 } 113 114 public String toString() 115 { 116 return getPrefix() + "parent::"; 117 } 118 } 119 | Popular Tags |