Package org.apache.ws.jaxme.xs

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


      XSSchema schema = parser.parse(isource);

      XSElement[] elements = schema.getElements();
      assertEquals( 1, elements.length );

      XSElement libraryElement = elements[0];
      XSIdentityConstraint[] ics = libraryElement.getIdentityConstraints();

      assertEquals( 1, ics.length );

      XSIdentityConstraint ic = ics[0];
      assertEquals( "book-key", ic.getName() );

      XSElementOrAttrRef[][] icMatchCriteria = ic.getMatchCriteria();

      assertEquals( 2, icMatchCriteria.length );
      assertEquals( 1, icMatchCriteria[0].length );
      assertEquals( 1, icMatchCriteria[1].length );

      assertEquals(
        "id",
        icMatchCriteria[0][0].getAttribute().getName().getLocalName()
      );
      assertEquals(
        "book",
        icMatchCriteria[1][0].getElement().getName().getLocalName()
      );

      XSKeyRef[] rfs = libraryElement.getKeyRefs();
      assertEquals( 1, rfs.length );

      XSKeyRef rf = rfs[0];
      assertEquals( "book-key-ref", rf.getName() );
View Full Code Here


        XSGroup group = assertGroup(particle);
        XSParticle[] particles = group.getParticles();
        assertEquals(2, particles.length);
        assertEquals(1, particles[0].getMinOccurs());
        assertEquals(1, particles[0].getMaxOccurs());
        XSElement refElement = assertElement(particles[0]);
        assertTrue(refElement.isGlobal());
        assertEquals(refElement.getName(), elements[0].getName());
        assertEquals(0, particles[1].getMinOccurs());
        assertEquals(-1, particles[1].getMaxOccurs());
        refElement = assertElement(particles[1]);
        assertTrue(refElement.isGlobal());
        assertEquals(refElement.getName(), elements[0].getName());
    }
View Full Code Here

    // Print the names of all global elements:
    XSElement[] elements = schema.getElements();
    assertEquals(154, elements.length);

    XSElement localTransformationElement = schema.getElement(new XsQName((String) null, "local_transformation"));
    assertNotNull(localTransformationElement);
    XSType localTransformationType = localTransformationElement.getType();
    assertTrue(!localTransformationType.isSimple());
    XSComplexType localTransformationComplexType = localTransformationType.getComplexType();
    assertTrue(!localTransformationComplexType.hasSimpleContent());
    XSParticle localTransformationParticle = localTransformationComplexType.getParticle();
    XSGroup localTransformationGroup = localTransformationParticle.getGroup();
View Full Code Here

      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

    // 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

                     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();
      global = element.isGlobal();
      isClassGlobal = !type.isSimple()  &&  (type.isGlobal()  ||  global);
    } else {
      throw new IllegalStateException("Unknown object type: " + pObject.getClass().getName());
    }
View Full Code Here

    XSSchema schema = getXSSchema();
    XSObjectFactory factory = schema.getXSObjectFactory();

    XSType myType;
    if (isReference()) {
      XSElement element = schema.getElement(getName());
      if (element == null) {
        throw new LocSAXException("Invalid element reference: " + getName() + " is not defined.",
                                     getLocator());
      }
      element.validate();
      isNillable = element.isNillable();   
      myType = element.getType();
     
    } else {
      XsTElement element = getXsTElement();
      if (isInnerSimpleType()) {
        myType = factory.newXSType(this, element.getSimpleType());
      } else if (isInnerComplexType()) {
        myType = factory.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 = schema.getType(typeName);
View Full Code Here

  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

        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];
        XSComplexType ct = assertComplexType(rifElem.getType());
        XSAttributable[] rifAttrs = ct.getAttributes();
        assertEquals(1, rifAttrs.length);
        XSAttribute idRef = (XSAttribute) rifAttrs[0];
        assertFalse(idRef.equals(idAttr));
        assertEquals(new XsQName(uri, "id"), idAttr.getName());
View Full Code Here

  }

  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

TOP

Related Classes of org.apache.ws.jaxme.xs.XSElement

Copyright © 2018 www.massapicom. 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.