1 22 23 package org.xquark.xpath.schema; 24 25 import org.xquark.schema.AttributeDeclaration; 26 import org.xquark.schema.Declaration; 27 import org.xquark.schema.ElementDeclaration; 28 import org.xquark.xpath.NodeKind; 29 import org.xquark.xpath.TypedXTreeNode; 30 import org.xquark.xpath.XTree; 31 32 35 public class SchemaNode extends TypedXTreeNode 36 { 37 private static final String RCSRevision = "$Revision: 1.1 $"; 38 private static final String RCSName = "$Name: $"; 39 40 Declaration declaration; 41 42 52 public SchemaNode( 53 XTree tree, 54 SchemaNode parent, 55 String namespace, 56 String localName, 57 byte type) 58 { 59 super(tree, parent, namespace, localName, type); 60 if ((type != NodeKind.NONE) 61 && (parent != null) 62 && (parent.getDeclaration() != null)) 63 { 64 org.xquark.schema.Type parentType = 65 parent.getDeclaration().getType(); 66 switch (type) 67 { 68 case NodeKind.ATTRIBUTE : 69 declaration = 70 parentType.getAttributeDeclaration( 71 namespace, 72 localName); 73 break; 74 case NodeKind.ELEMENT : 75 declaration = 76 parentType.getElementDeclaration(namespace, localName); 77 break; 78 } 79 } 80 } 81 82 90 public SchemaNode(XTree tree, SchemaNode parent, Declaration decl) 91 { 92 super(tree, parent, decl.getNamespace(), decl.getName(), NodeKind.NODE); 93 if (decl instanceof AttributeDeclaration) 94 XModelNode.set(NodeKind.ATTRIBUTE); 95 else if (decl instanceof ElementDeclaration) 96 XModelNode.set(NodeKind.ELEMENT); 97 declaration = decl; 98 } 99 100 104 public Declaration getDeclaration() 105 { 106 return declaration; 107 } 108 109 113 public String toString() 114 { 115 return super.toString() + "[Decl = " + declaration + "]"; 116 } 117 } 118 | Popular Tags |