private static XmlSchemaObjectCollection getSchemaObjectsFromComplexType(XmlSchemaComplexType schemaComplexType) { XmlSchemaObjectCollection collection = new XmlSchemaObjectCollection(); XmlSchemaSequence sequence = (XmlSchemaSequence) schemaComplexType.getParticle(); if (sequence != null) { XmlSchemaObjectCollection seqItems = sequence.getItems(); int c = seqItems.getCount(); for (int i = 0; i < c; i++) { // add elements collection.add(seqItems.getItem(i)); } } XmlSchemaObjectCollection attrItems = schemaComplexType.getAttributes(); int c = attrItems.getCount(); for (int i = 0; i < c; i++) { // add attributes collection.add(attrItems.getItem(i)); } return collection; }
private void inlineIncludes(XmlSchema schema, Set<XmlSchema> processedIncludes, Set<XmlSchema> processedImports) { processedIncludes.add(schema); XmlSchemaObjectCollection schemaItems = schema.getItems(); for (int i = 0; i < schemaItems.getCount(); i++) { XmlSchemaObject schemaObject = schemaItems.getItem(i); if (schemaObject instanceof XmlSchemaInclude) { XmlSchema includedSchema = ((XmlSchemaInclude) schemaObject).getSchema(); if (!processedIncludes.contains(includedSchema)) { inlineIncludes(includedSchema, processedIncludes, processedImports); findImports(includedSchema, processedImports, processedIncludes); XmlSchemaObjectCollection includeItems = includedSchema.getItems(); for (int j = 0; j < includeItems.getCount(); j++) { XmlSchemaObject includedItem = includeItems.getItem(j); schemaItems.add(includedItem); } } // remove the <include/> schemaItems.removeAt(i); i--; } } }
private static List<XmlSchemaElement> getNestedElements(final XmlSchemaComplexType complexType) { final List<XmlSchemaElement> elements = new ArrayList<XmlSchemaElement>(); final XmlSchemaParticle particle = complexType.getParticle(); if (particle instanceof XmlSchemaElement) { final XmlSchemaElement element = (XmlSchemaElement) particle; elements.add(element); } else if (particle instanceof XmlSchemaGroupBase && !(particle instanceof XmlSchemaChoice)) { final XmlSchemaGroupBase groupBase = (XmlSchemaGroupBase) particle; for (final Iterator iterator = groupBase.getItems().getIterator(); iterator.hasNext(); ) { final XmlSchemaParticle child = (XmlSchemaParticle) iterator.next(); if (child instanceof XmlSchemaElement) { final XmlSchemaElement element = (XmlSchemaElement) child; elements.add(element); } } } else { // ignore all other types... you can have these other types, but JAX-RPC doesn't support them } return elements; } }
/** * Adds the given parameter to the complex type. * @param complexType The complex type which the attribute will be added to * @param name The name of the attribute * @param xsdType The type of the attribute */ @SuppressWarnings("unchecked") private static void addAttributeToComplexType(XmlSchemaComplexType complexType, String name, QName xsdType) { XmlSchemaAttribute attr = new XmlSchemaAttribute(); attr.setName(name); attr.setSchemaTypeName(xsdType); attr.setUse(new XmlSchemaUse("optional")); XmlSchemaAttribute tmpAttr; for (Iterator<XmlSchemaAttribute> itr = complexType.getAttributes().getIterator(); itr.hasNext();) { tmpAttr = itr.next(); if (tmpAttr.getName().equals(attr.getName())) { /* current attribute is already set, nothing more to do */ return; } } complexType.getAttributes().add(attr); }
choice.items.add(seq); } else if (el.getLocalName().equals("element")) { XmlSchemaElement element = handleElement(schema, el, schemaEl, false); choice.items.add(element); } else if (el.getLocalName().equals("group")) { XmlSchemaGroupRef group = handleGroupRef(schema, el, schemaEl); choice.items.add(group); } else if (el.getLocalName().equals("choice")) { XmlSchemaChoice choiceItem = handleChoice(schema, el, schemaEl); choice.items.add(choiceItem); } else if (el.getLocalName().equals("any")) { XmlSchemaAny any = handleAny(schema, el, schemaEl); choice.items.add(any); } else if (el.getLocalName().equals("annotation")) { XmlSchemaAnnotation annotation = handleAnnotation(el);
public void fixUpMovedTypeReferences(String fromNamespace, String toNamespace, XmlSchemaObject fixUpObj, List<XmlSchema> relatedSchema){ if (!(fixUpObj instanceof XmlSchemaComplexType)){ return; } for (XmlSchema schema : relatedSchema){ int importRemoveIndex = -1; for (int i = 0; i < schema.getItems().getCount(); i++){ XmlSchemaObject obj = schema.getItems().getItem(i); processXMLSchemaObject(toNamespace, obj, fixUpObj); // remove FROM imports if (obj instanceof XmlSchemaImport && ((XmlSchemaImport)obj).getNamespace().equals(fromNamespace)){ importRemoveIndex = i; } } if (importRemoveIndex >= 0){ schema.getItems().removeAt(importRemoveIndex); } } }
/** * Creates new XmlSchemaGroupBase */ public XmlSchemaGroupBase() { items = new XmlSchemaObjectCollection(); }
XmlSchemaObjectCollection content = new XmlSchemaObjectCollection(); XmlSchemaAppInfo appInfoObj; XmlSchemaDocumentation docsObj; content.add(appInfoObj); content.add(docsObj);
private static XmlSchemaComplexType getRowNameBasedSchemaComplexType( XmlSchemaComplexType wrapperSchemaComplexType) { return (((XmlSchemaComplexType) ((XmlSchemaElement) ((XmlSchemaSequence) wrapperSchemaComplexType .getParticle()).getItems().getItem(0)).getSchemaType())); }
protected static boolean hasAttributes(XmlSchemaComplexType complexType) { // Now lets see if we have any attributes... // This should probably look at the restricted and substitute types too. if (complexType.getAnyAttribute() != null || complexType.getAttributes().getCount() > 0) return true; else return false; }
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); } } } }
List<XmlSchemaObject> movedItems = new ArrayList<XmlSchemaObject>(); Iterator<XmlSchemaObject> iter = fromItems.getIterator(); while(iter.hasNext()){ toItems.add(obj); movedItems.add(obj);
choice.items.add(seq); } else if (el.getLocalName().equals("element")) { XmlSchemaElement element = handleElement(schema, el, schemaEl, false); choice.items.add(element); } else if (el.getLocalName().equals("group")) { XmlSchemaGroupRef group = handleGroupRef(schema, el, schemaEl); choice.items.add(group); } else if (el.getLocalName().equals("choice")) { XmlSchemaChoice choiceItem = handleChoice(schema, el, schemaEl); choice.items.add(choiceItem); } else if (el.getLocalName().equals("any")) { XmlSchemaAny any = handleAny(schema, el, schemaEl); choice.items.add(any); } else if (el.getLocalName().equals("annotation")) { XmlSchemaAnnotation annotation = handleAnnotation(el);
public void fixUpMovedTypeReferences(String fromNamespace, String toNamespace, XmlSchemaObject fixUpObj, List<XmlSchema> relatedSchema){ if (!(fixUpObj instanceof XmlSchemaComplexType)){ return; } for (XmlSchema schema : relatedSchema){ int importRemoveIndex = -1; for (int i = 0; i < schema.getItems().getCount(); i++){ XmlSchemaObject obj = schema.getItems().getItem(i); processXMLSchemaObject(toNamespace, obj, fixUpObj); // remove FROM imports if (obj instanceof XmlSchemaImport && ((XmlSchemaImport)obj).getNamespace().equals(fromNamespace)){ importRemoveIndex = i; } } if (importRemoveIndex >= 0){ schema.getItems().removeAt(importRemoveIndex); } } }
/** * Creates new XmlSchemaAttributeGroup */ public XmlSchemaAttributeGroup() { attributes = new XmlSchemaObjectCollection(); }
XmlSchemaObjectCollection content = new XmlSchemaObjectCollection(); XmlSchemaAppInfo appInfoObj; XmlSchemaDocumentation docsObj; content.add(appInfoObj); content.add(docsObj);
private static String getResultRowName(XmlSchemaComplexType wrapperSchemaComplexType) { return ((XmlSchemaElement) ((XmlSchemaSequence) wrapperSchemaComplexType .getParticle()).getItems().getItem(0)).getName(); }
if (attribute == null) { for (Iterator includedItems = includes.getIterator(); includedItems .hasNext();) {