Package org.apache.xerces.xs

Examples of org.apache.xerces.xs.XSTerm


      private void analyzeParticle(XSParticle particle, String parentName, String namespace)
      {
         // Is this right, can a particle be null?
         if (particle == null)
            return;
         XSTerm term = particle.getTerm();

         // Is this right, can a term be null?
         if (term == null)
            return;
         switch (term.getType())
         {
            case XSConstants.MODEL_GROUP:
               XSModelGroup group = (XSModelGroup)term;
               XSObjectList list = group.getParticles();
               for (int i = 0; i < list.getLength(); i++)
View Full Code Here


      int lenobj = objlist != null ? objlist.getLength() : 0;

      for (int i = 0; i < lenobj; i++)
      {
         XSParticle jxsp = (XSParticle)objlist.item(i);
         XSTerm xterm = jxsp.getTerm();
         short termType = xterm.getType();
         if (termType == XSConstants.ELEMENT_DECLARATION)
         {
            XSElementDeclaration xsel = (XSElementDeclaration)jxsp.getTerm();
            buf.append(this.write(xsel, jxsp));
         }
         else if (termType == XSConstants.MODEL_GROUP)
         {
            XSObjectList olist = ((XSModelGroup)xterm).getParticles();
            int lobj = olist != null ? olist.getLength() : 0;
            for (int k = 0; k < lobj; k++)
            {
               XSParticle jxp = (XSParticle)olist.item(k);
               XSTerm xsterm = jxp.getTerm();
               termType = xsterm.getType();
               if (termType == XSConstants.ELEMENT_DECLARATION)
                  buf.append(write((XSElementDeclaration)xsterm, jxsp));
               else if (termType == XSConstants.MODEL_GROUP && k > 0)
                  buf.append(write((XSModelGroup)xsterm));
            }
View Full Code Here

   }

   private void appendComplexTypeDefinition(StringBuilder buf, XSComplexTypeDefinition jxstype)
   {
      XSParticle xsp = jxstype.getParticle();
      XSTerm xsterm = xsp.getTerm();
      short deriveMethod = jxstype.getDerivationMethod();

      if (xsterm instanceof XSElementDeclaration)
      {
         // FIXME This is horribly wrong, but too much depends on this broken behavior
         buf.append("<sequence>");

         XSElementDeclaration xsel = (XSElementDeclaration)xsterm;
         buf.append(this.write(xsel, xsp));
         buf.append("</sequence>");
      }
      else if (xsterm instanceof XSModelGroup)
      {
         XSModelGroup jmg = (XSModelGroup)xsterm;
         XSObjectList objlist = jmg.getParticles();
         String end = null;

         switch (jmg.getCompositor())
         {
            case XSModelGroup.COMPOSITOR_ALL:
               buf.append("<all>");
               end = "</all>";
               break;
            case XSModelGroup.COMPOSITOR_CHOICE:
               buf.append("<choice>");
               end = "</choice>";
               break;
            default:
            case XSModelGroup.COMPOSITOR_SEQUENCE:
               buf.append("<sequence>");
               end = "</sequence>";
               break;
         }

         int lenobj = objlist != null ? objlist.getLength() : 0;

         for (int i = 0; i < lenobj; i++)
         {
            XSParticle jxsp = (XSParticle)objlist.item(i);
            XSTerm xterm = jxsp.getTerm();
            if (xterm instanceof XSElementDeclaration)
            {
               XSElementDeclaration xsel = (XSElementDeclaration)jxsp.getTerm();
               buf.append(this.write(xsel, jxsp));
            }
            else if (xterm instanceof XSModelGroup)
            {
               if (deriveMethod == XSConstants.DERIVATION_EXTENSION && i != lenobj - 1)
                  continue;

               if (i == 0)
                  continue;//Ignore as it provides the baseclass sequence of elements
               XSObjectList olist = ((XSModelGroup)xterm).getParticles();
               int lobj = olist != null ? olist.getLength() : 0;
               for (int k = 0; k < lobj; k++)
               {
                  XSParticle jxp = (XSParticle)olist.item(k);
                  XSTerm jxpterm = jxp.getTerm();
                  short termType = jxpterm.getType();
                  if (termType == XSConstants.ELEMENT_DECLARATION)
                     buf.append(write((XSElementDeclaration)jxpterm, jxsp));
                  else if (termType == XSConstants.MODEL_GROUP)
                     buf.append(write((XSModelGroup)jxpterm));
               }
View Full Code Here

        addRelatedAttribute(component.getAttrDeclaration(), componentList, namespace, dependencies);
    }

    private void expandRelatedParticleComponents(XSParticle component, Vector componentList,
            String namespace, Hashtable dependencies) {
        XSTerm term = component.getTerm();
        switch (term.getType()) {
        case XSConstants.ELEMENT_DECLARATION :
            addRelatedElement((XSElementDeclaration) term, componentList, namespace, dependencies);
            break;
        case XSConstants.MODEL_GROUP :
            expandRelatedModelGroupComponents((XSModelGroup) term, componentList, namespace, dependencies);
View Full Code Here

    XSTypeDefinition type = element.getTypeDefinition();
    if (type instanceof XSComplexTypeDefinition) {
      XSParticle particle = ((XSComplexTypeDefinition) type).getParticle();
      if (particle != null) {
        XSTerm term = particle.getTerm();
        if (term instanceof XSElementDeclaration) {
          parseXSDElement(tagList, (XSElementDeclaration) term);
          tagInfo.addChildTagName(((XSElementDeclaration) term).getName());
        }
        if (term instanceof XSModelGroup) {
View Full Code Here

    XSObjectList list = (term).getParticles();
    for (int i = 0; i < list.getLength(); i++) {
      XSObject obj = list.item(i);

      if (obj instanceof XSParticle) {
        XSTerm term2 = ((XSParticle) obj).getTerm();

        if (term2 instanceof XSElementDeclaration) {
          parseXSDElement(tagList, (XSElementDeclaration) term2);
          tagInfo.addChildTagName(((XSElementDeclaration) term2).getName());
        }
View Full Code Here

      {
         XSParticle particle = XSDUtil.getParticle(type);
  
         if (particle != null)
         {
            XSTerm term = particle.getTerm();
           
            if (term.getType() == XSConstants.MODEL_GROUP)
            {
               return ((XSModelGroup)term).getParticles();
            }
         }
      }
View Full Code Here

    *    2. It has more than 1 descendant element
    *    3. The choice has a sibling (element or model group with descendant element) or an uncle ancestor element
    */
   private static boolean hasChoiceDescendantWithSiblingOrUncleElement(XSParticle particle, boolean bHasUncle)
   {
      XSTerm term = particle.getTerm();

      if (term.getType() == XSConstants.MODEL_GROUP)
      {
         XSModelGroup modelGroup = (XSModelGroup)term;
         XSObjectList particleList = modelGroup.getParticles();
        
         if (particleList.getLength() > 1)
         {
            //inspect children
            boolean bHasElement = hasElement(particle);
            List modelGroupList = getModelGroups(particle);

            //search for children that are model groups of type choice
            for (int i = 0; i < modelGroupList.size(); i++)
            {
               XSParticle childParticle = (XSParticle)modelGroupList.get(i);
               XSTerm childTerm = childParticle.getTerm();

               assert childTerm.getType() == XSConstants.MODEL_GROUP;

               if (bHasElement || modelGroupList.size() > 1 || bHasUncle)
               {
                  XSModelGroup childModelGroup = (XSModelGroup)childTerm;

View Full Code Here

    * @return the particles of particle that are model groups with at least one descendant element
    */
   private static List getModelGroups(XSParticle particle)
   {
      List retVal = new ArrayList();
      XSTerm term = particle.getTerm();

      if (term.getType() == XSConstants.MODEL_GROUP)
      {
         XSModelGroup modelGroup = (XSModelGroup)term;
         XSObjectList particleList = modelGroup.getParticles();

         //inspect particles and remember the ones with element descendants
View Full Code Here

   private static boolean hasElement(XSParticle particle)
   {
      if (particle.getTerm().getType() == XSConstants.MODEL_GROUP)
      {
         XSTerm term = particle.getTerm();
         XSObjectList childParticleList = ((XSModelGroup)term).getParticles();

         for (int i = 0; i < childParticleList.getLength(); i++)
         {
            XSParticle childParticle = (XSParticle)childParticleList.item(i);
            XSTerm childTerm = childParticle.getTerm();

            if (childTerm.getType() == XSConstants.ELEMENT_DECLARATION)
            {
               return true;
            }
         }
      }
View Full Code Here

TOP

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

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.