Package org.apache.xerces.xs

Examples of org.apache.xerces.xs.XSModelGroup


   {
      JavaXmlTypeMapping jxtm = null;

      if (xt instanceof XSComplexTypeDefinition)
      {
         XSModelGroup xm = null;
         XSComplexTypeDefinition xc = (XSComplexTypeDefinition)xt;
         XSTypeDefinition baseType = xc.getBaseType();
         short der = xc.getDerivationMethod();
         String typeQName = "";
View Full Code Here


            // If this particle is a model group (one of
            // <xs:sequence>, <xs:choice> or <xs:all>) then
            // it subparticles must be processed.
        } else if (term.getType() == XSConstants.MODEL_GROUP) {
            XSModelGroup mg = (XSModelGroup) term;

            /* Si cela est une séquence */
            // If the top level compositor is <xs:sequence> we convert this to
            // mean that the node type corresponding to the complex type def will have
            // an orderable setting of true.
            if (mg.getCompositor() == XSModelGroup.COMPOSITOR_SEQUENCE) {
                orderable = true;
            }

            // We ignore any further nested compositors
            // by ignoring the return value of nested particleToDefs calls.
            XSObjectList list = mg.getParticles();
            for (int i = 0; i < list.getLength(); i++) {
                XSParticle pp = (XSParticle) list.item(i);
                particleToDefs(pp, propDefList, nodeDefList);
            }
        }
View Full Code Here

      JavaXmlTypeMapping jxtm = null;

      if (xt instanceof XSComplexTypeDefinition)
      {

         XSModelGroup xm = null;
         XSComplexTypeDefinition xc = (XSComplexTypeDefinition)xt;
         if (xc.getContentType() != XSComplexTypeDefinition.CONTENTTYPE_EMPTY)
         {
            XSParticle xp = xc.getParticle();
            if (xp != null)
View Full Code Here

      XSNamedMap groups = model.getComponents(XSConstants.MODEL_GROUP_DEFINITION);
      for(int i = 0; i < groups.getLength(); ++i)
      {
         XSModelGroupDefinition groupDef = (XSModelGroupDefinition)groups.item(i);
         XSModelGroup group = groupDef.getModelGroup();
         XSObjectList particles = group.getParticles();
         for(int j = 0; j < particles.getLength(); ++j)
         {
            XSParticle particle = (XSParticle)particles.item(j);
            XSTerm term = particle.getTerm();
            switch(term.getType())
View Full Code Here

            // If this particle is a model group (one of
            // <xs:sequence>, <xs:choice> or <xs:all>) then
            // it subparticles must be processed.
        } else if (term.getType() == XSConstants.MODEL_GROUP) {
            XSModelGroup mg = (XSModelGroup) term;

            // If the top level compositor is <xs:sequence> we convert this to
            // mean that the node type corresponding to the complex type def will have
            // an orderable setting of true.
            if (mg.getCompositor() == XSModelGroup.COMPOSITOR_SEQUENCE) {
                orderable = true;
            }

            // We ignore any further nested compositors
            // by ignoring the return value of nested particleToDefs calls.
            XSObjectList list = mg.getParticles();
            for (int i = 0; i < list.getLength(); i++) {
                XSParticle pp = (XSParticle) list.item(i);
                particleToDefs(pp, propDefList, nodeDefList);
            }
        }
View Full Code Here

         "</xsd:schema>";

      XSModel model = Util.loadSchema(xsd, (String)null);

      XSComplexTypeDefinition type = (XSComplexTypeDefinition)model.getTypeDefinition("valueType", "");
      XSModelGroup modelGroup = (XSModelGroup)type.getParticle().getTerm();
      assertNull(modelGroup.getAnnotation());

      type = (XSComplexTypeDefinition)model.getTypeDefinition("annotatedValueType", "");
      modelGroup = (XSModelGroup)type.getParticle().getTerm();
      assertNull(modelGroup.getAnnotation());
   }
View Full Code Here

   {
      JavaXmlTypeMapping jxtm = null;

      if (xt instanceof XSComplexTypeDefinition)
      {
         XSModelGroup xm = null;
         XSComplexTypeDefinition xc = (XSComplexTypeDefinition)xt;
         XSTypeDefinition baseType = xc.getBaseType();
         short der = xc.getDerivationMethod();

         if ((baseType != null) && !utils.isBaseTypeIgnorable(baseType, xc))
View Full Code Here

    protected void printComplexValidationDataStructMembers(PrintStream stream, XSComplexTypeDefinition complexType,
            Set<String> printedMembers) {
        if (complexType.getParticle() != null) {
            XSTerm term = complexType.getParticle().getTerm();
            if (term instanceof XSModelGroup) {
                XSModelGroup modelGroup = (XSModelGroup) term;
                printComplexValidationDataStructMembers(stream, modelGroup, printedMembers);
            }
        }
        if (complexType.getBaseType() instanceof XSComplexTypeDefinition) {
            XSComplexTypeDefinition baseType = (XSComplexTypeDefinition) complexType.getBaseType();
View Full Code Here

     *            XSParticle to build state machine for.
     * @return State machine or null.
     */
    protected StateMachineRootNode build(XSParticle particle) {
        if (particle.getTerm() instanceof XSModelGroup) {
            XSModelGroup modelGroup = (XSModelGroup) particle.getTerm();
            boolean foundNestedModelGroup = false;
            for (int i = 0; i < modelGroup.getParticles().getLength(); i++) {
                XSParticle subParticle = (XSParticle) modelGroup.getParticles().item(i);
                if (subParticle.getTerm() instanceof XSModelGroup) {
                    foundNestedModelGroup = true;
                    break;
                }
            }
View Full Code Here

     */
    public static String fillInComplexValidationTemplate(String tmpl, String cppElementName,
            String cppValidationDataStructType, XSComplexTypeDefinition complexType, XSElementDeclaration element,
            StateMachineRootNode sm, IGenerationDataProvider dataProvider) {

        XSModelGroup modelGroup = null;
        boolean complexTypeMaxOccursUnbounded = false;
        int complexTypeMinOccurs = -1;
        int complexTypeMaxOccurs = -1;
        if (complexType != null) {
          XSParticle complexTypeParticle = complexType.getParticle();
            if (complexTypeParticle != null) {
              complexTypeMaxOccursUnbounded = complexTypeParticle.getMaxOccursUnbounded();
              complexTypeMinOccurs = complexTypeParticle.getMinOccurs();
              complexTypeMaxOccurs = complexTypeParticle.getMaxOccurs();
                if (complexTypeParticle.getTerm() instanceof XSModelGroup) {
                 
                    modelGroup = (XSModelGroup) complexType.getParticle().getTerm();
                }
            }
        }
        XSParticle particle = null;
        if (modelGroup != null && modelGroup.getParticles() != null) {
            for (int i = 0; i < modelGroup.getParticles().getLength(); i++) {
                XSObject particleObject = modelGroup.getParticles().item(i);
                if (particleObject instanceof XSParticle) {
                    XSParticle currentParticle = (XSParticle) particleObject;
                    if (currentParticle.getTerm() instanceof XSElementDeclaration) {
                        XSElementDeclaration particleElement = (XSElementDeclaration) currentParticle.getTerm();
                        if (particleElement.getName().equals(element.getName())) {
                            particle = currentParticle;
                            break;
                        }
                    }
                }
            }
        }
       
        Config config = dataProvider.getConfig();
        int iterationCounter = 0;
        while (tmpl.contains(Constants.TEMPLATE_DELIMITER_COMPLEX_VALIDATION)) {
            iterationCounter++;
            if (iterationCounter > config.getMaxTemplateResolvingIterations()) {
                System.err.println("********************************************");
                System.err.println("Could not resolve template:");
                System.err.println(fillInTemplate(tmpl, cppElementName, null, null, null, null, null, dataProvider));
                System.err.println("********************************************");
                break;
            }

            if (tmpl.contains(Constants.TMPL_COMPLEX_VALI_STRUCT_TYPE)) {
                tmpl = tmpl.replace(Constants.TMPL_COMPLEX_VALI_STRUCT_TYPE, cppValidationDataStructType);
            }
            if (tmpl.contains(Constants.TMPL_COMPLEX_VALI_STRUCT_NAME)) {
                tmpl = tmpl.replace(Constants.TMPL_COMPLEX_VALI_STRUCT_NAME, config
                        .getComplexValidationDataStructVariableName());
            }
            if (tmpl.contains(Constants.TMPL_COMPLEX_VALI_PARENT_STRUCT_NAME)) {
                tmpl = tmpl.replace(Constants.TMPL_COMPLEX_VALI_PARENT_STRUCT_NAME, config
                        .getComplexValidationDataParentStructVariableName());
            }
            if (tmpl.contains(Constants.TMPL_COMPLEX_VALI_STRUCT_MEMBER)) {
                tmpl = tmpl.replace(Constants.TMPL_COMPLEX_VALI_STRUCT_MEMBER, Util
                        .createComplexValidationDataStructMemberName(element, config));
            }
            if (tmpl.contains(Constants.TMPL_COMPLEX_VALI_CHECK_MAX_OCCURENCE)) {
                String maxOccCheck = config.getTemplateComplexValidationCheckMaxOccurence();
                if (particle == null || (particle != null && particle.getMaxOccursUnbounded()) || complexTypeMaxOccursUnbounded ) {
                    maxOccCheck = "";
                }
                tmpl = tmpl.replace(Constants.TMPL_COMPLEX_VALI_CHECK_MAX_OCCURENCE, maxOccCheck);
            }
            if (tmpl.contains(Constants.TMPL_COMPLEX_VALI_GET_VALIDATION_DATA)) {
                tmpl = tmpl.replace(Constants.TMPL_COMPLEX_VALI_GET_VALIDATION_DATA, config
                        .getTemplateComplexValidationGetTopValidationData());
            }
            if (tmpl.contains(Constants.TMPL_COMPLEX_VALI_DELETE_VALIDATION_DATA)) {
                tmpl = tmpl.replace(Constants.TMPL_COMPLEX_VALI_DELETE_VALIDATION_DATA, config
                        .getTemplateComplexValidationDeleteValidationData());
            }
            if (tmpl.contains(Constants.TMPL_COMPLEX_VALI_GET_PARENT_VALIDATION_DATA)) {
                tmpl = tmpl.replace(Constants.TMPL_COMPLEX_VALI_GET_PARENT_VALIDATION_DATA, config
                        .getTemplateComplexValidationGetTopParentValidationData());
            }
            if (tmpl.contains(Constants.TMPL_COMPLEX_VALI_INCREMENT_OCCURENCE)) {
                tmpl = tmpl.replace(Constants.TMPL_COMPLEX_VALI_INCREMENT_OCCURENCE, config
                        .getTemplateComplexValidationIncrementOccurence());
            }
            if (tmpl.contains(Constants.TMPL_COMPLEX_VALI_MAX_OCCURENCE)) {
                int maxOccurence = 0;
                if (particle != null) {
                    maxOccurence = particle.getMaxOccurs();
                }
                tmpl = tmpl.replace(Constants.TMPL_COMPLEX_VALI_MAX_OCCURENCE, String.valueOf(maxOccurence));
            }
            if (tmpl.contains(Constants.TMPL_COMPLEX_VALI_CHECK_MIN_OCCURENCE_OF_CHILDREN)) {
                String childrenCheck = "";
                if (modelGroup != null && modelGroup.getParticles() != null) {
                    switch (modelGroup.getCompositor()) {
                    case XSModelGroup.COMPOSITOR_ALL:
                    case XSModelGroup.COMPOSITOR_SEQUENCE:
                        for (int i = 0; i < modelGroup.getParticles().getLength(); i++) {
                            XSObject item = modelGroup.getParticles().item(i);
                            if (item instanceof XSParticle) {
                                XSParticle child = (XSParticle) item;
                                if (child.getMinOccurs() == 0) {
                                    continue;
                                }
                                String particleTmpl = config.getTemplateComplexValidationCheckMinOccurencOfChildren();
                                childrenCheck += fillInComplexValidationParticleTemplate(particleTmpl, child, config);
                            }
                        }
                        break;
                    case XSModelGroup.COMPOSITOR_CHOICE:
                        boolean allChildrenHaveMinOccurs = true;
                        for (int i = 0; i < modelGroup.getParticles().getLength(); i++) {
                            XSObject item = modelGroup.getParticles().item(i);
                            if (item instanceof XSParticle) {
                                XSParticle child = (XSParticle) item;
                                if (child.getMinOccurs() == 0) {
                                    allChildrenHaveMinOccurs = false;
                                    continue;
                                }
                                String particleTmpl = config
                                        .getTemplateComplexValidationChoiceCheckMinOccurencOfChildren();
                                childrenCheck += fillInComplexValidationParticleTemplate(particleTmpl, child, config);
                            }
                        }
                        if (allChildrenHaveMinOccurs) {
                            childrenCheck += config.getTemplateComplexValidationChoiceCheckOneChildPresent();
                            if (childrenCheck.contains(Constants.TMPL_COMPLEX_VALI_CHOICE_ONE_CHILD_PER_CHILD)) {
                                for (int i = 0; i < modelGroup.getParticles().getLength(); i++) {
                                    XSObject item = modelGroup.getParticles().item(i);
                                    if (item instanceof XSParticle) {
                                        XSParticle child = (XSParticle) item;
                                        String perChild = config
                                                .getTemplateComplexValidationChoiceCheckOneChildPresentPerChild();
                                        if (i != modelGroup.getParticles().getLength() - 1) {
                                            perChild += " && " + Constants.TMPL_CONTINUE_LOOP;
                                        }
                                        childrenCheck = childrenCheck.replace(
                                                Constants.TMPL_COMPLEX_VALI_CHOICE_ONE_CHILD_PER_CHILD, perChild);
                                        childrenCheck = fillInComplexValidationParticleTemplate(childrenCheck, child,
                                                config);

                                        if (childrenCheck.contains(Constants.TMPL_CONTINUE_LOOP)) {
                                            childrenCheck = childrenCheck.replace(Constants.TMPL_CONTINUE_LOOP,
                                                    Constants.TMPL_COMPLEX_VALI_CHOICE_ONE_CHILD_PER_CHILD);
                                        }
                                    }
                                }
                            }
                        }
                        break;
                    }
                }
                tmpl = tmpl.replace(Constants.TMPL_COMPLEX_VALI_CHECK_MIN_OCCURENCE_OF_CHILDREN, childrenCheck);
            }
            if (tmpl.contains(Constants.TMPL_COMPLEX_VALI_CHECK_SIBLINGS)) {
                String siblingsCheck = "";
                if (modelGroup != null && modelGroup.getParticles() != null) {
                    switch (modelGroup.getCompositor()) {
                    case XSModelGroup.COMPOSITOR_SEQUENCE:
                        List<XSParticle> previousSiblings = new ArrayList<XSParticle>();
                        List<XSParticle> followingSiblings = new ArrayList<XSParticle>();
                        Util.splitParticlesForSequence(modelGroup, particle, previousSiblings, followingSiblings);
                        for (int i = previousSiblings.size() - 1; i >= 0; i--) {
View Full Code Here

TOP

Related Classes of org.apache.xerces.xs.XSModelGroup

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.