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; } }
if (element == null) { for (Iterator includedItems = includes.getIterator(); includedItems .hasNext();) {
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); } } } }
if (attribute == null) { for (Iterator includedItems = includes.getIterator(); includedItems .hasNext();) {
if (attribute == null) { for (Iterator includedItems = includes.getIterator(); includedItems .hasNext();) {
if (element == null) { for (Iterator includedItems = includes.getIterator(); includedItems .hasNext();) {
if (type == null) { for (Iterator includedItems = includes.getIterator(); includedItems .hasNext();) {
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; }
schema.write(outStream); for (Iterator<?> i = schema.getIncludes().getIterator(); i.hasNext();) { XmlSchemaObject obj = (XmlSchemaObject)i.next(); XmlSchema ext = null;
Iterator includes = includeColl.getIterator(); while(includes.hasNext()) { Object o = includes.next();
private static <T extends XmlSchemaObject> T getXmlSchemaObject(XmlSchema schema, QName name, Class<T> type) { if (schema != null) { XmlSchemaObject object = null; if (type == XmlSchemaElement.class) { object = schema.getElementByName(name); } else if (type == XmlSchemaType.class) { object = schema.getTypeByName(name); } if (object != null) { return type.cast(object); } for (Iterator<?> i = schema.getIncludes().getIterator(); i.hasNext();) { XmlSchemaObject obj = (XmlSchemaObject)i.next(); XmlSchema ext = null; if (obj instanceof XmlSchemaInclude) { ext = ((XmlSchemaInclude)obj).getSchema(); } if (obj instanceof XmlSchemaImport) { ext = ((XmlSchemaImport)obj).getSchema(); } object = getXmlSchemaObject(ext, name, type); if (object != null) { return type.cast(object); } } } return null; }
private static <T extends XmlSchemaObject> T getXmlSchemaObject(XmlSchema schema, QName name, Class<T> type) { if (schema != null) { XmlSchemaObject object = null; if (type == XmlSchemaElement.class) { object = schema.getElementByName(name); } else if (type == XmlSchemaType.class) { object = schema.getTypeByName(name); } if (object != null) { return type.cast(object); } for (Iterator<?> i = schema.getIncludes().getIterator(); i.hasNext();) { XmlSchemaObject obj = (XmlSchemaObject)i.next(); XmlSchema ext = null; if (obj instanceof XmlSchemaInclude) { ext = ((XmlSchemaInclude)obj).getSchema(); } if (obj instanceof XmlSchemaImport) { ext = ((XmlSchemaImport)obj).getSchema(); } object = getXmlSchemaObject(ext, name, type); if (object != null) { return type.cast(object); } } } return null; }
private void createMessageParts(MessageInfo info, XmlSchemaElement el) { if (el == null) { return; } XmlSchemaComplexType type = (XmlSchemaComplexType) el.getSchemaType(); if (type == null) { return; } if (type.getParticle() instanceof XmlSchemaSequence) { XmlSchemaSequence seq = (XmlSchemaSequence) type.getParticle(); XmlSchemaObjectCollection col = seq.getItems(); for (Iterator itr = col.getIterator(); itr.hasNext();) { XmlSchemaObject schemaObj = (XmlSchemaObject) itr.next(); if (schemaObj instanceof XmlSchemaElement) { createMessagePart(info, (XmlSchemaElement) schemaObj, el.getQName()); } } } }
if (particle instanceof XmlSchemaSequence || particle instanceof XmlSchemaAll) { XmlSchemaGroupBase xmlSchemaGroupBase = (XmlSchemaGroupBase)particle; Iterator iterator = xmlSchemaGroupBase.getItems().getIterator();
XmlSchemaSequence sequence = (XmlSchemaSequence) type.getParticle(); List<XSDType> sequenceTypes = new ArrayList<>(); Iterator<XmlSchemaObject> iter = sequence.getItems().getIterator(); while (iter.hasNext()) { XmlSchemaObject o = iter.next();
public void processXMLSchemaObject(String toNamespace, XmlSchemaObject obj, XmlSchemaObject fixUpObj){ if (obj instanceof XmlSchemaComplexType){ processXMLSchemaObject(toNamespace, ((XmlSchemaComplexType)obj).getParticle(), fixUpObj); processXMLSchemaObject(toNamespace, ((XmlSchemaComplexType)obj).getContentModel(), fixUpObj); } else if (obj instanceof XmlSchemaComplexContent){ processXMLSchemaObject(toNamespace, ((XmlSchemaComplexContent)obj).getContent(), fixUpObj); } else if (obj instanceof XmlSchemaElement){ XmlSchemaElement element = (XmlSchemaElement)obj; if(element.getSchemaType() == fixUpObj){ QName name = element.getSchemaTypeName(); QName newName = new QName(toNamespace, name.getLocalPart()); element.setSchemaTypeName(newName); } ((XmlSchemaElement)obj).getSchemaType(); } else if (obj instanceof XmlSchemaGroupBase){ XmlSchemaObjectCollection items = ((XmlSchemaGroupBase)obj).getItems(); Iterator<XmlSchemaObject> iter = items.getIterator(); while(iter.hasNext()){ processXMLSchemaObject(toNamespace, iter.next(), fixUpObj); } } else if (obj instanceof XmlSchemaComplexContentExtension){ XmlSchemaComplexContentExtension extension = (XmlSchemaComplexContentExtension)obj; QName name = extension.getBaseTypeName(); QName newName = new QName(toNamespace, name.getLocalPart()); extension.setBaseTypeName(newName); } // TODO - what other structure items will be generated by JAXB? }
XmlSchemaObjectCollection includes = schema.getIncludes(); if (includes != null) { for (Iterator iter = includes.getIterator(); iter.hasNext();) { Object externalComponent = iter.next(); if (externalComponent instanceof XmlSchemaExternal) {
public void processXMLSchemaObject(String toNamespace, XmlSchemaObject obj, XmlSchemaObject fixUpObj){ if (obj instanceof XmlSchemaComplexType){ processXMLSchemaObject(toNamespace, ((XmlSchemaComplexType)obj).getParticle(), fixUpObj); processXMLSchemaObject(toNamespace, ((XmlSchemaComplexType)obj).getContentModel(), fixUpObj); } else if (obj instanceof XmlSchemaComplexContent){ processXMLSchemaObject(toNamespace, ((XmlSchemaComplexContent)obj).getContent(), fixUpObj); } else if (obj instanceof XmlSchemaElement){ XmlSchemaElement element = (XmlSchemaElement)obj; if(element.getSchemaType() == fixUpObj){ QName name = element.getSchemaTypeName(); QName newName = new QName(toNamespace, name.getLocalPart()); element.setSchemaTypeName(newName); } ((XmlSchemaElement)obj).getSchemaType(); } else if (obj instanceof XmlSchemaGroupBase){ XmlSchemaObjectCollection items = ((XmlSchemaGroupBase)obj).getItems(); Iterator<XmlSchemaObject> iter = items.getIterator(); while(iter.hasNext()){ processXMLSchemaObject(toNamespace, iter.next(), fixUpObj); } } else if (obj instanceof XmlSchemaComplexContentExtension){ XmlSchemaComplexContentExtension extension = (XmlSchemaComplexContentExtension)obj; QName name = extension.getBaseTypeName(); QName newName = new QName(toNamespace, name.getLocalPart()); extension.setBaseTypeName(newName); } // TODO - what other structure items will be generated by JAXB? }
/** * 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); }
.getIterator(); i.hasNext();) { XmlSchemaObject subAnnotation = i.next(); if (subAnnotation instanceof XmlSchemaAppInfo) {