Package commonj.sdo.helper

Examples of commonj.sdo.helper.XMLDocument


    private static final String QUOTE_XML = "/quote.xml";
    private static final String SHALLOW_QUOTE_XML = "/shallowquote.xml";

    public void testEquality() throws IOException {

        XMLDocument doc = XMLHelper.INSTANCE.load(getClass().getResourceAsStream(QUOTE_XML));
        DataObject sdo = doc.getRootObject();

        doc = XMLHelper.INSTANCE.load(getClass().getResourceAsStream(SHALLOW_QUOTE_XML));
        DataObject shallowSdo = doc.getRootObject();

        boolean result = EqualityHelper.INSTANCE.equalShallow(sdo, shallowSdo);
        assertTrue(result);

        result = EqualityHelper.INSTANCE.equal(sdo, shallowSdo);
View Full Code Here


    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    xmlHelper.save(customerType, "commonj.sdo", "type", baos);
   
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    XMLDocument xdoc = xmlHelper.load(bais);

    customerType = xdoc.getRootObject();
   
    // now define the Customer type so that customers can be made
    types.define(customerType);
   
    DataObject customer1 = factory.create("http://example.com/customer",
View Full Code Here

   * @throws IOException
   */
  public void testSchemaLocation() throws IOException
  {
    // load the xml document which has xsi:noNamespaceSchemaLocation and xsi:schemaLocation defined
    XMLDocument doc = XMLHelper.INSTANCE.load(getClass().getResourceAsStream(TEST_XML_DOCUMENT));

    // get the schemaLocation
    assertEquals(NS1_SCHEMA_NAME + " " + NS1_SCHEMA_LOCATION + " " + NS2_SCHEMA_NAME + " " + NS2_SCHEMA_LOCATION, doc.getSchemaLocation());

    // set the schemaLocation to another value and test to see if the value was set
    doc.setSchemaLocation(NS_SET_NAME_LOCATION);
    assertEquals(NS_SET_NAME_LOCATION, doc.getSchemaLocation());

    // remove the schemaLocation and ensure it returns null
    doc.setSchemaLocation(null);
    assertNull(doc.getSchemaLocation());

    // ensure changes to schemaLocation have not changed noNamespaceSchemaLocation
    assertEquals(NNS_SCHEMA_LOCATION, doc.getNoNamespaceSchemaLocation());
  }
View Full Code Here

   * @throws IOException
   */
  public void testNoNamespaceSchemaLocation() throws IOException
  {
    // load the xml document which has xsi:noNamespaceSchemaLocation and xsi:schemaLocation defined
    XMLDocument doc = XMLHelper.INSTANCE.load(getClass().getResourceAsStream(TEST_XML_DOCUMENT));

    // get the noNamespaceSchemaLocation
    assertEquals(NNS_SCHEMA_LOCATION, doc.getNoNamespaceSchemaLocation());

    // set the noNameSpaceSchemaLocation to another value and test to see if the value was set
    doc.setNoNamespaceSchemaLocation(NNS_SET_LOCATION);
    assertEquals(NNS_SET_LOCATION, doc.getNoNamespaceSchemaLocation());

    // remove the noNameSpaceSchemaLocation and ensure it returns null
    doc.setNoNamespaceSchemaLocation(null);
    assertNull(doc.getNoNamespaceSchemaLocation());

    // ensure changes to noNameSpaceSchemaLocation have not changed schemaLocation
    assertEquals(NS1_SCHEMA_NAME + " " + NS1_SCHEMA_LOCATION + " " + NS2_SCHEMA_NAME + " " + NS2_SCHEMA_LOCATION, doc.getSchemaLocation());
  }
View Full Code Here

     */
    public static DataObject toDataObject(TypeHelper typeHelper, byte[] xmlBytes) {
        try {

            XMLHelper xmlHelper = SDOUtil.createXMLHelper(typeHelper);
            XMLDocument document = xmlHelper.load(new ByteArrayInputStream(xmlBytes));

            return document.getRootObject();

        } catch (IOException e) {
            throw new ServiceRuntimeException(e);
        }
    }
View Full Code Here

            name = Character.toLowerCase(name.charAt(0)) + name.substring(1, name.length());
        }

        try {
            DOMResult domResult = new DOMResult(DOMHelper.newDocument());
            XMLDocument xmlDoc = helper.createDocument(source, null, name);
            helper.save(xmlDoc, domResult, null);
            return node2NodeInfoTransformer.transform(domResult.getNode(), context);
        } catch (Exception e) {
            throw new TransformationException(e);
        }
View Full Code Here

    @Override
    public Object copy(Object arg) {
        HelperContext context = HelperProvider.getDefaultContext();
        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);
        }
View Full Code Here

        try {
            HelperContext helperContext = SDOContextHelper.getHelperContext(context);
            XMLStreamHelper streamHelper = SDOUtil.createXMLStreamHelper(helperContext);
            QName elementName = SDOContextHelper.getElement(context);
            XMLHelper xmlHelper = helperContext.getXMLHelper();
            XMLDocument document =
                    xmlHelper.createDocument(source, elementName.getNamespaceURI(), elementName.getLocalPart());
            return streamHelper.createXMLStreamReader(document);
        } catch (XMLStreamException e) {
            // TODO: Add context to the exception
            throw new TransformationException(e);
View Full Code Here

        handler = new SDOWrapperHandler();
    }

    public void testWrapperAnyType() throws Exception {
        XMLHelper xmlHelper = context.getXMLHelper();
        XMLDocument document = xmlHelper.load(getClass().getResourceAsStream("/wrapper.xml"));
        List children = handler.getChildren(document, null, null);
        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"));
        List children = handler.getChildren(document, null, null);
        assertEquals(5, children.size());
    }
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.