Examples of ElementDecl


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

        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

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

        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

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

            _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

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

        }

        //-- process all top level element declarations
        enumeration = schema.getElementDecls();
        while (enumeration.hasMoreElements()) {
          ElementDecl temp = (ElementDecl) enumeration.nextElement();
          boolean found = false;
          //--check if this attributeGroup is not
          //-- included
          Enumeration includedSchemas = schema.getCachedIncludedSchemas();
          while (includedSchemas.hasMoreElements()) {
            Schema tempSchema = (Schema)includedSchemas.nextElement();
            found = (tempSchema.getElementDecl(temp.getName())!= null);
          }
         
          if (!found)
              processElement(temp,schemaPrefix);
        }

        //-- process all top level complex types
        enumeration = schema.getComplexTypes();
        while (enumeration.hasMoreElements()) {
            ComplexType temp = (ComplexType) enumeration.nextElement();
            boolean found = false;
            //--check if this attributeGroup is not
            //-- included
            Enumeration includedSchemas = schema.getCachedIncludedSchemas();
            while (includedSchemas.hasMoreElements()) {
              Schema tempSchema = (Schema)includedSchemas.nextElement();
              found = (tempSchema.getComplexType(temp.getName())!= null);
            }
            if (!temp.isRedefined() && !found)
                processComplexType(temp, schemaPrefix);
        }

        //-- process all top level groups
        enumeration = schema.getModelGroups();
        while (enumeration.hasMoreElements()) {
          ModelGroup temp = (ModelGroup)enumeration.nextElement();
          boolean found = false;
          //--check if this Group is not
          //-- included
          Enumeration includedSchemas = schema.getCachedIncludedSchemas();
          while (includedSchemas.hasMoreElements()) {
            Schema tempSchema = (Schema)includedSchemas.nextElement();
            found = (tempSchema.getModelGroup(temp.getName())!= null);
          }
         
          if (!temp.isRedefined() && !found)
              processGroup(temp, schemaPrefix);
        }

        //-- process all top level simple types
        enumeration = schema.getSimpleTypes();
        while (enumeration.hasMoreElements()) {
            SimpleType temp = (SimpleType) enumeration.nextElement();
            boolean found = false;
            //--check if this attributeGroup is not
            //-- included
            Enumeration includedSchemas = schema.getCachedIncludedSchemas();
            while (includedSchemas.hasMoreElements()) {
              Schema tempSchema = (Schema)includedSchemas.nextElement();
              found = (tempSchema.getSimpleType(temp.getName())!= null);
            }
            if (!temp.isRedefined() && !found)
                processSimpleType(temp, schemaPrefix);
        }

        _handler.endElement(ELEM_SCHEMA);
View Full Code Here

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

            return createComment(enumeration.nextElement());
        }
        //-- there were no annotations...try possible references
        switch(annotated.getStructureType()) {
            case Structure.ELEMENT:
                ElementDecl elem = (ElementDecl) annotated;
                if (elem.isReference()) {
                    return createComment(elem.getReference());
                }
                break;
            case Structure.ATTRIBUTE:
                AttributeDecl att = (AttributeDecl) annotated;
                if (att.isReference()) {
View Full Code Here

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

                    //-- if we're in element-centric mode, then all
                    //--  complexTypes are treated as abstract
                    result = result || _config.mappingSchemaElement2Java();
                    break;
                case Structure.ELEMENT:
                    ElementDecl eDecl = (ElementDecl) _annotated;
                    result = eDecl.isAbstract();
                    break;
                default:
                    break;
            }
        }
View Full Code Here

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

        // get local name
        String localName = getLocalName(xPath);
        String typedLocalName = localName;
       
        if (annotated instanceof ElementDecl) {
            ElementDecl element = (ElementDecl) annotated;
            String typexPath = XPathHelper.getSchemaLocation(element.getType());
            xPath += "[" + typexPath  + "]";
            typedLocalName += "[" + typexPath  + "]";
        } else if (annotated instanceof Group) {
            Group group = (Group) annotated;
            if (group.getOrder() == Order.choice
                    && !_globalElements.contains("/" + localXPath)) {
                xPath += "/#choice";
            }
        }
       
        ExtendedBinding binding = component.getBinding();
        if (binding != null) {
            // deal with explicit exclusions
            if (binding.existsExclusion(typedLocalName)) {
                Exclude exclusion = binding.getExclusion(typedLocalName);
                if (exclusion.getClassName() != null) {
                    LOG.info("Dealing with exclusion for local element " + xPath
                            + " as per binding file.");
                    jClass.changeLocalName(exclusion.getClassName());
                }
                return;
            }

            // deal with explicit forces
            if (binding.existsForce(localName)) {

                List<String> localNamesList = _localNames.get(localName);
                memorizeCollision(xPath, localName, localNamesList);

                LOG.info("Changing class name for local element " + xPath
                        + " as per binding file (force).");
                checkAndChange(jClass, annotated, untypedXPath, typedLocalName);
                return;
            }
        }
               
       
        String jClassLocalName = jClass.getLocalName();
        String expectedClassNameDerivedFromXPath = _javaNaming.toJavaClassName(localName);
        if (!jClassLocalName.equals(expectedClassNameDerivedFromXPath)) {
            if (component.createGroupItem()) {
                xPath += "/#item";
            }
            _xpathToJClass.put(xPath, jClass);
            return;
        }

        if (mode.equals("field")) {
            if (annotated instanceof ModelGroup) {
                ModelGroup group = (ModelGroup) annotated;
                final boolean isReference = group.isReference();
                if (isReference) {
                    return;
                }
            }
               
            if (annotated instanceof ElementDecl) {
                ElementDecl element = (ElementDecl) annotated;

                final boolean isReference = element.isReference();
                if (isReference) {
                    ElementDecl referredElement = element.getReference();
                    // if that global element definition is a substitution head,
                    // we now
                    // need to do work out the global element's type, and use
                    // its
                    // JClass instance to defer the type of the member currently
                    // processed
                    Enumeration<?> possibleSubstitutes = referredElement
                            .getSubstitutionGroupMembers();
                    if (possibleSubstitutes.hasMoreElements()) {
                        XMLType referredType = referredElement.getType();
                        String xPathType = XPathHelper.getSchemaLocation(referredType);
                        JClass typeJClass = _xpathToJClass.get(xPathType);
                        if (typeJClass != null) {
                            jClass.changeLocalName(typeJClass.getLocalName());
                        } else {
                            // manually deriving class name for referenced type
                            XMLBindingComponent temp = component;
                            temp.setView(referredType);
                            jClass.changeLocalName(temp.getJavaClassName());
                            component.setView(annotated);
                        }
//                        String typeXPath = XPathHelper
//                                .getSchemaLocation(referredElement);
//                        JClass referredJClass = (JClass) _xpathToJClass
//                                .get(typeXPath + "_class");
//                        jClass.changeLocalName(referredJClass.getSuperClass()
//                                .getLocalName());
                    }
                    return;
                }
            }
        }

        final boolean alreadyProcessed = _xpathToJClass.containsKey(xPath);

        // if already processed, change the JClass instance accordingly
        if (alreadyProcessed) {
            JClass jClassAlreadyProcessed = _xpathToJClass.get(xPath);
            jClass.changeLocalName(jClassAlreadyProcessed.getLocalName());
            return;
        }

        // register JClass instance for XPATH
        _xpathToJClass.put(xPath, jClass);

        if (LOG.isDebugEnabled()) {
            LOG.debug("Binding JClass[" + jClass.getName() + "] for XML schema structure " + xPath);
        }

        // global elements don't need to change
        final boolean isGlobalElement = _globalElements.contains(untypedXPath);
        if (isGlobalElement) {
            return;
        }

        // resolve references to global elements
        if (mode.equals("field") && annotated instanceof ElementDecl) {
            ElementDecl element = (ElementDecl) annotated;
            final boolean isReference = element.isReference();
            if (isReference) {
                ElementDecl referredElement = element.getReference();
                // if that global element definition is a substitution head, we
                // now
                // need to do work out the global element's type, and use its
                // JClass instance to defer the type of the member currently
                // processed
                Enumeration<?> possibleSubstitutes = referredElement
                        .getSubstitutionGroupMembers();
                if (possibleSubstitutes.hasMoreElements()) {
                    String typeXPath = XPathHelper
                            .getSchemaLocation(referredElement);
                    JClass referredJClass = _xpathToJClass
View Full Code Here

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

                case Structure.ELEMENT :
                    //--handle reference: if the element referred a
                    //--global element then we use the global binding
                    if (result == null) {
                        ElementDecl element = (ElementDecl) annotated;
                        if (element.isReference()) {
                            xPath = XPathHelper.getSchemaLocation(element.getReference());
                            result = lookupComponentBindingType(xPath);
                        }
                        //--discard the element
                        element = null;
                    }
View Full Code Here

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

    public void changeClassInfoAsResultOfConflict(final JClass jClass,
            final String xpath, final String typedXPath, final Annotated annotated) {
        String typeString = typedXPath.substring(typedXPath.indexOf("[") + 1,
                typedXPath.indexOf("]"));
        if (annotated instanceof ElementDecl) {
            ElementDecl element = (ElementDecl) annotated;
            // keep the suggested names for global elements
            if (element.getParent() == element.getSchema()) {
                return;
            }
            // keep the suggested name for element references
            if (element.isReference()) {
                return;
            }
            // keep the suggested class name if the local element is of the same
            // type as the global one
            XMLType xmlType = element.getType();
            ElementDecl globalElement = element.getSchema().getElementDecl(element.getName());
            if (globalElement != null) {
                XMLType globalElementType = globalElement.getType();
                if (globalElementType.getName() != null
                        && globalElementType.getName().equals(xmlType.getName())) {
                    return;
                }
            }
View Full Code Here

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

        subgroup.setMinOccurs(0);
        subgroup.setMaxOccurs(Particle.UNBOUNDED);
        group.addGroup(subgroup);

        // create an element for choice
        ElementDecl elem = new ElementDecl(_schema);
        elem.setName("myStringType");
        elem.setTypeReference("string");
        subgroup.addElementDecl(elem);

        elem = new ElementDecl(_schema);
        elem.setName("myStringType2");
        elem.setTypeReference("string");
        group.addElementDecl(elem);

        // compare
        TestResult result = doTest("group_subgroupwithanelement.xsd");
        assertEquals("single attribute test failed", TestResult.IDENTICAL,
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.