Package org.apache.tuscany.sca.xsd

Examples of org.apache.tuscany.sca.xsd.XSDefinition


    }

    private XmlSchemaType getType(QName typeName) {
        XmlSchemaType type = wsdlDefinition.getXmlSchemaType(typeName);
        if (type == null) {
            XSDefinition definition = xsdFactory.createXSDefinition();
            definition.setUnresolved(true);
            definition.setNamespace(typeName.getNamespaceURI());
            definition = resolver.resolveModel(XSDefinition.class, definition);
            if (definition.getSchema() != null) {
                type = definition.getSchema().getTypeByName(typeName);
            }
        }
        return type;
    }
View Full Code Here


                        wsdlDefinition.setUnresolved(false);
                        wsdlDefinition.setDefinition(null);
                    }
                    if (XSD.equals(reader.getName())) {
                        String tns = reader.getAttributeValue(null, "targetNamespace");
                        XSDefinition xsd = xsdFactory.createXSDefinition();
                        xsd.setUnresolved(true);
                        xsd.setNamespace(tns);
                        xsd.setLocation(URI.create(doc.toURI() + "#" + index));
                        index++;
                        // The definition is marked as resolved but not loaded
                        xsd.setUnresolved(false);
                        xsd.setSchema(null);
                        wsdlDefinition.getXmlSchemas().add(xsd);
                    }
                }
                if (reader.hasNext()) {
                    eventType = reader.next();
View Full Code Here

                        element = ((UnknownExtensibilityElement)extElement).getElement();
                    }
                }
                if (element != null) {
                    Document doc = promote(element);
                    XSDefinition xsDefinition = xsdFactory.createXSDefinition();
                    xsDefinition.setUnresolved(true);
                    xsDefinition.setNamespace(element.getAttribute("targetNamespace"));
                    xsDefinition.setDocument(doc);
                    xsDefinition.setLocation(URI.create(doc.getDocumentURI() + "#" + index));
                    XSDefinition resolved =
                        contribution.getModelResolver().resolveModel(XSDefinition.class, xsDefinition);
                    if (resolved != null && !resolved.isUnresolved()) {
                        if (!wsdlDefinition.getXmlSchemas().contains(resolved)) {
                            // Don't add resolved because it may be an aggregate that
                            // contains more than we need.  The resolver will have
                            // set the specific schema we need into unresolved.
                            wsdlDefinition.getXmlSchemas().add(xsDefinition);
View Full Code Here

    private XmlSchemaElement getElement(QName elementName) {

        XmlSchemaElement element = wsdlDefinition.getXmlSchemaElement(elementName);
        if (element == null) {
            XSDefinition definition = xsdFactory.createXSDefinition();
            definition.setUnresolved(true);
            definition.setNamespace(elementName.getNamespaceURI());
            definition = resolver.resolveModel(XSDefinition.class, definition);
            if (definition.getSchema() != null) {
                element = definition.getSchema().getElementByName(elementName);
            }
        }
        return element;
    }
View Full Code Here

    }

    private XmlSchemaType getType(QName typeName) {
        XmlSchemaType type = wsdlDefinition.getXmlSchemaType(typeName);
        if (type == null) {
            XSDefinition definition = xsdFactory.createXSDefinition();
            definition.setUnresolved(true);
            definition.setNamespace(typeName.getNamespaceURI());
            definition = resolver.resolveModel(XSDefinition.class, definition);
            if (definition.getSchema() != null) {
                type = definition.getSchema().getTypeByName(typeName);
            }
        }
        return type;
    }
View Full Code Here

            Map<Element, Map<String, String>> prefixMaps = new HashMap<Element, Map<String, String>>();
            for (Map.Entry<QName, List<ElementInfo>> entry: wrappers.entrySet()) {
                String targetNS = entry.getKey().getNamespaceURI();
                Document schemaDoc = null;
                Element schema = null;
                XSDefinition xsDef = wrapperXSDs.get(targetNS);
                if (xsDef != null) {
                    schemaDoc = xsDef.getDocument();
                    schema = schemaDoc.getDocumentElement();
                } else {
                    schemaDoc = createDocument();
                    schema = schemaDoc.createElementNS(SCHEMA_NS, "xs:schema");
                    // The elementFormDefault should be set to unqualified, see TUSCANY-2388
                    schema.setAttribute("elementFormDefault", "unqualified");
                    schema.setAttribute("attributeFormDefault", "qualified");
                    schema.setAttribute("targetNamespace", targetNS);
                    schema.setAttributeNS(XMLNS_NS, "xmlns:xs", SCHEMA_NS);
                    schemaDoc.appendChild(schema);
                    Schema schemaExt = createSchemaExt(definition);
                    schemaExt.setElement(schema);
                    prefixMaps.put(schema, new HashMap<String, String>());
                    xsDef = xsdFactory.createXSDefinition();
                    xsDef.setUnresolved(true);
                    xsDef.setNamespace(targetNS);
                    xsDef.setDocument(schemaDoc);
                    // TUSCANY-2465: Set the system id to avoid schema conflict
                    xsDef.setLocation(URI.create("xsd_" + index + ".xsd"));
                    index++;
                    wrapperXSDs.put(targetNS, xsDef);
                }
                Element wrapper = schemaDoc.createElementNS(SCHEMA_NS, "xs:element");
                schema.appendChild(wrapper);
View Full Code Here

        DOMImplementationLS ls = (DOMImplementationLS)impl.getFeature("LS", "3.0");
        LSParser parser = ls.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, SCHEMA_NS);
        LSInput input = ls.createLSInput();
        input.setCharacterStream(new StringReader(schema));
        Document document = parser.parse(input);
        XSDefinition definition = factory.createXSDefinition();
        definition.setUnresolved(true);
        definition.setDocument(document);
        definition.setNamespace(ns);
        definitions.add(definition);
    }
View Full Code Here

    private void addResolvedXSDs(List<XSDefinition> definitions,
                                 XSDFactory factory,
                                 ModelResolver resolver,
                                 Map<String, List<Type>> map) {
        for (Map.Entry<String, List<Type>> entry : map.entrySet()) {
            XSDefinition definition = factory.createXSDefinition();
            definition.setUnresolved(true);
            definition.setNamespace(entry.getKey());
            //FIXME: set location URI
            XSDefinition resolved = resolver.resolveModel(XSDefinition.class, definition);
            if (resolved.getSchema() == null) {
                //FIXME: create a checked exception and propagate it back up to the activator
                throw new RuntimeException("No XSD found for namespace " + entry.getKey());
            }
            // make sure all the required types are defined in the resolved schema
            for (Type type : entry.getValue()) {
                String name = xsdHelper.getLocalName(type);
                QName typeName = null;
                if (name.endsWith("_._type")) {
                    // FIXME: Anonymous tyype
                    name = name.substring(0, name.length() - "_._type".length());
                    typeName = new QName(type.getURI(), name);
                    if (resolved.getXmlSchemaElement(typeName) == null) {
                        //FIXME: create a checked exception and propagate it back up to the activator
                        throw new RuntimeException("No XSD found for " + typeName.toString());
                    }
                } else {
                    typeName = new QName(type.getURI(), name);
                    if (resolved.getXmlSchemaType(typeName) == null) {
                        //FIXME: create a checked exception and propagate it back up to the activator
                        throw new RuntimeException("No XSD found for " + typeName.toString());
                    }
                }
View Full Code Here

                //throw ce;
            }
        } else {
            String ns = importSDO.getNamespace();
            if (ns != null) {
                XSDefinition xsd = xsdFactory.createXSDefinition();
                xsd.setUnresolved(true);
                xsd.setNamespace(ns);
                xsd = resolver.resolveModel(XSDefinition.class, xsd);
                if (!xsd.isUnresolved()) {
                    XSDHelper xsdHelper = helperContext.getXSDHelper();
                    xsdHelper.define(xsd.getLocation().toString());
                }
            }
        }
    }
View Full Code Here

        schemaCollection.setSchemaResolver(new URIResolverImpl(contribution));
        this.factory = new DefaultXSDFactory();
    }

    public void addModel(Object resolved) {
        XSDefinition definition = (XSDefinition)resolved;
        List<XSDefinition> list = map.get(definition.getNamespace());
        if (list == null) {
            list = new ArrayList<XSDefinition>();
            map.put(definition.getNamespace(), list);
        }
        list.add(definition);
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.xsd.XSDefinition

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.