home *** CD-ROM | disk | FTP | other *** search
- package com.kav.xsl;
-
- import com.kav.util.List;
- import java.util.Enumeration;
- import java.util.Hashtable;
- import org.w3c.dom.Attr;
- import org.w3c.dom.Comment;
- import org.w3c.dom.Element;
- import org.w3c.dom.NamedNodeMap;
- import org.w3c.dom.Node;
- import org.w3c.dom.NodeList;
- import org.w3c.dom.ProcessingInstruction;
- import org.w3c.dom.Text;
-
- public class XSLObject {
- public static final short APPLY_IMPORTS = 0;
- public static final short APPLY_TEMPLATES = 1;
- public static final short ATTRIBUTE = 2;
- public static final short ATTRIBUTE_SET = 3;
- public static final short CHOOSE = 4;
- public static final short COMMENT = 5;
- public static final short CONSTANT = 6;
- public static final short CONTENTS = 7;
- public static final short COPY = 8;
- public static final short COUNTER = 9;
- public static final short COUNTERS = 10;
- public static final short COUNTER_INCREMENT = 11;
- public static final short COUNTER_RESET = 12;
- public static final short COUNTER_SCOPE = 13;
- public static final short ELEMENT = 14;
- // $FF: renamed from: ID short
- public static final short field_0 = 15;
- // $FF: renamed from: IF short
- public static final short field_1 = 16;
- public static final short IMPORT = 17;
- public static final short INCLUDE = 18;
- public static final short INVOKE = 19;
- public static final short FOR_EACH = 20;
- public static final short LITERAL = 21;
- public static final short MACRO = 22;
- public static final short MACRO_ARG = 23;
- public static final short NUMBER = 24;
- public static final short OTHERWISE = 25;
- // $FF: renamed from: PI short
- public static final short field_2 = 26;
- public static final short PRESERVE_SPACE = 27;
- public static final short SORT = 28;
- public static final short STRIP_SPACE = 29;
- public static final short STYLESHEET = 30;
- public static final short TEMPLATE = 31;
- public static final short TEXT = 32;
- public static final short USE = 33;
- public static final short VALUE_OF = 34;
- public static final short WHEN = 35;
- public static final short CDATA = 36;
- public static final short ARG = 37;
- public static final short ENTITY_REF = 38;
- public static final short SCRIPT = 39;
- private static final short MAX_TYPE = 40;
- private short type = 21;
- private Hashtable avtCache;
- private List children;
- private Hashtable attributes;
- private List readOnlyAttrs;
- private boolean allowActions = true;
- private XSLStylesheet parentStylesheet;
- private String typeName = "XSLObject";
- private XSLObject parent;
- static String[] typeNames = null;
-
- public XSLObject(XSLStylesheet var1, short var2) {
- this.type = var2;
- this.typeName = typeNames[var2];
- this.parentStylesheet = var1;
- this.attributes = new Hashtable();
- this.children = new List();
- this.readOnlyAttrs = new List();
- this.avtCache = new Hashtable();
- }
-
- public boolean appendAction(XSLObject var1) {
- if (!this.allowActions) {
- return false;
- } else {
- if (var1.type == 32) {
- XSLText var2 = (XSLText)var1;
- if (this.children.size() > 0) {
- XSLObject var3 = (XSLObject)this.children.get(this.children.size() - 1);
- if (var3.type == 32) {
- ((XSLText)var3).appendData(var2.getData());
- return true;
- }
- }
- }
-
- this.children.add(var1);
- var1.setParentStylesheet(this.parentStylesheet);
- var1.setParent(this);
- return true;
- }
- }
-
- public List getActions() {
- return (List)this.children.clone();
- }
-
- public String getAttribute(String var1) {
- return var1 != null ? (String)this.attributes.get(var1) : null;
- }
-
- public AttributeValueTemplate getAttributeAsAVT(String var1) throws XSLException {
- if (var1 == null) {
- return null;
- } else {
- String var2 = this.getAttribute(var1);
- AttributeValueTemplate var3 = null;
- if (var2 != null && var2.length() > 0) {
- var3 = (AttributeValueTemplate)this.avtCache.get(var2);
- if (var3 == null) {
- try {
- var3 = new AttributeValueTemplate(var2);
- this.avtCache.put(var2, var3);
- } catch (InvalidExprException var5) {
- throw new XSLException(5, ((Throwable)var5).getMessage());
- }
- }
- }
-
- return var3;
- }
- }
-
- public Enumeration getAttributeNames() {
- return this.attributes.keys();
- }
-
- public XSLObject getNearestAncestor(short var1) {
- if (this.parent == null) {
- return null;
- } else {
- XSLObject var2 = this.parent;
- return var2.type == var1 ? this.parent : this.parent.getNearestAncestor(var1);
- }
- }
-
- public static String getNodeValue(Node var0) {
- if (var0 == null) {
- return "";
- } else {
- switch (var0.getNodeType()) {
- case 1:
- return getText((Element)var0);
- case 2:
- return ((Attr)var0).getValue();
- case 3:
- case 4:
- return ((Text)var0).getData();
- case 5:
- case 6:
- default:
- return "";
- case 7:
- return ((ProcessingInstruction)var0).getData();
- case 8:
- return ((Comment)var0).getData();
- }
- }
- }
-
- public XSLStylesheet getParentStylesheet() {
- return this.parentStylesheet;
- }
-
- public final short getType() {
- return this.type;
- }
-
- public static String getText(Element var0) {
- if (var0 == null) {
- return null;
- } else {
- NodeList var1 = var0.getChildNodes();
- int var3 = var1.getLength();
- StringBuffer var4 = new StringBuffer();
-
- for(int var5 = 0; var5 < var3; ++var5) {
- Node var2 = var1.item(var5);
- switch (var2.getNodeType()) {
- case 1:
- if (var3 == 1) {
- return getText((Element)var2);
- }
-
- var4.append(getText((Element)var2));
- case 2:
- default:
- break;
- case 3:
- case 4:
- if (var3 == 1) {
- return ((Text)var2).getData();
- }
-
- var4.append(((Text)var2).getData());
- }
- }
-
- return var4.toString();
- }
- }
-
- public String getTypeName() {
- return this.typeName;
- }
-
- public void setAllowActions(boolean var1) {
- this.allowActions = var1;
- }
-
- public void setTypeName(String var1) {
- this.typeName = var1;
- }
-
- public void setAttribute(String var1, String var2) throws XSLException {
- if (var1 != null && var2 != null) {
- if (this.readOnlyAttrs.contains(var1)) {
- StringBuffer var3 = new StringBuffer("The attribute '");
- var3.append(var1);
- var3.append("' has been set to read only for this ");
- var3.append(this.getTypeName());
- var3.append(" and cannot be changed.");
- throw new XSLException(var3.toString());
- }
-
- this.attributes.put(var1, var2);
- }
-
- }
-
- protected void copyAttributes(Element var1) throws XSLException {
- NamedNodeMap var2 = var1.getAttributes();
- if (var2 != null) {
- for(int var4 = 0; var4 < var2.getLength(); ++var4) {
- Attr var3 = (Attr)var2.item(var4);
- this.setAttribute(var3.getName(), var3.getValue());
- }
-
- }
- }
-
- protected void copyAttributes(XSLObject var1) {
- var1.copyAttributesInto(this.attributes);
- }
-
- protected void copyActions(XSLObject var1) {
- List var2 = var1.getActions();
-
- for(int var3 = 0; var3 < var2.size(); ++var3) {
- XSLObject var4 = (XSLObject)var2.get(var3);
- this.appendAction(var4);
- }
-
- }
-
- protected void makeAttrReadOnly(String var1) {
- this.readOnlyAttrs.add(var1);
- }
-
- protected void setParent(XSLObject var1) {
- this.parent = var1;
- }
-
- protected void setParentStylesheet(XSLStylesheet var1) {
- this.parentStylesheet = var1;
- }
-
- protected void copyAttributesInto(Hashtable var1) {
- Enumeration var2 = this.attributes.keys();
-
- while(var2.hasMoreElements()) {
- Object var3 = var2.nextElement();
- var1.put(var3, this.attributes.get(var3));
- }
-
- }
-
- static {
- typeNames = new String[40];
- typeNames[0] = "xsl:apply-imports";
- typeNames[1] = "xsl:apply-templates";
- typeNames[37] = "xsl:arg";
- typeNames[3] = "xsl:attribute-set";
- typeNames[2] = "xsl:attribute";
- typeNames[4] = "xsl:choose";
- typeNames[5] = "xsl:comment";
- typeNames[6] = "xsl:constant";
- typeNames[7] = "xsl:contents";
- typeNames[8] = "xsl:copy";
- typeNames[9] = "xsl:counter";
- typeNames[10] = "xsl:counters";
- typeNames[11] = "xsl:counter-increment";
- typeNames[12] = "xsl:counter-reset";
- typeNames[13] = "xsl:counter-scope";
- typeNames[14] = "xsl:element";
- typeNames[15] = "xsl:id";
- typeNames[16] = "xsl:if";
- typeNames[17] = "xsl:import";
- typeNames[18] = "xsl:include";
- typeNames[19] = "xsl:invoke";
- typeNames[20] = "xsl:for-each";
- typeNames[21] = "xsl:element";
- typeNames[22] = "xsl:macro";
- typeNames[23] = "xsl:macro-arg";
- typeNames[24] = "xsl:number";
- typeNames[25] = "xsl:otherwise";
- typeNames[26] = "xsl:pi";
- typeNames[27] = "xsl:preserve-space";
- typeNames[28] = "xsl:sort";
- typeNames[29] = "xsl:strip-space";
- typeNames[30] = "xsl:stylesheet";
- typeNames[31] = "xsl:template";
- typeNames[32] = "xsl:text";
- typeNames[33] = "xsl:use";
- typeNames[34] = "xsl:value-of";
- typeNames[35] = "xsl:when";
- typeNames[36] = "xsl:cdata";
- typeNames[38] = "xsl:entity-ref";
- typeNames[39] = "xsl:script";
- }
- }
-