Package org.exolab.castor.xml.schema

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


       // declarations in XML DTD, so we convert each General Entity declaration
       // to Documentation subelement of XML Schema document annotaion.
       Enumeration dtdGeneralEntities = dtd.getGeneralEntities();
       if (dtdGeneralEntities.hasMoreElements()) {
          GeneralEntity ge;
          Annotation annotation = new Annotation();
          Documentation documentation;
          String text;

          while (dtdGeneralEntities.hasMoreElements()) {
             ge = (GeneralEntity)dtdGeneralEntities.nextElement();
             documentation = new Documentation();

             text = "General Entity Declaration";
             documentation.add(text);
             documentation.add(ge);
             annotation.addDocumentation(documentation);
          }

          schema.addAnnotation(annotation);
       }
       //-- convert General Entity declarations
View Full Code Here


     */
    public void testUnmarshallSchema() throws FileNotFoundException, SAXException, IOException {
        Schema schema = unmarshalSchema("schema-entity.xsd");
        ComplexType bookType = schema.getComplexType("bookType");
        Enumeration annotations = bookType.getAnnotations();
        Annotation annotation = (Annotation) annotations.nextElement();
        Enumeration appInfos = annotation.getAppInfo();
        AppInfo appInfo = (AppInfo) appInfos.nextElement();
        List jdoContent = appInfo.getJdoContent();

        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();

        assertEquals(1, jdoContent.size());
        c = (Column) jdoContent.get(0);
View Full Code Here

     */
    public void testUnmarshallNonJdoSchema() throws SAXException, IOException {
        Schema schema = unmarshalSchema("schema-entity-non-jdo.xsd");
        ComplexType bookType = schema.getComplexType("bookType");
        Enumeration annotations = bookType.getAnnotations();
        Annotation annotation = (Annotation) annotations.nextElement();
        Enumeration appInfos = annotation.getAppInfo();
        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();

        assertEquals(0, jdoContent.size());
    }
View Full Code Here

     */
    public void testUnmarshallMixedSchema() throws SAXException, IOException {
        Schema schema = unmarshalSchema("schema-entity-mixed.xsd");
        ComplexType bookType = schema.getComplexType("bookType");
        Enumeration annotations = bookType.getAnnotations();
        Annotation annotation = (Annotation) annotations.nextElement();
        Enumeration appInfos = annotation.getAppInfo();
        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();

        assertEquals(0, jdoContent.size());
    }
View Full Code Here

     */
    public void testUnmarshallOneToManySchema() throws SAXException, IOException {
        Schema schema = unmarshalSchema("schema-one-to-many.xsd");
        ComplexType bookType = schema.getComplexType("bookType");
        Enumeration annotations = bookType.getAnnotations();
        Annotation annotation = (Annotation) annotations.nextElement();
        Enumeration appInfos = annotation.getAppInfo();
        AppInfo appInfo = (AppInfo) appInfos.nextElement();
        List jdoContent = appInfo.getJdoContent();

        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();

        assertEquals(1, jdoContent.size());
        OneToMany oneToMany = (OneToMany) jdoContent.get(0);
View Full Code Here

     */
    public void testUnmarshallOneToOneSchema() throws SAXException, IOException {
        Schema schema = unmarshalSchema("schema-one-to-one.xsd");
        ComplexType bookType = schema.getComplexType("bookType");
        Enumeration annotations = bookType.getAnnotations();
        Annotation annotation = (Annotation) annotations.nextElement();
        Enumeration appInfos = annotation.getAppInfo();
        AppInfo appInfo = (AppInfo) appInfos.nextElement();
        List jdoContent = appInfo.getJdoContent();

        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();

        assertEquals(1, jdoContent.size());
        OneToOne oneToOne = (OneToOne) jdoContent.get(0);
View Full Code Here

            Group group = ((GroupUnmarshaller)unmarshaller).getGroup();
            _complexType.addGroup(group);
        }
        //-- annotation
        else if (SchemaNames.ANNOTATION.equals(name)) {
            Annotation ann = ((AnnotationUnmarshaller)unmarshaller).getAnnotation();
            _complexType.addAnnotation(ann);
        }

        unmarshaller = null;
    } //-- endElement
View Full Code Here

            } catch (SchemaException e) {
                throw new IllegalArgumentException(e.getMessage());
            }
        }
        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);
View Full Code Here

        //-- have unmarshaller perform any necessary clean up
        unmarshaller.finish();

        if (SchemaNames.ANNOTATION.equals(name)) {
            Annotation annotation = (Annotation)unmarshaller.getObject();
            _simpleTypeDef.setAnnotation(annotation);
        }
        else if (SchemaNames.LIST.equals(name)) {
            _simpleType = (SimpleType)unmarshaller.getObject();
            _simpleTypeDef.copyInto(_simpleType);
View Full Code Here

        //-- have unmarshaller perform any necessary clean up
        unmarshaller.finish();

        //-- annotation
        if (SchemaNames.ANNOTATION.equals(name)) {
            Annotation ann = ((AnnotationUnmarshaller)unmarshaller).getAnnotation();
            _typeDefinition.setAnnotation(ann);
        }
        else if (SchemaNames.SIMPLE_TYPE.equals(name)) {
            SimpleType type = (SimpleType) unmarshaller.getObject();
            _typeDefinition.setBaseType(type);
View Full Code Here

TOP

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

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.