Package commonj.sdo.helper

Examples of commonj.sdo.helper.XMLDocument


 
  public DataObject getDataObjectFromFile(HelperContext scope, String filename)
      throws Exception {


    XMLDocument xmlDoc = getXMLDocumentFromFile(scope, filename);
    commentary(COMMENTARY_FOR_NOVICE,
        "An XMLDocument instance provides a wrapper for the root DataObject of a data graph\n" +
        "along with other aspects of the XML nature of the document\n\n"+
        "DataObject result = xmlDoc.getRootObject();",
       
        "Geting the root object from an XMLDocument as seen in previous samples"
    );
    DataObject result = xmlDoc.getRootObject();

    return result;
  }
View Full Code Here


  }
 
  public XMLDocument getXMLDocumentFromFile(HelperContext scope,
      String filename) throws Exception {

    XMLDocument result = null;
    InputStream is = null;

    try {
      commentary(COMMENTARY_FOR_NOVICE,
          "The XMLHelper can be used to create an SDO XMLDocument instance from a file\n\n"+
View Full Code Here

    return result;
  }
 
  protected XMLDocument getXMLDocumentFromString(HelperContext scope, String xmlDoc) throws IOException {
    XMLDocument result = null;
    InputStream is = null;


      commentary(COMMENTARY_FOR_NOVICE,
          "The XMLHelper can be used to create an SDO XMLDocument instance from an\n\n"+
View Full Code Here

            }
        }

        if (unmarshalledObject instanceof XMLRoot) {
            XMLRoot xmlRoot = (XMLRoot)unmarshalledObject;
            XMLDocument xmlDocument = createDocument((DataObject)((XMLRoot)unmarshalledObject).getObject(), ((XMLRoot)unmarshalledObject).getNamespaceURI(), ((XMLRoot)unmarshalledObject).getLocalName());
            if(xmlRoot.getEncoding() != null) {
                xmlDocument.setEncoding(xmlRoot.getEncoding());
            }
            if(xmlRoot.getXMLVersion() != null) {
                xmlDocument.setXMLVersion(xmlRoot.getXMLVersion());
            }
            xmlDocument.setSchemaLocation(xmlRoot.getSchemaLocation());
            xmlDocument.setNoNamespaceSchemaLocation(xmlRoot.getNoNamespaceSchemaLocation());
            return xmlDocument;            
        } else if (unmarshalledObject instanceof DataObject) {
            String localName = ((SDOType)((DataObject)unmarshalledObject).getType()).getXmlDescriptor().getDefaultRootElement();
            if (localName == null) {
                localName = ((SDOType)((DataObject)unmarshalledObject).getType()).getXsdLocalName();
View Full Code Here

           
        }
       
        if (unmarshalledObject instanceof XMLRoot) {
            XMLRoot xmlRoot = (XMLRoot)unmarshalledObject;
            XMLDocument xmlDocument = createDocument((DataObject)((XMLRoot)unmarshalledObject).getObject(), ((XMLRoot)unmarshalledObject).getNamespaceURI(), ((XMLRoot)unmarshalledObject).getLocalName());
            if(xmlRoot.getEncoding() != null) {
                xmlDocument.setEncoding(xmlRoot.getEncoding());
            }
            if(xmlRoot.getXMLVersion() != null) {
                xmlDocument.setXMLVersion(xmlRoot.getXMLVersion());
            }
            xmlDocument.setSchemaLocation(xmlRoot.getSchemaLocation());
            xmlDocument.setNoNamespaceSchemaLocation(xmlRoot.getNoNamespaceSchemaLocation());
            return xmlDocument;            
        } else if (unmarshalledObject instanceof DataObject) {
            DataObject unmarshalledDataObject = (DataObject)unmarshalledObject;
            String localName = ((SDOType)((DataObject)unmarshalledObject).getType()).getXmlDescriptor().getDefaultRootElement();
            if (localName == null) {
View Full Code Here

    /**
     * Convert between an XMLRoot and an SDO  XMLDocument.
     */
    private XMLDocument wrap(XMLRoot xmlRoot) {
        DataObject dataObject = getHelperContext().wrap(xmlRoot.getObject());
        XMLDocument xmlDocument =  getHelperContext().getXMLHelper().createDocument(dataObject, xmlRoot.getNamespaceURI(), xmlRoot.getLocalName());
        xmlDocument.setEncoding(xmlRoot.getEncoding());
        xmlDocument.setXMLVersion(xmlRoot.getXMLVersion());
        xmlDocument.setSchemaLocation(xmlRoot.getSchemaLocation());
        xmlDocument.setNoNamespaceSchemaLocation(xmlRoot.getNoNamespaceSchemaLocation());
        return xmlDocument;
    }
View Full Code Here

                // chain a GZIP stream to the byte stream
                aGZIPOutputStream = new GZIPOutputStream(aByteOutputStream);

                // write XML Serialization of the root DataObject to the GZIP output stream
                XMLDocument aDocument = aHelperContext.getXMLHelper().createDocument(//
                    theSDODataObject, //
                    SDOConstants.SDO_URL, // root element URI
                    SDOConstants.SDO_PREFIX + SDOConstants.SDO_XPATH_NS_SEPARATOR_FRAGMENT + DEFAULT_ROOT_ELEMENT_NAME);
                aHelperContext.getXMLHelper().save(aDocument, aGZIPOutputStream, null);
                // finished the stream to move compressed data from the Deflater
View Full Code Here

                // chain a GZIP stream to the byte stream
                aGZIPInputStream = new GZIPInputStream(aByteInputStream);

                // read XML Serialization of the root DataObject from the GZIP input stream
                XMLDocument aDocument = aHelperContext.getXMLHelper().load(aGZIPInputStream);

                theSDODataObject = (SDODataObject)aDocument.getRootObject();           
            } finally {
                // close streams on all Exceptions
                if (aGZIPInputStream != null) {// Clover: false case testing requires IO/comm failure
                    aGZIPInputStream.close();
                }
View Full Code Here

        } else {
            try {

                System.out.println("Using file to access xml to populate DataObjects");
                FileInputStream fis = new FileInputStream(xmlFileName);
                XMLDocument xmlDoc = XMLHelper.INSTANCE.load(fis);
                purchaseOrder = xmlDoc.getRootObject();
                System.out.println("Sucessfully used file to populate DataObjects");
                fis.close();
            } catch (Exception e) {
                System.out.println("Could not open and use file " + xmlFileName);
                e.printStackTrace();
View Full Code Here

        InputStream inputStream = url.openStream();
        xsdHelper.define(inputStream, url.toString());
       
        inputStream.close();
       
        XMLDocument doc = xmlHelper.load(getClass().getResourceAsStream(XPATH_XML));
         
        DataObject drive = doc.getRootObject();
        DataObject folder1 = (DataObject) drive.get("Folder.1");
        String value = folder1.getString("@creation_date");
        
        assertEquals(value, "2000-03-23");
    }
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.