Package org.apache.xerces.xs

Examples of org.apache.xerces.xs.XSTypeDefinition


      return groupParticle;
   }

   private JBossXSParticle getXSParticle(String name, Class fieldType, String targetNS)
   {
      XSTypeDefinition xstype = null;
      boolean isArray = fieldType.isArray();

      if (isArray)
         fieldType = fieldType.getComponentType();
View Full Code Here


   public void createJavaFile(XSComplexTypeDefinition type, XSModel schema, boolean isExceptionType) throws IOException
   {
      if (typeMapping == null)
         throw new WSException("TypeMapping has not been set");
      XSTypeDefinition baseType = type.getBaseType();
      // Ensure the characters in the name are valid
      fname = ToolsUtils.convertInvalidCharacters(fname);
      //Ensure that the first character is uppercase
      fname = utils.firstLetterUpperCase(fname);
      List vars = new ArrayList();

      String baseName = getBaseTypeName(type);
      if (baseName != null && baseType != null && !generatedFiles.contains(baseName))
      {
         if (baseType instanceof XSComplexTypeDefinition)
         {
            generatedFiles.add(baseName);
            String pushName = fname;
            fname = baseName;
            this.createJavaFile((XSComplexTypeDefinition)baseType, schema, isExceptionType);
            fname = pushName;
         }
      }

      vars = this.getVARList(type, schema, isExceptionType);

      if (baseName == null && isExceptionType)
      {
         baseName = "Exception";
      }
      else if (baseName != null)
      {
         baseName = getPackageName(baseType.getNamespace()) + "." + baseName;
      }
      String packageName = getPackageName(type.getNamespace());
      jwriter.createJavaFile(getLocationForJavaGeneration(packageName), fname, packageName, vars, null, baseName, isExceptionType, serializableTypes,
            typeNameToBaseVARList);
   }
View Full Code Here

   public void createJavaFile(XSSimpleTypeDefinition xsSimple, XSModel schema) throws IOException
   {
      if (typeMapping == null)
         throw new WSException("TypeMapping has not been set");
      XSTypeDefinition baseType = xsSimple.getBaseType();

      short variety = xsSimple.getVariety();
      if (XSSimpleTypeDefinition.VARIETY_ATOMIC == variety)
      {
         //If the simple type has an enumerated list, then just use its type
View Full Code Here

   public List<VAR> getVARList(XSComplexTypeDefinition type, XSModel schema, boolean isExceptionType) throws IOException
   {
      if (typeMapping == null)
         throw new WSException("TypeMapping has not been set");
      XSTypeDefinition baseType = type.getBaseType();
      List vars = new ArrayList();

      vars = handleAttributes(type, vars);
      //TODO:Handle xsd:group
View Full Code Here

            XSModelGroup xsm = (XSModelGroup)xsterm;
            XSObjectList xparts = xsm.getParticles();

            int length = xparts.getLength();

            XSTypeDefinition baseType = type.getBaseType();

            if (baseType instanceof XSComplexTypeDefinition && ((XSComplexTypeDefinition)baseType).getContentType() != XSComplexTypeDefinition.CONTENTTYPE_EMPTY)
            {
               XSTerm baseTerm = ((XSComplexTypeDefinition)baseType).getParticle().getTerm();
               if (isExceptionType && baseTerm instanceof XSModelGroup)
View Full Code Here

      //    TODO: If yes, create class that is ComplexTypeName+ElementName
      //    TODO: ItemsItem  If the elem contains anon simpletype
      //    TODO: No need to create seperate Java class

      String tname = elem.getName();
      XSTypeDefinition xstypedef = elem.getTypeDefinition();

      String xstypename = xstypedef.getName();
      // Check if it is a composite type
      if (xstypename != null && xstypedef.getName().equals(origType.getName()) && xstypedef.getNamespace().equals(origType.getNamespace()))
      {
         // it is a composite type
         QName qn = new QName(origType.getNamespace(), origType.getName());
         VAR vr = createVAR(qn, elem, (XSComplexTypeDefinition)xstypedef, tname, getPackageName(origType.getNamespace()), arrayType);
         vars.add(vr);
         return vars;
      }
      else

      if (xstypename == null && xstypedef instanceof XSComplexTypeDefinition)
      {
         XSComplexTypeDefinition xsc = (XSComplexTypeDefinition)xstypedef;
         String subname = utils.firstLetterUpperCase(tname);
         // Save the fname in a temp var
         String tempfname = this.fname;
         // it will be an anonymous type
         if (containingElement == null || containingElement.length() == 0)
            containingElement = origType.getName();

         String anonName;
         if (elem.getScope() == XSConstants.SCOPE_GLOBAL)
         {
            anonName = subname;
         }
         else
         {
            anonName = containingElement + subname;
         }

         anonName = utils.firstLetterUpperCase(anonName);
         this.fname = anonName;

         if (!generatedFiles.contains(this.fname))
         {
            generatedFiles.add(this.fname);
            this.createJavaFile((XSComplexTypeDefinition)xstypedef, schema, false);
         }

         // Restore the fname
         this.fname = tempfname;
         // Bypass rest of processing
         QName anonqn = new QName(anonName);
         VAR vr = createVAR(anonqn, elem, xsc, tname, getPackageName(xsc.getNamespace()), arrayType);
         vars.add(vr);
         return vars;
      }
      else
      {
         String temp = this.fname;
         // Unwrap any array wrappers
         if (SchemaUtils.isWrapperArrayType(xstypedef))
         {
            XSComplexTypeDefinition complex = (XSComplexTypeDefinition)xstypedef;
            XSModelGroup group = (XSModelGroup)complex.getParticle().getTerm();
            XSElementDeclaration element = (XSElementDeclaration)((XSParticle)group.getParticles().item(0)).getTerm();
            xstypedef = element.getTypeDefinition();
            xstypename = xstypedef.getName();
            arrayType = true;
         }

         QName qn = null;
         if (xstypedef instanceof XSSimpleTypeDefinition)
         {
            qn = SchemaUtils.handleSimpleType((XSSimpleTypeDefinition)xstypedef);
         }
         else
         {
            qn = new QName(xstypedef.getNamespace(), xstypename);
         }

         if (xstypename != null && xstypedef instanceof XSComplexTypeDefinition)
         {
            this.fname = ToolsUtils.convertInvalidCharacters(utils.firstLetterUpperCase(xstypename));
            if (!generatedFiles.contains(this.fname))
            {
               generatedFiles.add(this.fname);
               this.createJavaFile((XSComplexTypeDefinition)xstypedef, schema, false);
            }
            this.fname = temp;
         }

         VAR v = createVAR(qn, elem, xstypedef, tname, getPackageName(xstypedef.getNamespace()), arrayType);
         vars.add(v);
      }
      return vars;
   }
View Full Code Here

   }

   private String getBaseTypeName(XSComplexTypeDefinition type)
   {
      String baseName = null;
      XSTypeDefinition baseType = null;
      if (type instanceof XSComplexTypeDefinition)
      {
         XSComplexTypeDefinition t = (XSComplexTypeDefinition)type;

         baseType = t.getBaseType();
         //Check baseType is xsd:anyType
         if (baseType != null)
         {
            if (baseType.getNamespace() == Constants.NS_SCHEMA_XSD && baseType.getName().equals("anyType"))
               baseType = null; //Ignore this baseType
         }
         if (XSComplexTypeDefinition.CONTENTTYPE_SIMPLE == t.getContentType())
         {
            baseType = null; //ComplexType has a simplecontent
         }
      }

      if (baseName == null && baseType != null)
         baseName = ToolsUtils.firstLetterUpperCase(baseType.getName());

      return baseName;
   }
View Full Code Here

      len = xsnamedmap != null ? xsnamedmap.getLength() : 0;
      for (int i = 0; i < len; i++)
      {
         XSElementDeclaration elm = (XSElementDeclaration)xsnamedmap.item(i);
         String elmname = elm.getName();
         XSTypeDefinition elmtype = elm.getTypeDefinition();
         if (elmtype != null && elmtype instanceof XSComplexTypeDefinition)
         {
            XSComplexTypeDefinition ctype = (XSComplexTypeDefinition)elmtype;
            String nsuri = elmtype.getNamespace();
            String tname = elmtype.getName();
            if (tname != null) continue;   //Consider only anon complex types
           
            createJavaFile(ctype, dirloc, packageName, xsmodel, elmname);
         }
      }
View Full Code Here

            XSModel xsModel = loader.loadURI(uri);

            // Convert top level complex type definitions to node types
            XSNamedMap map = xsModel.getComponents(XSConstants.TYPE_DEFINITION);
            for (int i = 0; i < map.getLength(); i++) {
                XSTypeDefinition tDef = (XSTypeDefinition) map.item(i);
                checkAndConvert(tDef, null, null);
            }
            //  Convert local (anonymous) complex type defs found in top level element declarations
            map = xsModel.getComponents(XSConstants.ELEMENT_DECLARATION);
            for (int i = 0; i < map.getLength(); i++) {
                XSElementDeclaration eDec = (XSElementDeclaration) map.item(i);

                XSTypeDefinition tDef = eDec.getTypeDefinition();
                checkAndConvert(tDef, eDec.getNamespace(), eDec.getName());
            }
        } catch (ClassNotFoundException e) {
            throw new SchemaConversionException("XSLoader not found", e);
        } catch (InstantiationException e) {
View Full Code Here

            // Name for property or node def taken from the name of the element
            QName name = new QName(noNull(eDec.getNamespace()), eDec.getName());

            // Get the type definition for this element declaration
            XSTypeDefinition tDef = eDec.getTypeDefinition();

            // If this element declaration is of simple type
            // then it is converted into a property def
            if (tDef.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) {
                XSSimpleTypeDefinition stDef = (XSSimpleTypeDefinition) tDef;
                PropDef propDef = simpleTypeToPropDef(stDef, name, mandatory, multiple);
                propDefList.add(propDef);

                // If this element declaration is of complex type then
                // it is converted into either node or property def
            } else if (tDef.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
                XSComplexTypeDefinition ctDef = (XSComplexTypeDefinition) tDef;

                // If the complex type definition contains a simple content model
                // and does not contain any attribute uses or attribute wildcards
                // then the enclosing element is converted to a property def
View Full Code Here

TOP

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

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.