private XmlSchema getSchema(XmlSchema parentSchema, String name) { for (Iterator iter = parentSchema.getIncludes().getIterator(); iter.hasNext();) { Object obj = iter.next(); if (obj instanceof XmlSchemaExternal) { XmlSchemaExternal extSchema = (XmlSchemaExternal)obj; if (extSchema.getSchemaLocation().endsWith(name)) { return extSchema.getSchema(); } else { XmlSchema schema = getSchema(extSchema.getSchema(), name); if (schema != null) { return schema; } } } } return null; }
private void updateSchemaLocation(XmlSchema schema) throws AxisFault { for (XmlSchemaExternal xmlSchemaExternal : schema.getExternals()) { XmlSchema s = xmlSchemaExternal.getSchema(); updateSchemaLocation(s, xmlSchemaExternal); } }
private void updateSchemaLocation(XmlSchema schema) throws AxisFault { for (XmlSchemaExternal xmlSchemaExternal : schema.getExternals()) { XmlSchema s = xmlSchemaExternal.getSchema(); updateSchemaLocation(s, xmlSchemaExternal); } }
private static void updateSchemaRefs(XmlSchema parentSchema, String name) { for (Iterator iter = parentSchema.getIncludes().getIterator(); iter.hasNext();) { Object obj = iter.next(); if (obj instanceof XmlSchemaExternal) { XmlSchemaExternal extSchema = (XmlSchemaExternal)obj; String location = extSchema.getSchemaLocation(); if (location.length() > 0 && location.indexOf(":/") < 0 && location.indexOf("?xsd=") < 0) { extSchema.setSchemaLocation(name + "?xsd=" + location); } if (extSchema.getSchema() != null) { updateSchemaRefs(extSchema.getSchema(), name); } } } }
/** * Adjust a single schema * * @param parentSchema * @param nameTable */ private void adjustSchemaName(XmlSchema parentSchema, Hashtable nameTable, Hashtable importedScheams, Hashtable sourceURIToNewLocationMap) { for (XmlSchemaExternal xmlSchemaExternal : parentSchema.getExternals()) { XmlSchema s = xmlSchemaExternal.getSchema(); adjustSchemaLocation(s, xmlSchemaExternal, nameTable, importedScheams, sourceURIToNewLocationMap); } }
/** * Adjust a single schema * * @param parentSchema * @param nameTable */ private void adjustSchemaName(XmlSchema parentSchema, Hashtable nameTable, Hashtable importedScheams, Hashtable sourceURIToNewLocationMap) { for (XmlSchemaExternal xmlSchemaExternal : parentSchema.getExternals()) { XmlSchema s = xmlSchemaExternal.getSchema(); adjustSchemaLocation(s, xmlSchemaExternal, nameTable, importedScheams, sourceURIToNewLocationMap); } }
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; }
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; }
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; }
private static void traverseSchemas(XmlSchema schema, HashMap map) { String key = schema.getTargetNamespace() + ":" + schema.getSourceURI(); if (map.containsKey(key)) { return; } map.put(key, schema); for (XmlSchemaExternal external : schema.getExternals()) { if (external instanceof XmlSchemaImport) { XmlSchema schema1 = external.getSchema(); if (schema1 != null) { traverseSchemas(schema1, map); } } if (external instanceof XmlSchemaInclude) { XmlSchema schema1 = external.getSchema(); if (schema1 != null) { traverseSchemas(schema1, map); } } } } }
private static void traverseSchemas(XmlSchema schema, HashMap map) { String key = schema.getTargetNamespace() + ":" + schema.getSourceURI(); if (map.containsKey(key)) { return; } map.put(key, schema); for (XmlSchemaExternal external : schema.getExternals()) { if (external instanceof XmlSchemaImport) { XmlSchema schema1 = external.getSchema(); if (schema1 != null) { traverseSchemas(schema1, map); } } if (external instanceof XmlSchemaInclude) { XmlSchema schema1 = external.getSchema(); if (schema1 != null) { traverseSchemas(schema1, map); } } } } }
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; }
/** * run 1 -calcualte unique names * * @param schemas */ private void calculateSchemaNames(List schemas, Hashtable nameTable, Hashtable sourceURIToNewLocationMap, boolean overrideAbsoluteAddress) { // first traversal - fill the hashtable for (int i = 0; i < schemas.size(); i++) { XmlSchema schema = (XmlSchema) schemas.get(i); for (XmlSchemaExternal externalSchema : schema.getExternals()) { if (externalSchema != null) { XmlSchema s = externalSchema.getSchema(); if (s != null && getScheamLocationWithDot( sourceURIToNewLocationMap, s) == null) { // insert the name into the table insertIntoNameTable(nameTable, s, sourceURIToNewLocationMap, overrideAbsoluteAddress); // recursively call the same procedure calculateSchemaNames(Arrays .asList(new XmlSchema[] { s }), nameTable, sourceURIToNewLocationMap, overrideAbsoluteAddress); } } } } }
/** * run 1 -calcualte unique names * * @param schemas */ private void calculateSchemaNames(List schemas, Hashtable nameTable, Hashtable sourceURIToNewLocationMap, boolean overrideAbsoluteAddress) { // first traversal - fill the hashtable for (int i = 0; i < schemas.size(); i++) { XmlSchema schema = (XmlSchema) schemas.get(i); for (XmlSchemaExternal externalSchema : schema.getExternals()) { if (externalSchema != null) { XmlSchema s = externalSchema.getSchema(); if (s != null && getScheamLocationWithDot( sourceURIToNewLocationMap, s) == null) { // insert the name into the table insertIntoNameTable(nameTable, s, sourceURIToNewLocationMap, overrideAbsoluteAddress); // recursively call the same procedure calculateSchemaNames(Arrays .asList(new XmlSchema[] { s }), nameTable, sourceURIToNewLocationMap, overrideAbsoluteAddress); } } } } }
Object o = includes.next(); XmlSchemaExternal externalSchema = (XmlSchemaExternal)o; XmlSchema schema = externalSchema.getSchema(); if(schema != null )
XmlSchema schema = externalSchema.getSchema(); if(schema != null )
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); } } }
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; }
if (externalComponent instanceof XmlSchemaExternal) { XmlSchemaExternal xmlSchemaExternal = (XmlSchemaExternal)externalComponent; XmlSchema schema1 = xmlSchemaExternal.getSchema(); if (schema1 != null) { String sourceURI = getAbsoluteSchemaURL(schema1.getSourceURI());
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; }