Exemplo n.º 1
0
  /**
   * Signals the start of an element with the given name.
   *
   * @param name the NCName of the element. It is an error if the name is a QName (ie. contains a
   *     prefix).
   * @param namespace the namespace of the element. This may be null. Note: A null namespace is not
   *     the same as the default namespace unless the default namespace is also null.
   * @param atts the AttributeSet containing the attributes associated with the element.
   * @param nsDecls the namespace declarations being declared for this element. This may be null.
   */
  public void startElement(String name, String namespace, AttributeSet atts, Namespaces nsDecls)
      throws XMLException {
    // -- Do delagation if necessary
    if (unmarshaller != null) {
      unmarshaller.startElement(name, namespace, atts, nsDecls);
      ++depth;
      return;
    }

    if (SchemaNames.ANNOTATION.equals(name)) {

      if (foundAnnotation)
        error("Only one (1) annotation is allowed as a child of " + "an attribute declaration.");

      if (foundSimpleType)
        error("An annotation may only appear as the first child of " + "an attribute declaration.");

      foundAnnotation = true;
      unmarshaller = new AnnotationUnmarshaller(atts);
    } else if (SchemaNames.SIMPLE_TYPE.equals(name)) {
      if (foundSimpleType)
        error("Only one (1) simpleType is allowed as a child of " + "an attribute declaration.");

      foundSimpleType = true;
      unmarshaller = new SimpleTypeUnmarshaller(_schema, atts);
    } else {
      illegalElement(name);
    }
  } // -- startElement
Exemplo n.º 2
0
  /**
   * Signals to end of the element with the given name.
   *
   * @param name the NCName of the element. It is an error if the name is a QName (ie. contains a
   *     prefix).
   * @param namespace the namespace of the element.
   */
  public void endElement(String name, String namespace) throws XMLException {

    // -- Do delagation if necessary
    if ((unmarshaller != null) && (depth > 0)) {
      unmarshaller.endElement(name, namespace);
      --depth;
      return;
    }

    // -- call unmarshaller finish to perform any necessary cleanup
    unmarshaller.finish();

    if (SchemaNames.ANNOTATION.equals(name)) {
      Annotation ann = (Annotation) unmarshaller.getObject();
      _attribute.addAnnotation(ann);
    } else if (SchemaNames.SIMPLE_TYPE.equals(name)) {
      SimpleType simpleType = ((SimpleTypeUnmarshaller) unmarshaller).getSimpleType();
      _attribute.setSimpleType(simpleType);
    }

    unmarshaller = null;
  } // -- endElement