Package commonj.sdo.helper

Examples of commonj.sdo.helper.XMLDocument


                    name = xmlType.getElementName();
                }
            }
        }

        XMLDocument document = helperContext.getXMLHelper().createDocument(source,
                                                                           name.getNamespaceURI(),
                                                                           name.getLocalPart());
        SDODataSource dataSource = new SDODataSource(document, helperContext);
        OMElement element = AxiomHelper.createOMElement(factory, name, dataSource);
        return element;
View Full Code Here


    }

    public final void testCopyXMLDocument() {
        PurchaseOrderType po = SdoFactory.INSTANCE.createPurchaseOrderType();
        po.setComment("Comment");
        XMLDocument doc =
            context.getXMLHelper().createDocument((DataObject)po,
                                                  ORDER_QNAME.getNamespaceURI(),
                                                  ORDER_QNAME.getLocalPart());
        Object copy = binding.copy(doc, null, null, null, null);
        assertTrue(copy instanceof XMLDocument);
        XMLDocument docCopy = (XMLDocument)copy;
        assertTrue(doc != copy);
        assertTrue(context.getEqualityHelper().equal((DataObject)po, docCopy.getRootObject()));
        assertEquals("Comment", ((PurchaseOrderType)docCopy.getRootObject()).getComment());
    }
View Full Code Here

    @Override
    public Object copy(Object arg, DataType dataType, DataType targetDataType, Operation operation, Operation targetOperation) {
        HelperContext context = SDOContextHelper.getHelperContext(operation);
        CopyHelper copyHelper = context.getCopyHelper();
        if (arg instanceof XMLDocument) {
            XMLDocument document = (XMLDocument)arg;
            DataObject dataObject = copyHelper.copy(document.getRootObject());
            return context.getXMLHelper().createDocument(dataObject,
                                                         document.getRootElementURI(),
                                                         document.getRootElementName());
        } else if (arg instanceof DataObject) {
            return context.getCopyHelper().copy((DataObject)arg);
        } else {
            return super.copy(arg, dataType, targetDataType, operation, targetOperation);
        }
View Full Code Here

    protected DataType<?> getTargetDataType() {
        return new DataTypeImpl<Class<XMLStreamReader>>(XMLStreamReader.class, XMLStreamReader.class);
    }

    public final void testTransform() throws XMLStreamException {
        XMLDocument document =
            helperContext.getXMLHelper().createDocument(dataObject,
                                                        ORDER_QNAME.getNamespaceURI(),
                                                        ORDER_QNAME.getLocalPart());
        XMLStreamReader reader = new XMLDocument2XMLStreamReader().transform(document, context);
        XMLDocument document2 = new XMLStreamReader2XMLDocument().transform(reader, reversedContext);
        Assert.assertEquals(ORDER_QNAME.getNamespaceURI(), document2.getRootElementURI());
        Assert.assertEquals(ORDER_QNAME.getLocalPart(), document2.getRootElementName());
        Assert.assertTrue(document2.getRootObject() instanceof PurchaseOrderType);
    }
View Full Code Here

    protected DataType<?> getTargetDataType() {
        return new DataTypeImpl<XMLType>(OMElement.class.getName(), OMElement.class, new XMLType(ORDER_QNAME, null));
    }

    public final void testTransform() throws XMLStreamException {
        XMLDocument document =
            helperContext.getXMLHelper().createDocument(dataObject,
                                                        ORDER_QNAME.getNamespaceURI(),
                                                        ORDER_QNAME.getLocalPart());
        OMElement element = new XMLDocument2OMElement().transform(document, context);
        Assert.assertEquals(ORDER_QNAME.getNamespaceURI(), element.getNamespace().getNamespaceURI());
View Full Code Here

        handler = new SDOWrapperHandler();
    }

    public void testWrapperAnyType() throws Exception {
        XMLHelper xmlHelper = context.getXMLHelper();
        XMLDocument document = xmlHelper.load(getClass().getResourceAsStream("/wrapper.xml"));
        Operation op = new OperationImpl();
        List children = handler.getChildren(document, op, true);
        assertEquals(5, children.size());
    }
View Full Code Here

    public void testWrapper() throws Exception {
        XSDHelper xsdHelper = context.getXSDHelper();
        xsdHelper.define(getClass().getResourceAsStream("/wrapper.xsd"), null);
        XMLHelper xmlHelper = context.getXMLHelper();
        XMLDocument document = xmlHelper.load(getClass().getResourceAsStream("/wrapper.xml"));
        Operation op = new OperationImpl();
        List children = handler.getChildren(document, op, true);
        assertEquals(5, children.size());
    }
View Full Code Here

      for (Iterator iter = getTypeMetaData().iterator(); iter.hasNext();)
      {
        TypeMetaData metadata = (TypeMetaData)iter.next();
        URL url = getClass().getResource(metadata.getLocation());
        InputStream inputStream = url.openStream();
        XMLDocument xmlDocument = xmlHelper.load(inputStream);
        Types types = (Types)xmlDocument.getRootObject();
        typeHelper.define(types.getTypeList());
      }
    }
    catch (Exception e)
    {
View Full Code Here

            }

            //REVISIT - This is SUCH a HACK.  This needs to be done with StAX or something
            //a bit better than streaming and reparsing
            InputStream in = getNodeStream(nd);
            XMLDocument document = new XMLHelperImpl(callback.getTypeHelper()).load(in);
            DataObject object = document.getRootObject();

            List ips = object.getInstanceProperties();
            Object[] os = new Object[object.getInstanceProperties().size()];
            for (int i = 0; i < os.length; i++) {
                os[i] = object.get((Property)ips.get(i));
View Full Code Here

  private final String TEST_NAMESPACE = "http://www.example.com/simple";
  private final String QUOTE_XML = "/quote.xml";
  private final String SHALLOW_QUOTE_XML = "/shallowquote.xml";

  public void testSimpleCopy() throws IOException {
      XMLDocument doc = XMLHelper.INSTANCE.load(getClass().getResourceAsStream(QUOTE_XML));
      DataObject sdo = doc.getRootObject();

      DataObject copiedSdo = CopyHelper.INSTANCE.copyShallow(sdo);

      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      XMLHelper.INSTANCE.save(copiedSdo, TEST_NAMESPACE, "stockQuote", baos);
View Full Code Here

TOP

Related Classes of commonj.sdo.helper.XMLDocument

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.