Package commonj.sdo.helper

Examples of commonj.sdo.helper.XMLDocument


    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


                    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

    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

    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

        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

    }

    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

            XMLStreamHelper streamHelper = SDOUtil.createXMLStreamHelper(helperContext);
            final QName elementName = SDOContextHelper.getElement(context);
            final XMLHelper xmlHelper = helperContext.getXMLHelper();
            // Allow privileged access to read properties. REquires java.util.PropertyPermission
            // XML.load.form.lax read in security policy.
            XMLDocument document = AccessController.doPrivileged(new PrivilegedAction<XMLDocument>() {
                public XMLDocument run() {
                    return xmlHelper.createDocument(source, elementName.getNamespaceURI(), elementName.getLocalPart());
                }
            });
                   
View Full Code Here

        try {
            HelperContext helperContext = SDOContextHelper.getHelperContext(context, false);
            XMLHelper xmlHelper = helperContext.getXMLHelper();
            Document doc = helper.promote(source);
            DOMSource domSource = new DOMSource(doc);
            XMLDocument xmlDoc = xmlHelper.load(domSource, doc.getDocumentURI(), null);
            return xmlDoc.getRootObject();
        } catch (Exception e) {
            throw new TransformationException(e);
        }
    }
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

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.