Examples of XSElement


Examples of org.apache.ws.jaxme.xs.XSElement

      assertEquals(new XsQName(uri, "id"), idAttr.getName());
      assertEquals(XSID.getInstance(), idAttr.getType());
      assertTrue(idAttr.isOptional());
      XSElement[] elements = schema.getElements();
      assertEquals(1, elements.length);
      XSElement rifElem = elements[0];
      assertFalse(rifElem.getType().isSimple());
      XSComplexType ct = rifElem.getType().getComplexType();
      XSAttributable[] rifAttrs = ct.getAttributes();
      assertEquals(1, rifAttrs.length);
      XSAttribute idRef = (XSAttribute) rifAttrs[0];
      assertTrue(idRef instanceof JAXBAttribute);
      assertFalse(idRef.equals(idAttr));
View Full Code Here

Examples of org.apache.ws.jaxme.xs.XSElement

   
    // Build the Map of substitution groups.
    Map substitutionGroups = new HashMap();
    for (int i = 0;  i < myChilds.length;  i++) {
      if (myChilds[i] instanceof XSElement) {
        XSElement element = (XSElement) myChilds[i];
        XsQName qName = element.getSubstitutionGroupName();
        if (qName != null) {
          SubstitutionGroup group = (SubstitutionGroup) substitutionGroups.get(qName);
          if (group == null) {
            XSElement head = pSchema.getElement(qName);
            if (head == null) {
              throw new LocSAXException("The substituted element " + qName + " is missing in the schema.",
                  element.getLocator());
            }
            if (head.isBlockedForSubstitution()) {
              throw new LocSAXException("The substituted element " + qName + " is blocked for substitution.",
                  element.getLocator());
            }
            group = new SubstitutionGroup(head);
            if (!head.isAbstract()) {
              group.addMember(head);
            }
            substitutionGroups.put(qName, group);
          }
          group.addMember(element);
        }
      }
    }
   
    // For any substitution group: Build an implicit choice group, which
    // may be used to replace the substitution groups head, if required.
    for (Iterator iter = substitutionGroups.values().iterator();  iter.hasNext()) {
      SubstitutionGroup group = (SubstitutionGroup) iter.next();
      XSElementImpl head = (XSElementImpl) group.getHead();
      XsObject object = head.getXsObject();
      XsESchema syntaxSchema = object.getXsESchema();
     
      // Find a name for the group
      String namespace = syntaxSchema.getTargetNamespace().toString();
      String localName = head.getName().getLocalName() + "Group";
      XsQName suggestion = new XsQName(namespace, localName);
      if (pSchema.getGroup(suggestion) != null) {
        for (int i = 0;  ;  i++) {
          suggestion = new XsQName(namespace, localName + i);
          if (pSchema.getGroup(suggestion) == null) {
            break;
          }
        }
      }
     
      XsTNamedGroup namedGroup = object.getObjectFactory().newXsTNamedGroup(syntaxSchema);
      namedGroup.setName(new XsNCName(suggestion.getLocalName()));
      XsTSimpleExplicitGroup choice = namedGroup.createChoice();
      XSElement[] members = group.getMembers();
      for (int j = 0;  j < members.length;  j++) {
        XSElement member = members[j];
        XsTLocalElement memberElement = choice.createElement();
        memberElement.setRef(member.getName());
      }
     
      XSGroupImpl xsGroup = (XSGroupImpl) getSchema().getXSObjectFactory().newXSGroup(pSchema, namedGroup);
      pSchema.add(xsGroup);
      head.setSubstitutionGroup(xsGroup);
View Full Code Here

Examples of org.apache.ws.jaxme.xs.XSElement

      } else if (pParticle instanceof XsTLocalElement) {
        localElement = (XsTLocalElement) pParticle;
        // May be the referenced element is the head of a substitution group
        XsQName ref = localElement.getRef();
        if (ref != null) {
          XSElement referencedElement = getXSSchema().getElement(ref);
          if (referencedElement == null) {
            throw new LocSAXException("The referenced element " + ref + " is undefined.", localElement.getLocator());
          }
          XSGroup substitutedGroup = referencedElement.getSubstitutionGroup();
          if (substitutedGroup != null  &&  substitutedGroup != this) {
            XsObject parent = localElement.getParentObject();
            XsTGroupRefImpl groupRefImpl = (XsTGroupRefImpl) localElement.getObjectFactory().newXsTGroupRef(parent);
            groupRefImpl.setRef(substitutedGroup.getName());
            int maxOccurs = localElement.getMaxOccurs();
            if (maxOccurs == -1) {
              groupRefImpl.setMaxOccurs("unbounded");
            } else {
              groupRefImpl.setMaxOccurs(Integer.toString(maxOccurs));
            }
            groupRefImpl.setMinOccurs(localElement.getMinOccurs());
            groupRef = groupRefImpl;
          }
        }
      } else {
        throw new IllegalStateException("Unknown particle type: " + pParticle.getClass().getName());
      }
      if (groupRef == null) {
        occurs = localElement;
        XSElement element = getXSSchema().getXSObjectFactory().newXSElement(this, localElement);
        element.validate();
        p = new XSParticleImpl(element);
      } else {
        occurs = groupRef;
        XSGroup group = getXSSchema().getXSObjectFactory().newXSGroup(this, groupRef);
        group.validate();
View Full Code Here

Examples of org.apache.ws.jaxme.xs.XSElement

  public ObjectSG getElement(SchemaSG pController, XsQName pName) throws SAXException {
    ObjectSG objectSG = (ObjectSG) elementsByName.get(pName);
    if (objectSG != null) {
      return objectSG;
    }
    XSElement element = getXSSchema().getElement(pName);
    if (element == null) {
      return null;
    }
    objectSG = pController.getFactory().getObjectSG(element);
    elementsByName.put(pName, objectSG);
View Full Code Here

Examples of org.apache.ws.jaxme.xs.XSElement

  }

  protected XSElement assertElement(XSParticle pParticle) {
    assertTrue(pParticle.isElement());
    assertEquals(XSParticle.ELEMENT, pParticle.getType());
    XSElement result = pParticle.getElement();
    assertNotNull(result);
    return result;
  }
View Full Code Here

Examples of org.apache.ws.jaxme.xs.XSElement

      annotations = new XSAnnotation[]{result};
    }

    XSType myType;
    if (isReference()) {
      XSElement element = getXSSchema().getElement(getName());
      if (element == null) {
        throw new LocSAXException("Invalid element reference: " + getName() + " is not defined.",
                                     getLocator());
      }
      element.validate();
      myType = element.getType();
    } else {
      XsTElement element = getXsTElement();
      if (isInnerSimpleType()) {
        myType = getXSSchema().getXSObjectFactory().newXSType(this, element.getSimpleType());
      } else if (isInnerComplexType()) {
        myType = getXSSchema().getXSObjectFactory().newXSType(this, element.getComplexType());
      } else {
        XsQName typeName = element.getType();
        if (typeName == null) {
          throw new LocSAXException("Invalid element: Either of its 'type' or 'ref' attributes or its 'simpleType' or 'complexType' children must be set.",
                                       getLocator());
        }
        myType = getXSSchema().getType(typeName);
View Full Code Here

Examples of org.apache.ws.jaxme.xs.XSElement

                        Context pClassContext) throws SAXException {
    super(pFactory, pSchema, pObject);
    final String mName = "<init>(XSObject,Context)";
    boolean isClassGlobal;
    if (pObject instanceof XSElement) {
      XSElement element = (XSElement) pObject;
      log.finest(mName, "->", new Object[]{element.getName(), pClassContext});
      type = element.getType();
      name = element.getName();
      isClassGlobal = !type.isSimple()  &&  (type.isGlobal()  ||  element.isGlobal());
    } else {
      throw new IllegalStateException("Unknown object type: " + pObject.getClass().getName());
    }

    Context myClassContext;
View Full Code Here

Examples of org.apache.ws.jaxme.xs.XSElement

    assertEquals(1, typeAttributes.length);
    assertEquals(pQualified ? barQualified : barUnQualified, ((XSAttribute) typeAttributes[0]).getName());
    XSGroup group = assertGroup(assertComplexContent(complexType));
    XSParticle[] particles = group.getParticles();
    assertEquals(1, particles.length);
    XSElement typeElement = assertElement(particles[0]);
    assertEquals(pQualified ? fooQualified : fooUnQualified, typeElement.getName());
  }
View Full Code Here

Examples of org.apache.ws.jaxme.xs.XSElement

    assertEquals("java.math.BigDecimal", ajjt.getName());
    assertEquals("javax.xml.bind.DatatypeConverter.parseInteger", ajjt.getParseMethod());
    assertEquals("javax.xml.bind.DatatypeConverter.printInteger", ajjt.getPrintMethod());
    assertTrue(!ajjt.hasNsContext());

    XSElement b = schema.getElement(new XsQName((String) null, "b"));
    XSType bt = b.getType();
    JAXBSimpleType bst = (JAXBSimpleType) assertSimpleType(bt);
    assertEquals(a, assertRestriction(bst));
    assertNull(bst.getJAXBJavaType());

    XSElement c = schema.getElement(new XsQName((String) null, "c"));
    XSType ct = c.getType();
    JAXBSimpleType cst = (JAXBSimpleType) assertSimpleType(ct);
    assertEquals(a, assertRestriction(cst));
    JAXBJavaType cjjt = cst.getJAXBJavaType();
    assertEquals("java.math.BigInteger", cjjt.getName());
    assertEquals("javax.xml.bind.DatatypeConverter.parseInt", cjjt.getParseMethod());
View Full Code Here

Examples of org.apache.ws.jaxme.xs.XSElement

    XSType b = schema.getType(new XsQName((String) null, "b"));
    checkJAXBTypesafeEnumClass1BType(b);

    XSElement[] elements = schema.getElements();
    assertEquals(1, elements.length);
    XSElement allTypesElement = elements[0];
    XSGroup allTypesGroup = assertGroup(assertComplexContent(assertComplexType(allTypesElement.getType())));
    assertSequence(allTypesGroup);
    XSParticle[] allTypesChilds = allTypesGroup.getParticles();
    assertEquals(2, allTypesChilds.length);
    checkJAXBTypesafeEnumClass1AType(assertElement(allTypesChilds[0]).getType());
    checkJAXBTypesafeEnumClass1BType(assertElement(allTypesChilds[1]).getType());   
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.