Package org.apache.xerces.xs

Examples of org.apache.xerces.xs.XSObjectList


            else
            {
               XSComplexTypeDefinition xsComplexType = (XSComplexTypeDefinition) xsType;
               if (xsComplexType.getContentType() == XSComplexTypeDefinition.CONTENTTYPE_SIMPLE)
               {
                  XSObjectList attributeUses = xsComplexType.getAttributeUses();
                  if(attributeUses.getLength() == 0)
                  {
                     ignoreIfNotFound = true;
                  }  
                  else if (attributeUses.getLength() == 1)
                  {
                     XSAttributeUse xsAttrUse = (XSAttributeUse) attributeUses.item(0);
                     XSAttributeDeclaration xsAttr = xsAttrUse.getAttrDeclaration();
                     if(xsAttr.getNamespace() == null && "id".equals(xsAttr.getName()))
                        ignoreIfNotFound = true;
                  }
               }
View Full Code Here


      if(trace)
         log.trace("assertEquivalent complex types: " + xsQName);
        
      assertEquals("Complex type is " + (xsType == null ? "anonymous" : "named '" + xsQName + "'"), xsQName, typeBinding.getQName());

      XSObjectList xsAttrUses = xsType.getAttributeUses();
      if(xsAttrUses.getLength() == 0)
      {
         // TODO missing id attributes in the schema
         //assertTrue("Type " + typeBinding.getQName() + " has no attributes in the schema", typeBinding.getAttributes().isEmpty());
      }
      else
      {
         for(int i = 0; i < xsAttrUses.getLength(); ++i)
         {
            XSAttributeDeclaration xsAttr = ((XSAttributeUse)xsAttrUses.item(i)).getAttrDeclaration();
            QName xsAttrQName = new QName(xsAttr.getNamespace(), xsAttr.getName());
            AttributeBinding attrBinding = typeBinding.getAttribute(xsAttrQName);
            assertNotNull("Type " + typeBinding.getQName() + " declares attribute " + xsAttrQName, attrBinding);
            assertEquivalent(xsAttr.getTypeDefinition(), attrBinding.getType());
         }
View Full Code Here

      }
      else
         fail("Unexpected compositor type for model group " + xsCompositor);
     
     
      XSObjectList xsParticles = xsModelGroup.getParticles();
      Collection<ParticleBinding> particleBindings = modelGroupBinding.getParticles();
      Map<QName, XSParticle> xsElementParticles = null;
      Map<QName, ParticleBinding> elementParticles = null;
      if(xsParticles.getLength() > 0)
      {
         assertTrue("ModelGroupBinding has particles.", particleBindings != null);
         if(xsParticles.getLength() != particleBindings.size() || all)
         {
            // let's try making it flat... to the elements
            xsElementParticles = new HashMap<QName, XSParticle>();
            flatten(xsModelGroup, xsElementParticles);
            elementParticles = new HashMap<QName, ParticleBinding>();
            flatten(modelGroupBinding, elementParticles);
           
            if(xsElementParticles.size() != elementParticles.size())
            {
               if (trace)
               {
                  String msg = "expected particles:\n";
                  for (int i = 0; i < xsParticles.getLength(); ++i)
                  {
                     XSTerm xsTerm = ((XSParticle) xsParticles.item(i)).getTerm();
                     short type = xsTerm.getType();
                     if (type == XSConstants.MODEL_GROUP)
                     {
                        short compositor = ((XSModelGroup) xsTerm).getCompositor();
                        if (compositor == XSModelGroup.COMPOSITOR_SEQUENCE)
                           msg += "- sequence\n";
                        else if (compositor == XSModelGroup.COMPOSITOR_CHOICE)
                           msg += "- choice\n";
                        else if (compositor == XSModelGroup.COMPOSITOR_ALL)
                           msg += "- all\n";
                     }
                     else if (type == XSConstants.ELEMENT_DECLARATION)
                     {
                        XSElementDeclaration element = (XSElementDeclaration) xsTerm;
                        msg += "- " + new QName(element.getNamespace(), element.getName()) + "\n";
                     }
                     else
                     {
                        msg += "- wildcard\n";
                     }
                  }

                  msg += "actual particles:\n";
                  Iterator<ParticleBinding> iter = particleBindings.iterator();
                  while (iter.hasNext())
                  {
                     TermBinding term = iter.next().getTerm();
                     if (term.isModelGroup())
                     {
                        if (term instanceof SequenceBinding)
                           msg += "- sequence\n";
                        else if (term instanceof ChoiceBinding)
                           msg += "- choice\n";
                        else
                           msg += "- wildcard\n";
                     }
                     else if (term.isElement())
                        msg += "- " + ((ElementBinding) term).getQName() + "\n";
                     else
                        msg += "- wildcard";
                  }
                  log.trace(msg);
                 
                  List<QName> missing = new ArrayList<QName>(xsElementParticles.keySet());
                  missing.removeAll(elementParticles.keySet());
                  log.trace("flattened ModelGroupBinding is missing: ");
                  for (Iterator<QName> missingNames = missing.iterator(); missingNames.hasNext();)
                     log.trace("- " + missingNames.next());

                  missing = new ArrayList<QName>(elementParticles.keySet());
                  missing.removeAll(xsElementParticles.keySet());
                  log.trace("flattened XSModelGroup is missing: ");
                  for (Iterator<QName> missingNames = missing.iterator(); missingNames.hasNext();)
                     log.trace("- " + missingNames.next());
               }
               fail("ModelGroupBinding particles total expected " + xsParticles.getLength() + " but was "
                     + particleBindings.size());
            }
         }
      }

      if(xsElementParticles != null)
      {
         Iterator<ParticleBinding> iter = elementParticles.values().iterator();
         while(iter.hasNext())
         {
            ParticleBinding particleBinding = iter.next();
            QName particleQName;
            TermBinding termBinding = particleBinding.getTerm();
            if(termBinding.isWildcard())
               particleQName = WILDCARD;
            else
               particleQName = ((ElementBinding)termBinding).getQName();
            XSParticle xsParticle = xsElementParticles.get(particleQName);
            if(xsParticle == null)
            {
               if(particleQName == WILDCARD)
                  fail("WildcardBinding is missing");
               else
                  fail("ElementBinding " + particleQName + " is missing: " + xsElementParticles.keySet());
            }
            assertEquivalent(xsParticle, particleBinding);           
         }
      }
      else
      {
         Iterator<ParticleBinding> iter = particleBindings.iterator();
         for (int i = 0; i < xsParticles.getLength(); ++i)
         {
            XSParticle xsParticle = (XSParticle) xsParticles.item(i);
            assertEquivalent(xsParticle, iter.next());
         }
      }
   }
View Full Code Here

      }
   }

   private void flatten(XSModelGroup xsModelGroup, Map<QName, XSParticle> elementParticles)
   {
      XSObjectList xsParticles = xsModelGroup.getParticles();
      for(int i = 0; i < xsParticles.getLength(); ++i)
      {
         XSParticle particle = (XSParticle)xsParticles.item(i);
         XSTerm term = particle.getTerm();
         short termType = term.getType();
         if(termType == XSConstants.ELEMENT_DECLARATION)
         {
            XSElementDeclaration element = (XSElementDeclaration) term;
View Full Code Here

    }
    // else if a term is a model group
    else if(term.getType() == XSConstants.MODEL_GROUP)
    {
      // Getting a list of Particle schema components
      XSObjectList list = ((XSModelGroup) term).getParticles();
      for (int i = 0; i < list.getLength(); i++)
      {
        // Collecting element names
        swaRefs.addAll(collectSwaRefs(((XSParticle) list.item(i)).getTerm()));
      }
    }
    return swaRefs;
  }
View Full Code Here

          && referencesSwaRef(xsComplexType.getParticle().getTerm(), types))
        {
          return true;
        }
        // Getting the type's attributes
        XSObjectList attrList = xsComplexType.getAttributeUses();
        for (int i = 0; i < attrList.getLength(); i++)
        {
          XSAttributeUse xsAttrUse = (XSAttributeUse) attrList.item(i);
          // If an attribute is defined using ref:swaRef, return true
          if (referencesSwaRef(
            xsAttrUse.getAttrDeclaration().getTypeDefinition(), types))
          {
            return true;
View Full Code Here

    }
    // else if a term is a model group
    else if(term.getType() == XSConstants.MODEL_GROUP)
    {
      // Getting a list of Particle schema components
      XSObjectList list = ((XSModelGroup) term).getParticles();
      for (int i = 0; i < list.getLength(); i++)
      {
        // If the term of a particle is defined with the ref:swaRef,
        // return true
        if (referencesSwaRef(((XSParticle) list.item(i)).getTerm(), types))
        {
          return true;
        }
      }
    }
View Full Code Here

        }
        if(term instanceof XSModelGroup){
          parseXSModelGroup(tagInfo, tagList, (XSModelGroup)term);
        }
      }
      XSObjectList attrs = ((XSComplexTypeDefinition)type).getAttributeUses();
      for(int i=0;i<attrs.getLength();i++){
        XSAttributeUse attrUse = (XSAttributeUse)attrs.item(i);
        XSAttributeDeclaration attr = attrUse.getAttrDeclaration();
        AttributeInfo attrInfo = new AttributeInfo(attr.getName(),true,AttributeInfo.NONE,attrUse.getRequired());
        tagInfo.addAttributeInfo(attrInfo);
      }
     
View Full Code Here

     
    }
  }
 
  private void parseXSModelGroup(TagInfo tagInfo, List tagList, XSModelGroup term){
    XSObjectList list = ((XSModelGroup)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){
View Full Code Here

      }
   }

   private void addGroup(XSModelGroup xm, String containingElement, String containingType, JavaWsdlMapping jwm)
   {
      XSObjectList xo = xm.getParticles();
      int len = xo != null ? xo.getLength() : 0;
      for (int i = 0; i < len; i++)
      {
         XSTerm xsterm = ((XSParticle)xo.item(i)).getTerm();
         if (xsterm instanceof XSModelGroup)
         {
            addGroup((XSModelGroup)xsterm, containingElement, containingType, jwm);
         }
         else if (xsterm instanceof XSElementDeclaration)
View Full Code Here

TOP

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

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.