Package org.jboss.xb.binding.sunday.unmarshalling

Examples of org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding


      assertXmlEqual(XML_STRING_TYPE, writer.getBuffer().toString());
   }

   public void testTermAfterUnmarshallingHandler_stringType() throws Exception
   {
      SchemaBinding schema = getSchema();
      StringReader xmlReader = new StringReader(XML_STRING_TYPE);
      Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
      Object o = unmarshaller.unmarshal(xmlReader, schema);
      assertNotNull(o);
      assertTrue(o instanceof GlobalElement);
View Full Code Here


      assertEquals(GlobalElement.STRING_TYPE, global.stringType);
   }

   public void testTermBeforeMarshallingHandler_stringElement() throws Exception
   {
      SchemaBinding schema = getSchema();
      MarshallerImpl marshaller = getMarshaller();
      StringWriter writer = new StringWriter();
      GlobalElement global = new GlobalElement();
      global.stringElement = GlobalElement.TEXT;
      marshaller.marshal(schema, null, global, writer);
View Full Code Here

      assertXmlEqual(XML_STRING_ELEMENT, writer.getBuffer().toString());
   }

   public void testTermAfterUnmarshallingHandler_stringElement() throws Exception
   {
      SchemaBinding schema = getSchema();
      StringReader xmlReader = new StringReader(XML_STRING_ELEMENT);
      Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
      Object o = unmarshaller.unmarshal(xmlReader, schema);
      assertNotNull(o);
      assertTrue(o instanceof GlobalElement);
View Full Code Here

      assertEquals(GlobalElement.TEXT, global.stringElement);
   }

   public void testTermBeforeMarshallingHandler_sequenceItem() throws Exception
   {
      SchemaBinding schema = getSchema();
      MarshallerImpl marshaller = getMarshaller();
      StringWriter writer = new StringWriter();
      GlobalElement global = new GlobalElement();
      global.sequenceItem = GlobalElement.STRING_TYPE;
      marshaller.marshal(schema, null, global, writer);
View Full Code Here

      assertXmlEqual(XML_SEQUENCE_ITEM, writer.getBuffer().toString());
   }

   public void testTermAfterUnmarshallingHandler_sequenceItem() throws Exception
   {
      SchemaBinding schema = getSchema();
      StringReader xmlReader = new StringReader(XML_SEQUENCE_ITEM);
      Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
      Object o = unmarshaller.unmarshal(xmlReader, schema);
      assertNotNull(o);
      assertTrue(o instanceof GlobalElement);
View Full Code Here

      super(localName);
   }

   public void testXsd() throws Exception
   {
      SchemaBinding schema = XsdBinder.bind(getFullPath("xml/maps.xsd"));

      Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
      Object map = unmarshaller.unmarshal(getFullPath("xml/maps.xml"), schema);

      assertNotNull(map);
View Full Code Here

      assertEquals(EXPECTED, map);
   }

   public void testManual() throws Exception
   {
      SchemaBinding schema = new SchemaBinding();

      // Type declarations
      TypeBinding mapType = new TypeBinding();
      // default model group is all, we want sequence
      mapType.setParticle(new ParticleBinding(new SequenceBinding(schema)));

      TypeBinding entry1Type = new TypeBinding();
      TypeBinding entry2Type = new TypeBinding();
      TypeBinding entry3Type = new TypeBinding();
      TypeBinding entry4Type = new TypeBinding();

      // Schema assembling
      mapType.addElement(QNAME_ENTRY1, entry1Type, 0, true);
      mapType.addElement(QNAME_ENTRY2, entry2Type, 0, true);
      mapType.addElement(QNAME_ENTRY3, entry3Type, 0, true);
      mapType.addElement(QNAME_ENTRY4, entry4Type, 0, true);

      // sequence as entry
      SequenceBinding entrySeq = new SequenceBinding(schema);
      ElementBinding keyElement = new ElementBinding(schema, new QName(NS, "key"), new TypeBinding());
      entrySeq.addParticle(new ParticleBinding(keyElement));
      ElementBinding valueElement = new ElementBinding(schema, new QName(NS, "value"), new TypeBinding());
      entrySeq.addParticle(new ParticleBinding(valueElement));

      ParticleBinding entryParticle = new ParticleBinding(entrySeq);
      entryParticle.setMinOccurs(0);
      entryParticle.setMaxOccursUnbounded(true);
      mapType.addParticle(entryParticle);

      mapType.addElement(QNAME_SUBMAP, mapType, 0, true);
      schema.addElement(QNAME_MAP, mapType);

      // Handler implementations
      mapType.setHandler(new DefaultElementHandler()
      {
         public Object startElement(Object parent, QName name, ElementBinding element)
View Full Code Here

   }

   public void testUnmarshalling() throws Exception
   {
      String xsdPath = getUrl("xml/soapenc/test.xsd").toExternalForm();
      SchemaBinding schema = XsdBinder.bind(xsdPath, RESOLVER);
      Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
      Object o = unmarshaller.unmarshal(new StringReader(XML), schema);
      assertNotNull(o);
      assertTrue(o instanceof AllStruct);
      assertEquals(AllStruct.INSTANCE, o);
View Full Code Here

    * Creates and initializes an instance of SchemaBinding
    */
   public SchemaBinding buildSchemaBinding(XSModel model, JavaWsdlMapping wsdlMapping)
   {
      JBossEntityResolver resolver = new JBossWSEntityResolver();
      SchemaBinding schemaBinding = XsdBinder.bind(model, new DefaultSchemaResolver(resolver));

      schemaBinding.setIgnoreLowLine(false);
      schemaBinding.setIgnoreUnresolvedFieldOrClass(false);
      schemaBinding.setUnmarshalListsToArrays(true); // note: default jaxb2.0 is false!
      schemaBinding.setSimpleContentProperty("_value");
      schemaBinding.setUseNoArgCtorIfFound(true);
      schemaBinding.setReplacePropertyRefs(false);
      if (wsdlMapping != null)
      {
         bindSchemaToJava(schemaBinding, wsdlMapping);
      }

View Full Code Here

               }
            }
         }

         // the actual marshalling
         SchemaBinding schemaBinding = JBossXBSupport.getOrCreateSchemaBinding(properties);
         schemaBinding.setXopMarshaller(new XOPMarshallerImpl());
         delegate.marshal(schemaBinding, null, obj, writer);
      }
      catch (RuntimeException e)
      {
         throw e;
View Full Code Here

TOP

Related Classes of org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding

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.