Package org.exolab.castor.xml.schema

Examples of org.exolab.castor.xml.schema.ElementDecl


       //-- convert General Entity declarations

       // convert Element declarations
       Enumeration dtdElements = dtd.getElements();
       Element dtdElement; // DTD Element declaration
       ElementDecl schemaElement; // Schema Element declaration

       while (dtdElements.hasMoreElements()) {
          dtdElement = (Element)dtdElements.nextElement();
          schemaElement = convertDTDElementToSchemaElement(dtdElement, schema);
          schema.addElementDecl(schemaElement);
View Full Code Here


       String name = dtdElement.getName();
       if (name == null || name.equals("")) {
          String err = "DTD to Schema converter: a DTD element has no name.";
          throw new DTDException(err);
       }
       ElementDecl schemaElement = new ElementDecl(schema, name);

       // start converting content of the element
       ComplexType complexType = schema.createComplexType();
       ContentType contentType = null;
       Group group = null; // auxiliary
       Iterator mixedChildrenIterator = null; // auxiliary
       String elementRef = null; // auxiliary
       ElementDecl elem = null// auxiliary

       if (dtdElement.isEmptyContent()) {

          // mixed="false"
          contentType = ContentType.elemOnly;
          //-- mixed="false"

       } else if (dtdElement.isAnyContent()) {

          // mixed="true"
          contentType = ContentType.mixed;
          //-- mixed="true"

          group = new Group();
          group.setOrder(Order.sequence);
          group.setMinOccurs(0);
          group.setMaxOccurs(-1);
          Wildcard any = new Wildcard(group);
          group.addWildcard(any);
          complexType.addGroup(group);

       } else if (dtdElement.isElemOnlyContent()) {

          // mixed="false"
          contentType = ContentType.elemOnly;
          //-- mixed="false"

          ContentParticle dtdContent = dtdElement.getContent();
          if (dtdContent == null) { // content is not specified
             String err = "DTD to Schema converter: element \"" + dtdElement.getName();
             err += "\" has no content.";
             throw new DTDException(err);
          }

          Particle content = null;
          try {
             content = convertContentParticle(dtdContent, schema);
          }
          catch (DTDException e) {
             String err = "DTD to Schema converter: content of DTD element \"" + dtdElement.getName();
             err += "\", represented by a Content Particle, is malformed.";
             throw new DTDException(err);
          }

          if (content instanceof ElementDecl) {
             group = new Group();
             group.setOrder(Order.sequence);
             group.addElementDecl((ElementDecl)content);
             complexType.addGroup(group);
          } else {
             complexType.addGroup((Group)content);
          }

       } else if (dtdElement.isMixedContent()) {

          // mixed="true"
          contentType = ContentType.mixed;
          //-- mixed="true"

          mixedChildrenIterator = dtdElement.getMixedContentChildren();
          if ((mixedChildrenIterator != null) && (mixedChildrenIterator.hasNext())) {
             group = new Group();
             group.setOrder(Order.choice);
             group.setMinOccurs(0);
             group.setMaxOccurs(-1);
             while (mixedChildrenIterator.hasNext()) {
                elementRef = (String)mixedChildrenIterator.next();
                elem = new ElementDecl(schema);
                elem.setReferenceName(elementRef);
                group.addElementDecl(elem);
             }
             complexType.addGroup(group);
          }
View Full Code Here

       Particle returnValue;

       if (dtdContent.isReferenceType()) {

          ElementDecl elem = new ElementDecl(schema);
          elem.setReferenceName(dtdContent.getReference());
          returnValue = elem;

       } else if (dtdContent.isSeqType() || dtdContent.isChoiceType()) {

          Group group = new Group();
View Full Code Here

        assertEquals(1, jdoContent.size());
        Table t = (Table) jdoContent.get(0);
        assertEquals("book", t.getName());
        assertEquals("isbn", t.getPrimaryKey().getKey(0));

        ElementDecl isbn = bookType.getElementDecl("isbn");
        annotations = isbn.getAnnotations();
        annotation = (Annotation) annotations.nextElement();
        appInfos = annotation.getAppInfo();
        appInfo = (AppInfo) appInfos.nextElement();
        jdoContent = appInfo.getJdoContent();

        assertEquals(1, jdoContent.size());
        Column c = (Column) jdoContent.get(0);
        assertEquals("isbn", c.getName());
        assertEquals("jdo:string", c.getType());

        ElementDecl title = bookType.getElementDecl("title");
        annotations = title.getAnnotations();
        annotation = (Annotation) annotations.nextElement();
        appInfos = annotation.getAppInfo();
        appInfo = (AppInfo) appInfos.nextElement();
        jdoContent = appInfo.getJdoContent();
View Full Code Here

        AppInfo appInfo = (AppInfo) appInfos.nextElement();
        List jdoContent = appInfo.getJdoContent();

        assertEquals(0, jdoContent.size());

        ElementDecl isbn = bookType.getElementDecl("isbn");
        annotations = isbn.getAnnotations();
        annotation = (Annotation) annotations.nextElement();
        appInfos = annotation.getAppInfo();
        appInfo = (AppInfo) appInfos.nextElement();
        jdoContent = appInfo.getJdoContent();

        assertEquals(0, jdoContent.size());

        ElementDecl title = bookType.getElementDecl("title");
        annotations = title.getAnnotations();
        annotation = (Annotation) annotations.nextElement();
        appInfos = annotation.getAppInfo();
        appInfo = (AppInfo) appInfos.nextElement();
        jdoContent = appInfo.getJdoContent();
View Full Code Here

        AppInfo appInfo = (AppInfo) appInfos.nextElement();
        List jdoContent = appInfo.getJdoContent();

        assertEquals(0, jdoContent.size());

        ElementDecl isbn = bookType.getElementDecl("isbn");
        annotations = isbn.getAnnotations();
        annotation = (Annotation) annotations.nextElement();
        appInfos = annotation.getAppInfo();
        appInfo = (AppInfo) appInfos.nextElement();
        jdoContent = appInfo.getJdoContent();

        assertEquals(0, jdoContent.size());

        ElementDecl title = bookType.getElementDecl("title");
        annotations = title.getAnnotations();
        annotation = (Annotation) annotations.nextElement();
        appInfos = annotation.getAppInfo();
        appInfo = (AppInfo) appInfos.nextElement();
        jdoContent = appInfo.getJdoContent();
View Full Code Here

        assertEquals(1, jdoContent.size());
        Table t = (Table) jdoContent.get(0);
        assertEquals("book", t.getName());
        assertEquals("isbn", t.getPrimaryKey().getKey(0));

        ElementDecl isbn = bookType.getElementDecl("isbn");
        annotations = isbn.getAnnotations();
        annotation = (Annotation) annotations.nextElement();
        appInfos = annotation.getAppInfo();
        appInfo = (AppInfo) appInfos.nextElement();
        jdoContent = appInfo.getJdoContent();

        assertEquals(1, jdoContent.size());
        Column c = (Column) jdoContent.get(0);
        assertEquals("isbn", c.getName());
        assertEquals("varchar", c.getType());

        ElementDecl title = bookType.getElementDecl("title");
        annotations = title.getAnnotations();
        annotation = (Annotation) annotations.nextElement();
        appInfos = annotation.getAppInfo();
        appInfo = (AppInfo) appInfos.nextElement();
        jdoContent = appInfo.getJdoContent();

        assertEquals(1, jdoContent.size());
        c = (Column) jdoContent.get(0);
        assertEquals("title", c.getName());
        assertEquals("varchar", c.getType());
       
        ElementDecl author = bookType.getElementDecl("author");
        annotations = author.getAnnotations();
        annotation = (Annotation) annotations.nextElement();
        appInfos = annotation.getAppInfo();
        appInfo = (AppInfo) appInfos.nextElement();
        jdoContent = appInfo.getJdoContent();
View Full Code Here

        assertEquals(1, jdoContent.size());
        Table t = (Table) jdoContent.get(0);
        assertEquals("book", t.getName());
        assertEquals("isbn", t.getPrimaryKey().getKey(0));

        ElementDecl isbn = bookType.getElementDecl("isbn");
        annotations = isbn.getAnnotations();
        annotation = (Annotation) annotations.nextElement();
        appInfos = annotation.getAppInfo();
        appInfo = (AppInfo) appInfos.nextElement();
        jdoContent = appInfo.getJdoContent();

        assertEquals(1, jdoContent.size());
        Column c = (Column) jdoContent.get(0);
        assertEquals("isbn", c.getName());
        assertEquals("varchar", c.getType());

        ElementDecl title = bookType.getElementDecl("title");
        annotations = title.getAnnotations();
        annotation = (Annotation) annotations.nextElement();
        appInfos = annotation.getAppInfo();
        appInfo = (AppInfo) appInfos.nextElement();
        jdoContent = appInfo.getJdoContent();

        assertEquals(1, jdoContent.size());
        c = (Column) jdoContent.get(0);
        assertEquals("title", c.getName());
        assertEquals("varchar", c.getType());
       
        ElementDecl author = bookType.getElementDecl("author");
        annotations = author.getAnnotations();
        annotation = (Annotation) annotations.nextElement();
        appInfos = annotation.getAppInfo();
        appInfo = (AppInfo) appInfos.nextElement();
        jdoContent = appInfo.getJdoContent();
View Full Code Here

        if (SchemaNames.ANNOTATION.equals(name)) {
            Annotation ann = (Annotation)unmarshaller.getObject();
            _group.addAnnotation(ann);
        }
        else if (SchemaNames.ELEMENT.equals(name)) {
            ElementDecl element = (ElementDecl) unmarshaller.getObject();
            _group.addElementDecl(element);
        }
        else if (name.equals(SchemaNames.GROUP)) {
            ModelGroup group = (ModelGroup) unmarshaller.getObject();
            _group.addGroup(group);
View Full Code Here

            _complexType.addAttributeGroupReference(attrGroupRef);
        }
        //-- element declarations
        else if (SchemaNames.ELEMENT.equals(name)) {

            ElementDecl element =
                ((ElementUnmarshaller)unmarshaller).getElement();
            _complexType.addElementDecl(element);
        }
        //--group
        else if (name.equals(SchemaNames.GROUP)) {
View Full Code Here

TOP

Related Classes of org.exolab.castor.xml.schema.ElementDecl

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.