1 57 58 package org.apache.wsif.schema; 59 60 import java.io.Serializable ; 61 import java.util.ArrayList ; 62 63 import javax.xml.namespace.QName ; 64 65 import org.w3c.dom.Element ; 66 import org.w3c.dom.Node ; 67 import org.w3c.dom.NodeList ; 68 69 74 public class Restriction implements Serializable { 75 76 static final long serialVersionUID = 1L; 77 78 QName base = null; 79 ArrayList attributes = new ArrayList (); 80 ArrayList sequenceElements = new ArrayList (); 81 82 86 Restriction(Element el, String tns) { 87 base = SchemaType.getAttributeQName(el, "base"); 88 NodeList children = el.getChildNodes(); 89 for (int i = 0; i < children.getLength(); i++) { 90 Node child = children.item(i); 91 if (child.getNodeType() == Node.ELEMENT_NODE) { 92 Element subEl = (Element ) child; 93 String elType = subEl.getLocalName(); 94 if (elType.equals("attribute")) { 95 attributes.add(new Attribute(subEl, tns)); 96 } else if (elType.equals("sequence")) { 97 parseSequenceElements(subEl, tns); 98 } 99 } 100 } 101 } 102 103 107 public QName getBase() { 108 return base; 109 } 110 111 115 public Attribute[] getAttributes() { 116 return (Attribute[]) attributes.toArray( 117 new Attribute[attributes.size()]); 118 } 119 120 124 public SequenceElement[] getSequenceElements() { 125 return (SequenceElement[]) sequenceElements.toArray( 126 new SequenceElement[sequenceElements.size()]); 127 } 128 129 private void parseSequenceElements(Element el, String tns) { 130 NodeList children = el.getChildNodes(); 131 for (int i = 0; i < children.getLength(); i++) { 132 Node child = children.item(i); 133 if (child.getNodeType() == Node.ELEMENT_NODE) { 134 Element subEl = (Element ) child; 135 String elType = subEl.getLocalName(); 136 if (elType.equals("element")) { 137 sequenceElements.add(new SequenceElement(subEl, tns)); 138 } 139 } 140 } 141 } 142 } 143 | Popular Tags |