home *** CD-ROM | disk | FTP | other *** search
- package com.kav.xsl;
-
- import java.io.PrintWriter;
- import java.util.Hashtable;
- import org.w3c.dom.Node;
-
- class SelectExpr {
- private UnionExpr unionExpr;
- private Hashtable attrParents = new Hashtable();
-
- public SelectExpr() {
- }
-
- public String toString() {
- return this.unionExpr != null ? this.unionExpr.toString() : "";
- }
-
- protected void getUnionExpr(UnionExpr var1) {
- this.unionExpr = var1;
- }
-
- protected void print(PrintWriter var1) {
- if (this.unionExpr != null) {
- this.unionExpr.print(var1);
- }
-
- }
-
- protected NodeSet selectNodes(Node var1, Hashtable var2) {
- if (this.unionExpr == null) {
- return new NodeSet(0);
- } else {
- NodeSet var3 = new NodeSet();
- this.attrParents.clear();
- Object var4 = null;
- Object var5 = null;
-
- for(int var6 = 0; var6 < this.unionExpr.getLength(); ++var6) {
- PathExpr var10 = (PathExpr)this.unionExpr.item(var6);
- NodeSet var9 = this.selectNodes(var10, var1, var2);
-
- for(int var7 = 0; var7 < var9.size(); ++var7) {
- var3.add(var9.get(var7));
- }
-
- var9.clear();
- }
-
- var3 = this.reorder(var3);
- this.attrParents.clear();
- return var3;
- }
- }
-
- protected void setUnionExpr(UnionExpr var1) {
- this.unionExpr = var1;
- }
-
- private int childNumber(Node var1) {
- int var2 = 0;
-
- for(Node var3 = var1; (var3 = var3.getPreviousSibling()) != null; ++var2) {
- }
-
- return var2;
- }
-
- private int compareOrders(int[] var1, int[] var2) {
- for(int var3 = 0; var3 < var1.length && var3 < var2.length; ++var3) {
- if (var1[var3] < var2[var3]) {
- return -1;
- }
-
- if (var2[var3] < var1[var3]) {
- return 1;
- }
- }
-
- if (var1.length < var2.length) {
- return -1;
- } else {
- return var2.length < var1.length ? 1 : 0;
- }
- }
-
- private int[] getDocumentOrder(Node var1, Hashtable var2) {
- if (var1 == null) {
- return new int[0];
- } else {
- Node var3 = var1;
- if (var1.getNodeType() == 2) {
- var3 = (Node)this.attrParents.get(var1);
- if (var3 == null) {
- int[] var4 = new int[]{0};
- var2.put(var1, var4);
- } else {
- int[] var6 = (int[])var2.get(var3);
- if (var6 != null) {
- var2.put(var1, var6);
- }
- }
- }
-
- int[] var7 = (int[])var2.get(var3);
- if (var7 != null) {
- return var7;
- } else {
- int[] var5 = this.getDocumentOrder(var3.getParentNode(), var2);
- var7 = new int[var5.length + 1];
- System.arraycopy(var5, 0, var7, 1, var5.length);
- var7[0] = this.childNumber(var3);
- var2.put(var1, var7);
- return var7;
- }
- }
- }
-
- private NodeSet reorder(NodeSet var1) {
- if (var1.size() < 2) {
- return var1;
- } else {
- Hashtable var2 = new Hashtable(var1.size());
-
- for(int var3 = 0; var3 < var1.size(); ++var3) {
- this.getDocumentOrder(var1.get(var3), var2);
- }
-
- NodeSet var4 = new NodeSet(var1.size());
- var4.add(var1.get(0));
-
- for(int var5 = 1; var5 < var1.size(); ++var5) {
- Node var6 = var1.get(var5);
- int[] var7 = (int[])var2.get(var6);
-
- for(int var8 = 0; var8 < var4.size(); ++var8) {
- int[] var9 = (int[])var2.get(var4.get(var8));
- if (this.compareOrders(var7, var9) < 0) {
- var4.add(var8, var6);
- break;
- }
-
- if (var8 == var4.size() - 1) {
- var4.add(var6);
- break;
- }
- }
- }
-
- return var4;
- }
- }
-
- private NodeSet selectNodes(PathExpr var1, Node var2, Hashtable var3) {
- if (var1 != null && var2 != null && ((PatternExpr)var1).getLength() != 0) {
- NodeSet var4 = new NodeSet();
- if (var1.isAbsolute() && var2.getNodeType() != 9) {
- var4.add(var2.getOwnerDocument());
- } else {
- var4.add(var2);
- }
-
- for(int var5 = 0; var5 < ((PatternExpr)var1).getLength(); ++var5) {
- FilterExpr var6 = (FilterExpr)((PatternExpr)var1).item(var5);
- NodeSet var7 = new NodeSet();
-
- for(int var8 = 0; var8 < var4.size(); ++var8) {
- Node var9 = var4.get(var8);
- short var10 = var9.getNodeType();
- if (var10 != 1 && var10 != 9) {
- var7.add(var9);
- } else {
- this.selectNodes(var6, var9, var3, var7);
- }
- }
-
- var4 = var7;
- }
-
- return var4;
- } else {
- return new NodeSet(0);
- }
- }
-
- private void selectNodes(FilterExpr param1, Node param2, Hashtable param3, NodeSet param4) {
- // $FF: Couldn't be decompiled
- }
- }
-