Search in sources :

Example 1 with SDOXSDHelper

use of org.eclipse.persistence.sdo.helper.SDOXSDHelper in project metro-jax-ws by eclipse-ee4j.

the class SDOUtils method defineSchema.

// used by tests
public static List defineSchema(HelperContext hc, File f) throws Exception {
    FileInputStream fin = null;
    try {
        fin = new FileInputStream(f);
        InputStreamReader reader = new InputStreamReader(fin);
        StreamSource source = new StreamSource(reader);
        return ((SDOXSDHelper) hc.getXSDHelper()).define(source, null);
    } finally {
        if (fin != null) {
            try {
                fin.close();
            } catch (IOException ioe) {
            }
        }
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) StreamSource(javax.xml.transform.stream.StreamSource) SDOXSDHelper(org.eclipse.persistence.sdo.helper.SDOXSDHelper) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream)

Example 2 with SDOXSDHelper

use of org.eclipse.persistence.sdo.helper.SDOXSDHelper in project eclipselink by eclipse-ee4j.

the class DeptServiceClientTestCases method defineXSD.

private void defineXSD() {
    LOGGER.info("********** defineXSD() called **********");
    try {
        FileInputStream is = new FileInputStream(getSchemaName());
        HelperContext ctx = HelperProvider.getDefaultContext();
        SDOXSDHelper helper = (SDOXSDHelper) ctx.getXSDHelper();
        helper.define(is, null);
    } catch (Exception ioe) {
        fail("An exception occurred while attempting to define schema [" + getSchemaName() + "]: " + ioe);
    }
}
Also used : HelperContext(commonj.sdo.helper.HelperContext) SDOXSDHelper(org.eclipse.persistence.sdo.helper.SDOXSDHelper) FileInputStream(java.io.FileInputStream) NamingException(javax.naming.NamingException)

Example 3 with SDOXSDHelper

use of org.eclipse.persistence.sdo.helper.SDOXSDHelper in project eclipselink by eclipse-ee4j.

the class SDOResolvableTest method setUp.

@Override
public void setUp() {
    try {
        xmlComparer = new SDOXMLComparer();
        aHelperContext = SDOHelperContext.getHelperContext();
        typeHelper = aHelperContext.getTypeHelper();
        xmlHelper = aHelperContext.getXMLHelper();
        xsdHelper = aHelperContext.getXSDHelper();
        equalityHelper = aHelperContext.getEqualityHelper();
        copyHelper = aHelperContext.getCopyHelper();
        dataFactory = aHelperContext.getDataFactory();
        // TODO: we should be using the DataHelper interface
        dataHelper = (SDODataHelper) aHelperContext.getDataHelper();
        DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
        builderFactory.setNamespaceAware(true);
        builderFactory.setIgnoringElementContentWhitespace(true);
        try {
            parser = builderFactory.newDocumentBuilder();
        } catch (Exception e) {
            fail("Could not create parser.");
            e.printStackTrace();
        }
        ((SDOTypeHelper) typeHelper).reset();
        ((SDOXMLHelper) xmlHelper).reset();
        ((SDOXSDHelper) xsdHelper).reset();
        // load in the schema
        String xsdString = getXSDString("org/eclipse/persistence/testing/sdo/helper/xmlhelper/PurchaseOrderDeep.xsd");
        // Define Types so that processing attributes completes
        List types = xsdHelper.define(xsdString);
        // first we set up root data object
        FileInputStream inStream = new FileInputStream("org/eclipse/persistence/testing/sdo/helper/xmlhelper/PurchaseOrderNSDeep.xml");
        XMLDocument document = xmlHelper.load(inStream);
        root = document.getRootObject();
        inStream.close();
    } catch (Exception e) {
        e.printStackTrace();
        fail("SDOResolvableTestCases.setup() failed to load DataObject");
    }
}
Also used : SDOTypeHelper(org.eclipse.persistence.sdo.helper.SDOTypeHelper) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) SDOXSDHelper(org.eclipse.persistence.sdo.helper.SDOXSDHelper) ArrayList(java.util.ArrayList) List(java.util.List) SDOXMLHelper(org.eclipse.persistence.sdo.helper.SDOXMLHelper) SDOXMLComparer(org.eclipse.persistence.testing.sdo.SDOXMLComparer) InvalidClassException(java.io.InvalidClassException) FileInputStream(java.io.FileInputStream) XMLDocument(commonj.sdo.helper.XMLDocument)

Example 4 with SDOXSDHelper

use of org.eclipse.persistence.sdo.helper.SDOXSDHelper in project eclipselink by eclipse-ee4j.

the class EntityResolverTestCases method testResolveEntities.

public void testResolveEntities() {
    ByteArrayInputStream bis = new ByteArrayInputStream(getSchema().getBytes());
    ((SDOXSDHelper) HelperProvider.getDefaultContext().getXSDHelper()).define(new StreamSource(bis), new SchemaEntityResolver());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) StreamSource(javax.xml.transform.stream.StreamSource) SDOXSDHelper(org.eclipse.persistence.sdo.helper.SDOXSDHelper)

Example 5 with SDOXSDHelper

use of org.eclipse.persistence.sdo.helper.SDOXSDHelper in project eclipselink by eclipse-ee4j.

the class LoadAndSaveIncludeWithExtensionTestCases method defineTypes.

@Override
protected List defineTypes() {
    try {
        String xsd = FILE_PROTOCOL + USER_DIR + "/org/eclipse/persistence/testing/sdo/helper/xmlhelper/includeWithExtension/WithInclude.xsd";
        DefaultSchemaResolver sr = new DefaultSchemaResolver();
        sr.setBaseSchemaLocation(getSchemaLocation());
        return ((SDOXSDHelper) xsdHelper).define(new StreamSource(xsd), sr);
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
Also used : DefaultSchemaResolver(org.eclipse.persistence.sdo.helper.DefaultSchemaResolver) StreamSource(javax.xml.transform.stream.StreamSource) SDOXSDHelper(org.eclipse.persistence.sdo.helper.SDOXSDHelper)

Aggregations

SDOXSDHelper (org.eclipse.persistence.sdo.helper.SDOXSDHelper)65 ArrayList (java.util.ArrayList)34 List (java.util.List)28 SDOType (org.eclipse.persistence.sdo.SDOType)23 Type (commonj.sdo.Type)22 Document (org.w3c.dom.Document)21 InputSource (org.xml.sax.InputSource)21 StringReader (java.io.StringReader)20 DefaultSchemaLocationResolver (org.eclipse.persistence.sdo.helper.DefaultSchemaLocationResolver)19 FileInputStream (java.io.FileInputStream)15 StreamSource (javax.xml.transform.stream.StreamSource)15 DataObject (commonj.sdo.DataObject)12 DOMSource (javax.xml.transform.dom.DOMSource)12 SDODataObject (org.eclipse.persistence.sdo.SDODataObject)11 DefaultSchemaResolver (org.eclipse.persistence.sdo.helper.DefaultSchemaResolver)10 XMLDocument (commonj.sdo.helper.XMLDocument)9 SchemaLocationResolver (org.eclipse.persistence.sdo.helper.SchemaLocationResolver)9 QName (javax.xml.namespace.QName)8 IOException (java.io.IOException)7 InputStream (java.io.InputStream)7