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 (particle instanceof XmlSchemaSequence || particle instanceof XmlSchemaAll) { XmlSchemaGroupBase xmlSchemaGroupBase = (XmlSchemaGroupBase)particle; Iterator iterator = xmlSchemaGroupBase.getItems().getIterator();
private static boolean containsAnonymousTypes(XmlSchemaComplexType ct) { XmlSchemaGroupBase particle = (XmlSchemaGroupBase)ct.getParticle(); if (particle == null) { return false; } XmlSchemaObjectCollection items = particle.getItems(); for (int i = 0; i < items.getCount(); i++) { XmlSchemaObject item = items.getItem(i); if (item instanceof XmlSchemaElement) { XmlSchemaElement el = (XmlSchemaElement) item; if (el.getSchemaTypeName() == null) return true; } else if (item instanceof XmlSchemaElement) { XmlSchemaComplexType el = (XmlSchemaComplexType) item; if (el.getParticle() != null) return true; } } return false; }
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? }
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? }
if (particle instanceof XmlSchemaSequence || particle instanceof XmlSchemaAll) { XmlSchemaGroupBase xmlSchemaGroupBase = (XmlSchemaGroupBase)particle; Iterator iterator = xmlSchemaGroupBase.getItems().getIterator();