1 /* 2 * reserved comment block 3 * DO NOT REMOVE OR ALTER! 4 */ 5 /* 6 * Licensed to the Apache Software Foundation (ASF) under one or more 7 * contributor license agreements. See the NOTICE file distributed with 8 * this work for additional information regarding copyright ownership. 9 * The ASF licenses this file to You under the Apache License, Version 2.0 10 * (the "License"); you may not use this file except in compliance with 11 * the License. You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, software 16 * distributed under the License is distributed on an "AS IS" BASIS, 17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 * See the License for the specific language governing permissions and 19 * limitations under the License. 20 */ 21 22 package com.sun.org.apache.xml.internal.dtm; 23 24 /** 25 * Specifies values related to XPath Axes. 26 * <p>The ancestor, descendant, following, preceding and self axes partition a 27 * document (ignoring attribute and namespace nodes): they do not overlap 28 * and together they contain all the nodes in the document.</p> 29 * 30 */ 31 public final class Axis 32 { 33 34 /** 35 * The ancestor axis contains the ancestors of the context node; 36 * the ancestors of the context node consist of the parent of context 37 * node and the parent's parent and so on; thus, the ancestor axis will 38 * always include the root node, unless the context node is the root node. 39 */ 40 public static final int ANCESTOR = 0; 41 42 /** 43 * the ancestor-or-self axis contains the context node and the ancestors of 44 * the context node; thus, the ancestor axis will always include the 45 * root node. 46 */ 47 public static final int ANCESTORORSELF = 1; 48 49 /** 50 * the attribute axis contains the attributes of the context node; the axis 51 * will be empty unless the context node is an element. 52 */ 53 public static final int ATTRIBUTE = 2; 54 55 /** The child axis contains the children of the context node. */ 56 public static final int CHILD = 3; 57 58 /** 59 * The descendant axis contains the descendants of the context node; 60 * a descendant is a child or a child of a child and so on; thus the 61 * descendant axis never contains attribute or namespace nodes. 62 */ 63 public static final int DESCENDANT = 4; 64 65 /** 66 * The descendant-or-self axis contains the context node and the 67 * descendants of the context node. 68 */ 69 public static final int DESCENDANTORSELF = 5; 70 71 /** 72 * the following axis contains all nodes in the same document as the 73 * context node that are after the context node in document order, excluding 74 * any descendants and excluding attribute nodes and namespace nodes. 75 */ 76 public static final int FOLLOWING = 6; 77 78 /** 79 * The following-sibling axis contains all the following siblings of the 80 * context node; if the context node is an attribute node or namespace node, 81 * the following-sibling axis is empty. 82 */ 83 public static final int FOLLOWINGSIBLING = 7; 84 85 /** 86 * The namespace axis contains the namespace nodes of the context node; the 87 * axis will be empty unless the context node is an element. 88 */ 89 public static final int NAMESPACEDECLS = 8; 90 91 /** 92 * The namespace axis contains the namespace nodes of the context node; the 93 * axis will be empty unless the context node is an element. 94 */ 95 public static final int NAMESPACE = 9; 96 97 /** 98 * The parent axis contains the parent of the context node, 99 * if there is one. 100 */ 101 public static final int PARENT = 10; 102 103 /** 104 * The preceding axis contains all nodes in the same document as the context 105 * node that are before the context node in document order, excluding any 106 * ancestors and excluding attribute nodes and namespace nodes 107 */ 108 public static final int PRECEDING = 11; 109 110 /** 111 * The preceding-sibling axis contains all the preceding siblings of the 112 * context node; if the context node is an attribute node or namespace node, 113 * the preceding-sibling axis is empty. 114 */ 115 public static final int PRECEDINGSIBLING = 12; 116 117 /** The self axis contains just the context node itself. */ 118 public static final int SELF = 13; 119 120 /** 121 * A non-xpath axis, traversing the subtree including the subtree 122 * root, descendants, attributes, and namespace node decls. 123 */ 124 public static final int ALLFROMNODE = 14; 125 126 /** 127 * A non-xpath axis, traversing the the preceding and the ancestor nodes, 128 * needed for inverseing select patterns to match patterns. 129 */ 130 public static final int PRECEDINGANDANCESTOR = 15; 131 132 // =========================================== 133 // All axis past this are absolute. 134 135 /** 136 * A non-xpath axis, returns all nodes in the tree from and including the 137 * root. 138 */ 139 public static final int ALL = 16; 140 141 /** 142 * A non-xpath axis, returns all nodes that aren't namespaces or attributes, 143 * from and including the root. 144 */ 145 public static final int DESCENDANTSFROMROOT = 17; 146 147 /** 148 * A non-xpath axis, returns all nodes that aren't namespaces or attributes, 149 * from and including the root. 150 */ 151 public static final int DESCENDANTSORSELFFROMROOT = 18; 152 153 /** 154 * A non-xpath axis, returns root only. 155 */ 156 public static final int ROOT = 19; 157 158 /** 159 * A non-xpath axis, for functions. 160 */ 161 public static final int FILTEREDLIST = 20; 162 163 /** 164 * A table to identify whether an axis is a reverse axis; 165 */ 166 private static final boolean[] isReverse = { 167 true, // ancestor 168 true, // ancestor-or-self 169 false, // attribute 170 false, // child 171 false, // descendant 172 false, // descendant-or-self 173 false, // following 174 false, // following-sibling 175 false, // namespace 176 false, // namespace-declarations 177 false, // parent (one node, has no order) 178 true, // preceding 179 true, // preceding-sibling 180 false // self (one node, has no order) 181 }; 182 183 /** The names of the axes for diagnostic purposes. */ 184 private static final String[] names = 185 { 186 "ancestor", // 0 187 "ancestor-or-self", // 1 188 "attribute", // 2 189 "child", // 3 190 "descendant", // 4 191 "descendant-or-self", // 5 192 "following", // 6 193 "following-sibling", // 7 194 "namespace-decls", // 8 195 "namespace", // 9 196 "parent", // 10 197 "preceding", // 11 198 "preceding-sibling", // 12 199 "self", // 13 200 "all-from-node", // 14 201 "preceding-and-ancestor", // 15 202 "all", // 16 203 "descendants-from-root", // 17 204 "descendants-or-self-from-root", // 18 205 "root", // 19 206 "filtered-list" // 20 207 }; 208 isReverse(int axis)209 public static boolean isReverse(int axis){ 210 return isReverse[axis]; 211 } 212 getNames(int index)213 public static String getNames(int index){ 214 return names[index]; 215 } 216 getNamesLength()217 public static int getNamesLength(){ 218 return names.length; 219 } 220 221 } 222