Package org.apache.xerces.xs

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


        XSModel model = fSchemaLoader
                .loadURI(getResourceURL("XSWildcardTest01.xsd"));

        XSElementDeclaration elem = model.getElementDeclaration("test",
                "XSWildcardTest");
        XSWildcard attrWC = ((XSComplexTypeDefinition) elem.getTypeDefinition())
                .getAttributeWildcard();

        XSAnnotation annotation = attrWC.getAnnotation();
        assertNull("TEST1_ATTRWC_NO_ANNOTATION", annotation);

        XSObjectList annotations = attrWC.getAnnotations();
        assertEquals("TEST1_ATTRWC_NO_ANNOTATIONS", 0, annotations.getLength());

        fConfig
                .setParameter(
                        "http://apache.org/xml/features/generate-synthetic-annotations",
                        Boolean.TRUE);

        model = fSchemaLoader
                .loadURI(getResourceURL("XSWildcardTest01.xsd"));

        elem = model.getElementDeclaration("test", "XSWildcardTest");
        attrWC = ((XSComplexTypeDefinition) elem.getTypeDefinition())
                .getAttributeWildcard();

        annotation = attrWC.getAnnotation();
        assertNotNull("TEST1_ATTRWC_SYNTH_ANNOTATION", annotation);

        annotations = attrWC.getAnnotations();
        assertEquals("TEST1_ATTRWC_SYNTHO_ANNOTATIONS", 1, annotations
                .getLength());
    }
View Full Code Here

        XSModel model = getXSModel(synthetic);

        XSElementDeclaration elem = model.getElementDeclaration("root",
                "XSWildcardTest");
        XSWildcard attrWC = ((XSComplexTypeDefinition) elem.getTypeDefinition())
                .getAttributeWildcard();

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

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

        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

                "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

                "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

                "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

                "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

      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

      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

TOP

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

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.