Java Code Examples for org.apache.ws.commons.schema.XmlSchema#getExternals()
The following examples show how to use
org.apache.ws.commons.schema.XmlSchema#getExternals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WSDLSchemaManager.java From cxf with Apache License 2.0 | 6 votes |
public void addXmlSchemaImport(XmlSchema rootSchema, XmlSchema schema, File file) { // Make sure we haven't already imported the schema. String importNamespace = schema.getTargetNamespace(); boolean included = false; for (XmlSchemaExternal ext : rootSchema.getExternals()) { if (ext instanceof XmlSchemaImport) { XmlSchemaImport imp = (XmlSchemaImport)ext; if (imp.getNamespace().equals(importNamespace)) { included = true; break; } } } if (!included) { XmlSchemaImport importSchema = new XmlSchemaImport(rootSchema); if (!ignoreImports) { importSchema.setSchemaLocation(file.toURI().toString()); } importSchema.setNamespace(schema.getTargetNamespace()); } if (!importedSchemas.containsKey(file)) { importedSchemas.put(file, schema); } }
Example 2
Source File: WSDLParameter.java From cxf with Apache License 2.0 | 6 votes |
private static XmlSchemaElement findElement(XmlSchema xmlSchema, QName elName) { XmlSchemaElement schemaElement = null; schemaElement = xmlSchema.getElementByName(elName); if (schemaElement == null) { String prefix = definition.getPrefix(elName.getNamespaceURI()); QName name = new QName(elName.getNamespaceURI(), prefix + ":" + elName.getLocalPart(), prefix); schemaElement = xmlSchema.getElementByName(name); } if (schemaElement != null) { return schemaElement; } for (XmlSchemaExternal ext : xmlSchema.getExternals()) { if (!(ext instanceof XmlSchemaImport)) { schemaElement = findElement(ext.getSchema(), elName); if (schemaElement != null) { return schemaElement; } } } return schemaElement; }
Example 3
Source File: WSDLToCorbaHelper.java From cxf with Apache License 2.0 | 6 votes |
private XmlSchemaType findTypeInSchema(XmlSchema xmlSchema, QName typeName) { XmlSchemaType schemaType = null; if (xmlSchema.getElementByName(typeName) != null) { XmlSchemaElement schemaElement = xmlSchema.getElementByName(typeName); schemaType = schemaElement.getSchemaType(); } else if (xmlSchema.getTypeByName(typeName) != null) { schemaType = xmlSchema.getTypeByName(typeName); } if (schemaType != null) { return schemaType; } for (XmlSchemaExternal extSchema : xmlSchema.getExternals()) { if (!(extSchema instanceof XmlSchemaImport)) { schemaType = findTypeInSchema(extSchema.getSchema(), typeName); if (schemaType != null) { return schemaType; } } } return null; }
Example 4
Source File: WSDLToCorbaBinding.java From cxf with Apache License 2.0 | 6 votes |
private void addCorbaTypes(Definition definition) throws Exception { for (XmlSchema xmlSchemaTypes : xmlSchemaList.getXmlSchemas()) { for (XmlSchemaExternal ext : xmlSchemaTypes.getExternals()) { addCorbaTypes(ext.getSchema()); // REVISIT: This was preventing certain types from being added to the corba // typemap even when they are referenced from other parts of the wsdl. // // Should this add the corba types if it IS an instance of the XmlSchemaImport // (and not an XmlSchemaInclude or XmlSchemaRedefine)? //if (!(extSchema instanceof XmlSchemaImport)) { // addCorbaTypes(extSchema.getSchema()); //} } if (!W3CConstants.NU_SCHEMA_XSD.equals(xmlSchemaTypes.getTargetNamespace())) { addCorbaTypes(xmlSchemaTypes); } } }
Example 5
Source File: WSDLParameter.java From cxf with Apache License 2.0 | 5 votes |
private static XmlSchemaType findSchemaType(XmlSchema xmlSchema, QName typeName) { XmlSchemaType schemaType = xmlSchema.getTypeByName(typeName); // Endpoint reference types will give a null schemaType // here, so we need to // go through the list of imports to find the definition for // an Endpoint // reference type. if (schemaType == null) { for (XmlSchemaExternal ext : xmlSchema.getExternals()) { if (ext instanceof XmlSchemaImport) { XmlSchemaImport xmlImport = (XmlSchemaImport)ext; if (xmlImport.getNamespace().equals(typeName.getNamespaceURI())) { XmlSchema importSchema = xmlImport.getSchema(); schemaType = importSchema.getTypeByName(typeName); } else { schemaType = findSchemaType(ext.getSchema(), typeName); if (schemaType != null) { return schemaType; } } } } if (schemaType != null) { return schemaType; } } return schemaType; }
Example 6
Source File: WSDLUtils.java From cxf with Apache License 2.0 | 5 votes |
public static boolean isElementFormQualified(XmlSchema schema, QName type) { if (type != null) { String uri = type.getNamespaceURI(); if (uri.equals(schema.getTargetNamespace())) { return schema.getElementFormDefault() == XmlSchemaForm.QUALIFIED; } for (XmlSchemaExternal extSchema : schema.getExternals()) { return isElementFormQualified(extSchema.getSchema(), type); } } return false; }
Example 7
Source File: CorbaUtils.java From cxf with Apache License 2.0 | 5 votes |
private static boolean isElementFormQualified(XmlSchema schema, String uri) { if (uri.equals(schema.getTargetNamespace())) { return schema.getElementFormDefault() == XmlSchemaForm.QUALIFIED; } for (XmlSchemaExternal extSchema : schema.getExternals()) { return isElementFormQualified(extSchema.getSchema(), uri); } return false; }
Example 8
Source File: CorbaUtils.java From cxf with Apache License 2.0 | 5 votes |
private static boolean isAttributeFormQualified(XmlSchema schema, String uri) { if (uri.equals(schema.getTargetNamespace())) { return schema.getAttributeFormDefault() == XmlSchemaForm.QUALIFIED; } for (XmlSchemaExternal extSchema : schema.getExternals()) { return isAttributeFormQualified(extSchema.getSchema(), uri); } return false; }
Example 9
Source File: ReflectionServiceFactoryBean.java From cxf with Apache License 2.0 | 5 votes |
private boolean isExistImport(XmlSchema schema, String ns) { boolean isExist = false; for (XmlSchemaExternal ext : schema.getExternals()) { if (ext instanceof XmlSchemaImport) { XmlSchemaImport xsImport = (XmlSchemaImport)ext; if (xsImport.getNamespace().equals(ns)) { isExist = true; break; } } } return isExist; }
Example 10
Source File: XmlSchemaUtils.java From cxf with Apache License 2.0 | 5 votes |
/** * Is there an import for a particular namespace in a schema? * @param schema * @param namespaceUri */ public static boolean schemaImportsNamespace(XmlSchema schema, String namespaceUri) { List<XmlSchemaExternal> externals = schema.getExternals(); for (XmlSchemaExternal what : externals) { if (what instanceof XmlSchemaImport) { XmlSchemaImport imp = (XmlSchemaImport)what; // already there. if (namespaceUri.equals(imp.getNamespace())) { return true; } } } return false; }
Example 11
Source File: Stax2ValidationUtils.java From cxf with Apache License 2.0 | 4 votes |
/** * Create woodstox validator for a schema set. * * @throws XMLStreamException */ private XMLValidationSchema getValidator(Endpoint endpoint, ServiceInfo serviceInfo) throws XMLStreamException { synchronized (endpoint) { XMLValidationSchema ret = (XMLValidationSchema) endpoint.get(KEY); if (ret == null) { if (endpoint.containsKey(KEY)) { return null; } Map<String, Source> sources = new TreeMap<>(); for (SchemaInfo schemaInfo : serviceInfo.getSchemas()) { XmlSchema sch = schemaInfo.getSchema(); String uri = sch.getTargetNamespace(); if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(uri)) { continue; } if (sch.getTargetNamespace() == null && !sch.getExternals().isEmpty()) { for (XmlSchemaExternal xmlSchemaExternal : sch.getExternals()) { addSchema(sources, xmlSchemaExternal.getSchema(), getElement(xmlSchemaExternal.getSchema().getSourceURI())); } continue; } else if (sch.getTargetNamespace() == null) { throw new IllegalStateException("An Schema without imports must have a targetNamespace"); } addSchema(sources, sch, schemaInfo.getElement()); } try { // I don't think that we need the baseURI. Method method = multiSchemaFactory.getMethod("createSchema", String.class, Map.class); ret = (XMLValidationSchema) method.invoke(multiSchemaFactory.newInstance(), null, sources); endpoint.put(KEY, ret); } catch (Throwable t) { LOG.log(Level.INFO, "Problem loading schemas. Falling back to slower method.", ret); endpoint.put(KEY, null); } } return ret; } }