Examples of XSWildcard


Examples of org.apache.xerces.xs.XSWildcard

        XSModel model = getXSModel(synthetic);

        XSAttributeGroupDefinition attgp = model.getAttributeGroup("attgrp",
                "XSWildcardTest");
        XSWildcard attrWC = attgp.getAttributeWildcard();

        XSAnnotation annotation = attrWC.getAnnotation();
        assertEquals("TEST3_ATTRWC_ANNOTATION_" + synthetic, expected,
                trim(annotation.getAnnotationString()));

        XSObjectList annotations = attrWC.getAnnotations();
        assertEquals(
                "TEST3_ATTRWC_ANNOTATIONS_" + synthetic,
                expected,
                trim(((XSAnnotation) annotations.item(0)).getAnnotationString()));
    }
View Full Code Here

Examples of org.apache.xerces.xs.XSWildcard

                "XSWildcardTest");
        XSParticle seq = ((XSComplexTypeDefinition) elem.getTypeDefinition())
                .getParticle();
        XSModelGroup mg = (XSModelGroup) seq.getTerm();
        XSParticle anyPart = (XSParticle) mg.getParticles().item(1);
        XSWildcard elemWC = (XSWildcard) anyPart.getTerm();

        XSAnnotation annotation = elemWC.getAnnotation();
        assertNull("TEST4_ELEMWC_NO_ANNOTATION", annotation);

        XSObjectList annotations = elemWC.getAnnotations();
        assertEquals("TEST4_ELEMWC_NO_ANNOTATIONS", 0, annotations.getLength());
    }
View Full Code Here

Examples of org.apache.xerces.xs.XSWildcard

                "XSWildcardTest");
        XSParticle seq = ((XSComplexTypeDefinition) elem.getTypeDefinition())
                .getParticle();
        XSModelGroup mg = (XSModelGroup) seq.getTerm();
        XSParticle anyPart = (XSParticle) mg.getParticles().item(2);
        XSWildcard elemWC = (XSWildcard) anyPart.getTerm();

        XSAnnotation annotation = elemWC.getAnnotation();
        assertNotNull("TEST5_ELEMWC_SYNTH_ANNOTATION", annotation);

        XSObjectList annotations = elemWC.getAnnotations();
        assertEquals("TEST5_ELEMWC_SYNTH_ANNOTATIONS", 1, annotations
                .getLength());
    }
View Full Code Here

Examples of org.apache.xerces.xs.XSWildcard

                "XSWildcardTest");
        XSParticle seq = ((XSComplexTypeDefinition) elem.getTypeDefinition())
                .getParticle();
        XSModelGroup mg = (XSModelGroup) seq.getTerm();
        XSParticle anyPart = (XSParticle) mg.getParticles().item(3);
        XSWildcard elemWC = (XSWildcard) anyPart.getTerm();

        XSAnnotation annotation = elemWC.getAnnotation();
        assertEquals("TEST6_ELEMWC_ANNOTATION", expected, trim(annotation
                .getAnnotationString()));

        XSObjectList annotations = elemWC.getAnnotations();
        assertEquals(
                "TEST6_ELEMWC_ANNOTATIONS",
                expected,
                trim(((XSAnnotation) annotations.item(0)).getAnnotationString()));
    }
View Full Code Here

Examples of org.apache.xerces.xs.XSWildcard

                "XSWildcardTest");
        XSParticle seq = ((XSComplexTypeDefinition) elem.getTypeDefinition())
                .getParticle();
        XSModelGroup mg = (XSModelGroup) seq.getTerm();
        XSParticle anyPart = (XSParticle) mg.getParticles().item(4);
        XSWildcard elemWC = (XSWildcard) anyPart.getTerm();

        XSAnnotation annotation = elemWC.getAnnotation();
        assertEquals("TEST7_ELEMWC_ANNOTATION", expected, trim(annotation
                .getAnnotationString()));

        XSObjectList annotations = elemWC.getAnnotations();
        assertEquals(
                "TEST7_ELEMWC_ANNOTATIONS",
                expected,
                trim(((XSAnnotation) annotations.item(0)).getAnnotationString()));
    }
View Full Code Here

Examples of org.apache.xerces.xs.XSWildcard

      return marshalled;
   }

   private boolean marshalWildcard(XSParticle particle, boolean declareNs)
   {
      XSWildcard wildcard = (XSWildcard)particle.getTerm();
      Object o = stack.peek();
      ClassMapping mapping = getClassMapping(o.getClass());
      if(mapping == null)
      {
         // todo: YAH (yet another hack)
         QName autoType = SimpleTypeBindings.typeQName(o.getClass());
         if(autoType != null)
         {
            String marshalled = SimpleTypeBindings.marshal(autoType.getLocalPart(), o, null);
            content.characters(marshalled.toCharArray(), 0, marshalled.length());
            return true;
         }
         else
         {
            if(ignoreUnresolvedWildcard)
            {
               log.warn("Failed to marshal wildcard. Class mapping not found for " +
                  o.getClass() +
                  "@" +
                  o.hashCode() +
                  ": " + o
               );
               return true;
            }
            else
            {
               throw new IllegalStateException("Failed to marshal wildcard. Class mapping not found for " +
                  o.getClass() +
                  "@" +
                  o.hashCode() +
                  ": " + o
               );
            }
         }
      }

      GenericObjectModelProvider parentProvider = this.provider;
      Object parentRoot = this.root;
      Stack parentStack = this.stack;
      XSModel parentModel = this.model;

      this.root = o;
      this.stack = new StackImpl();
      this.model = mapping.schemaUrl == null ? this.model : Util.loadSchema(mapping.schemaUrl, schemaResolver);
      if(mapping.provider != null)
      {
         this.provider = mapping.provider;
      }

      boolean marshalled;
      if(mapping.elementName != null)
      {
         XSElementDeclaration elDec = model.getElementDeclaration(mapping.elementName.getLocalPart(),
            mapping.elementName.getNamespaceURI()
         );

         if(elDec == null)
         {
            throw new JBossXBRuntimeException("Element " + mapping.elementName + " is not declared in the schema.");
         }

         Object elementValue = provider.getRoot(root, null, elDec.getNamespace(), elDec.getName());
         marshalled = marshalElementOccurence(elDec.getNamespace(),
            elDec.getName(),
            elDec.getTypeDefinition(),
            elementValue,
            elDec.getNillable(),
            particle.getMinOccurs() == 0,
            declareNs
         );
      }
      else if(mapping.typeName != null)
      {
         XSTypeDefinition typeDef = model.getTypeDefinition(mapping.typeName.getLocalPart(),
            mapping.typeName.getNamespaceURI()
         );

         if(typeDef == null)
         {
            List typeNames = new ArrayList();
            XSNamedMap types = model.getComponents(XSConstants.TYPE_DEFINITION);
            for(int i = 0; i < types.getLength(); ++i)
            {
               XSObject type = types.item(i);
               if(!Constants.NS_XML_SCHEMA.equals(type.getNamespace()))
               {
                  typeNames.add(new QName(type.getNamespace(), type.getName()));
               }
            }
            throw new JBossXBRuntimeException("Type " +
               mapping.typeName +
               " is not defined in the schema." +
               " Defined types are: " + typeNames
            );
         }

         Object elementValue = provider.getRoot(root, null, wildcard.getNamespace(), wildcard.getName());
         marshalled =
            marshalElementOccurence(wildcard.getNamespace(),
               wildcard.getName(),
               typeDef,
               elementValue,
               true,
               particle.getMinOccurs() == 0,
               declareNs
View Full Code Here

Examples of org.apache.xerces.xs.XSWildcard

      particleBinding.setMaxOccurs(particle.getMaxOccurs());
      particleBinding.setMaxOccursUnbounded(particle.getMaxOccursUnbounded());
      particleBinding.setMinOccurs(particle.getMinOccurs());
      group.addParticle(particleBinding);

      XSWildcard wildcard = (XSWildcard)particle.getTerm();
      if(wildcard.getName() != null)
      {
         binding.setQName(new QName(wildcard.getNamespace(), wildcard.getName()));
      }

      binding.setProcessContents(wildcard.getProcessContents());

      if (ctx.processAnnotations)
      {
         XSAnnotation annotation = wildcard.getAnnotation();
         if(annotation != null)
         {
            customizeTerm(annotation, binding, ctx.trace);
         }
      }
View Full Code Here

Examples of org.apache.xerces.xs.XSWildcard

      particleBinding.setMaxOccurs(particle.getMaxOccurs());
      particleBinding.setMaxOccursUnbounded(particle.getMaxOccursUnbounded());
      particleBinding.setMinOccurs(particle.getMinOccurs());
      group.addParticle(particleBinding);

      XSWildcard wildcard = (XSWildcard)particle.getTerm();
      if(wildcard.getName() != null)
      {
         binding.setQName(new QName(wildcard.getNamespace(), wildcard.getName()));
      }

      binding.setProcessContents(wildcard.getProcessContents());

      if (processAnnotations)
      {
         XSAnnotation annotation = wildcard.getAnnotation();
         if(annotation != null)
         {
            customizeTerm(annotation, binding, trace);
         }
      }
View Full Code Here

Examples of org.apache.xerces.xs.XSWildcard

      return marshalled;
   }

   private boolean marshalWildcard(XSParticle particle, boolean declareNs)
   {
      XSWildcard wildcard = (XSWildcard)particle.getTerm();
      Object o = stack.peek();
      ClassMapping mapping = getClassMapping(o.getClass());
      if(mapping == null)
      {
         // todo: YAH (yet another hack)
         QName autoType = SimpleTypeBindings.typeQName(o.getClass());
         if(autoType != null)
         {
            String marshalled = SimpleTypeBindings.marshal(autoType.getLocalPart(), o, null);
            content.characters(marshalled.toCharArray(), 0, marshalled.length());
            return true;
         }
         else
         {
            if(ignoreUnresolvedWildcard)
            {
               log.warn("Failed to marshal wildcard. Class mapping not found for " +
                  o.getClass() +
                  "@" +
                  o.hashCode() +
                  ": " + o
               );
               return true;
            }
            else
            {
               throw new IllegalStateException("Failed to marshal wildcard. Class mapping not found for " +
                  o.getClass() +
                  "@" +
                  o.hashCode() +
                  ": " + o
               );
            }
         }
      }

      GenericObjectModelProvider parentProvider = this.provider;
      Object parentRoot = this.root;
      Stack parentStack = this.stack;
      XSModel parentModel = this.model;

      this.root = o;
      this.stack = new StackImpl();
      this.model = mapping.schemaUrl == null ? this.model : Util.loadSchema(mapping.schemaUrl, schemaResolver);
      if(mapping.provider != null)
      {
         this.provider = mapping.provider;
      }

      boolean marshalled;
      if(mapping.elementName != null)
      {
         XSElementDeclaration elDec = model.getElementDeclaration(mapping.elementName.getLocalPart(),
            mapping.elementName.getNamespaceURI()
         );

         if(elDec == null)
         {
            throw new JBossXBRuntimeException("Element " + mapping.elementName + " is not declared in the schema.");
         }

         Object elementValue = provider.getRoot(root, null, elDec.getNamespace(), elDec.getName());
         marshalled = marshalElementOccurence(elDec.getNamespace(),
            elDec.getName(),
            elDec.getTypeDefinition(),
            elementValue,
            elDec.getNillable(),
            particle.getMinOccurs() == 0,
            declareNs
         );
      }
      else if(mapping.typeName != null)
      {
         XSTypeDefinition typeDef = model.getTypeDefinition(mapping.typeName.getLocalPart(),
            mapping.typeName.getNamespaceURI()
         );

         if(typeDef == null)
         {
            List typeNames = new ArrayList();
            XSNamedMap types = model.getComponents(XSConstants.TYPE_DEFINITION);
            for(int i = 0; i < types.getLength(); ++i)
            {
               XSObject type = types.item(i);
               if(!Constants.NS_XML_SCHEMA.equals(type.getNamespace()))
               {
                  typeNames.add(new QName(type.getNamespace(), type.getName()));
               }
            }
            throw new JBossXBRuntimeException("Type " +
               mapping.typeName +
               " is not defined in the schema." +
               " Defined types are: " + typeNames
            );
         }

         Object elementValue = provider.getRoot(root, null, wildcard.getNamespace(), wildcard.getName());
         marshalled =
            marshalElementOccurence(wildcard.getNamespace(),
               wildcard.getName(),
               typeDef,
               elementValue,
               true,
               particle.getMinOccurs() == 0,
               declareNs
View Full Code Here

Examples of org.apache.xerces.xs.XSWildcard

/* 1077 */     particleBinding.setMaxOccurs(particle.getMaxOccurs());
/* 1078 */     particleBinding.setMaxOccursUnbounded(particle.getMaxOccursUnbounded());
/* 1079 */     particleBinding.setMinOccurs(particle.getMinOccurs());
/* 1080 */     group.addParticle(particleBinding);
/*      */
/* 1082 */     XSWildcard wildcard = (XSWildcard)particle.getTerm();
/* 1083 */     if (wildcard.getName() != null)
/*      */     {
/* 1085 */       binding.setQName(new QName(wildcard.getNamespace(), wildcard.getName()));
/*      */     }
/*      */
/* 1088 */     binding.setProcessContents(wildcard.getProcessContents());
/*      */
/* 1090 */     if (this.processAnnotations)
/*      */     {
/* 1092 */       XSAnnotation annotation = wildcard.getAnnotation();
/* 1093 */       if (annotation != null)
/*      */       {
/* 1095 */         customizeTerm(annotation, binding, this.trace);
/*      */       }
/*      */     }
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.