Search in sources :

Example 1 with ResourceManagerWSDLLocator

use of org.apache.cxf.wsdl11.ResourceManagerWSDLLocator in project cxf by apache.

the class WSDLGetUtils method readXSDDocument.

/**
 * Read the schema file and return as a Document object.
 *
 * @param bus CXF's hub for access to internal constructs
 * @param xsd name of xsd file to be read
 * @param smp a map of known xsd SchemaReference objects
 * @param base the request URL
 * @return Document
 * @throws XMLStreamException
 */
protected Document readXSDDocument(Bus bus, String xsd, Map<String, SchemaReference> smp, String base) throws XMLStreamException {
    Document doc = null;
    SchemaReference si = lookupSchemaReference(bus, xsd, smp, base);
    String uri = si.getReferencedSchema().getDocumentBaseURI();
    uri = resolveWithCatalogs(OASISCatalogManager.getCatalogManager(bus), uri, si.getReferencedSchema().getDocumentBaseURI());
    if (uri == null) {
        uri = si.getReferencedSchema().getDocumentBaseURI();
    }
    ResourceManagerWSDLLocator rml = new ResourceManagerWSDLLocator(uri, bus);
    InputSource src = rml.getBaseInputSource();
    if (src.getByteStream() != null || src.getCharacterStream() != null) {
        doc = StaxUtils.read(src);
    } else {
        // last resort lets try for the referenced schema itself.
        // its not thread safe if we use the same document
        doc = StaxUtils.read(new DOMSource(si.getReferencedSchema().getElement().getOwnerDocument()));
    }
    return doc;
}
Also used : SchemaReference(javax.wsdl.extensions.schema.SchemaReference) InputSource(org.xml.sax.InputSource) DOMSource(javax.xml.transform.dom.DOMSource) ResourceManagerWSDLLocator(org.apache.cxf.wsdl11.ResourceManagerWSDLLocator) Document(org.w3c.dom.Document)

Aggregations

SchemaReference (javax.wsdl.extensions.schema.SchemaReference)1 DOMSource (javax.xml.transform.dom.DOMSource)1 ResourceManagerWSDLLocator (org.apache.cxf.wsdl11.ResourceManagerWSDLLocator)1 Document (org.w3c.dom.Document)1 InputSource (org.xml.sax.InputSource)1