for (Iterator itr = schema.getQNamePrefixToNamespaceMap().entrySet().iterator(); itr.hasNext(); ) { Map.Entry entry = (Map.Entry) itr.next(); namespaces.declarePrefix("", schema.getTargetNamespace()); root = XSDFactory.eINSTANCE.createXSDElementDeclaration(); root.setName(name.getLocalPart()); root.setTargetNamespace(name.getNamespaceURI()); root.setTypeDefinition(type); String local = attribute.getName(); if ((entry.encoding.getAttributeNS(ns, local) != null) && !"".equals(entry.encoding.getAttributeNS(ns, local))) { continue; entry.encoding.setAttributeNodeNS(attr); XSDParticle particle = (XSDParticle) tuple[0]; XSDElementDeclaration child = (XSDElementDeclaration) particle.getContent(); if (particle.getMinOccurs() == 0) { if (particle.isSetMaxOccurs()) { maxOccurs = particle.getMaxOccurs(); } else {
for (Iterator itr = children.iterator(); itr.hasNext(); ) { XSDParticle particle = (XSDParticle) itr.next(); XSDElementDeclaration child = (XSDElementDeclaration) particle.getContent(); if (child.isElementDeclarationReference()) { child = child.getResolvedElementDeclaration(); comment.appendChild( encoder.getDocument().createTextNode(v.next().toString())); XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle(); XSDFactory.eINSTANCE.createXSDElementDeclaration(); elementDecl.setTargetNamespace(Encoder.COMMENT.getNamespaceURI()); elementDecl.setName(Encoder.COMMENT.getLocalPart()); elementDecl.setElement(comment); particle.setContent(elementDecl); particles.put(name, particle); .resolveElementDeclaration( name.getNamespaceURI(), name.getLocalPart()); XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle(); XSDElementDeclaration wrapper = XSDFactory.eINSTANCE.createXSDElementDeclaration(); wrapper.setResolvedElementDeclaration(elementDecl); particle.setContent(wrapper);
decl = XSDFactory.eINSTANCE.createXSDAttributeDeclaration(); decl.setName(attQName.getLocalPart()); decl.setTargetNamespace(attQName.getNamespaceURI()); (XSDSimpleTypeDefinition) XSDUtil.getSchemaForSchema(XSDUtil.SCHEMA_FOR_SCHEMA_URI_2001) .getSimpleTypeIdMap() .get("string");
@SuppressWarnings("unchecked") protected XSDSchema xsd(SimpleFeatureType simpleFeatureType) throws IOException { XSDFactory factory = XSDFactory.eINSTANCE; XSDSchema xsd = factory.createXSDSchema(); xsd.setSchemaForSchemaQNamePrefix("xsd"); xsd.getQNamePrefixToNamespaceMap().put("xsd", XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001); xsd.setElementFormDefault(XSDForm.get(XSDForm.QUALIFIED)); XSDImport gml = factory.createXSDImport(); gml.setNamespace(gmlNamespace); gml.setSchemaLocation(baseURL.toString() + "/" + gmlLocation); gml.setResolvedSchema(gmlConfiguration.getXSD().getSchema()); xsd.getContents().add(gml); xsd.getQNamePrefixToNamespaceMap().put("gml", gmlNamespace); xsd.getQNamePrefixToNamespaceMap().put("gml", "http://www.opengis.net/gml"); XSDElementDeclaration element = factory.createXSDElementDeclaration(); element.setName(simpleFeatureType.getTypeName()); XSDElementDeclaration _FEATURE = xsd.resolveElementDeclaration(gmlNamespace, "_Feature"); element.setSubstitutionGroupAffiliation(_FEATURE); element.setTypeDefinition(featureType); xsd.getContents().add(element); xsd.updateElement(); return xsd;
XSDParticle particle(Attribute att) { XSDFactory factory = XSDFactory.eINSTANCE; AttributeType attType = att.getType(); XSDTypeDefinition xsdType = schemaIndex.getTypeDefinition( new QName( attType.getName().getNamespaceURI(), attType.getName().getLocalPart())); XSDElementDeclaration element = factory.createXSDElementDeclaration(); element.setName(att.getName().getLocalPart()); element.setTargetNamespace(att.getName().getNamespaceURI()); element.setTypeDefinition(xsdType); XSDParticle particle = factory.createXSDParticle(); particle.setContent(element); return particle; } }
/*{@link */XSDComplexTypeDefinition/*}*/ simpleRecursiveComplexTypeDefinition = xsdFactory.createXSDComplexTypeDefinition(); simpleRecursiveComplexTypeDefinition./*{@link XSDNamedComponent#getName */setName/*}*/("SimpleRecursiveComplexTypeDefinition"); simpleRecursiveComplexTypeDefinition./*{@link XSDComplexTypeDefinition#setAbstract */setAbstract/*}*/(false); simpleRecursiveComplexTypeDefinition./*{@link XSDComplexTypeDefinition#getBlock */getBlock/*}*/().add(/*{@link */XSDProhibitedSubstitutions/*}*/.ALL_LITERAL); simpleRecursiveComplexTypeDefinition./*{@link XSDComplexTypeDefinition#getLexicalFinal */getLexicalFinal/*}*/().add(/*{@link */XSDComplexFinal/*}*/.ALL_LITERAL); simpleRecursiveComplexTypeDefinition./*{@link XSDComplexTypeDefinition#setDerivationMethod */setDerivationMethod/*}*/(/*{@link */XSDDerivationMethod/*}*/.RESTRICTION_LITERAL); simpleRecursiveComplexTypeDefinition./*{@link XSDComplexTypeDefinition#setMixed */setMixed/*}*/(true); /*{@link */XSDAnnotation/*}*/ annotation = xsdFactory.createXSDAnnotation(); simpleRecursiveComplexTypeDefinition./*{@link XSDComplexTypeDefinition#setAnnotation */setAnnotation/*}*/(annotation); /*{@link */XSDModelGroupDefinition/*}*/ simpleRecursiveModelGroupDefinitionReference = xsdFactory.createXSDModelGroupDefinition(); simpleRecursiveModelGroupDefinitionReference./*{@link XSDModelGroupDefinition#setResolvedModelGroupDefinition */setResolvedModelGroupDefinition/*}*/ (prototypeSchema./*{@link XSDConcreteComponent#resolveModelGroupDefinition(String) */resolveModelGroupDefinition/*}*/("simpleRecursiveModelGroupDefinition")); /*{@link */XSDParticle/*}*/ modelGroupParticle = xsdFactory.createXSDParticle(); modelGroupParticle./*{@link XSDParticle#setContent */setContent/*}*/(simpleRecursiveModelGroupDefinitionReference); simpleRecursiveComplexTypeDefinition./*{@link XSDComplexTypeDefinition#setContent */setContent/*}*/(modelGroupParticle); /*{@link */XSDAttributeDeclaration/*}*/ simpleAttributeDeclarationReference = xsdFactory.createXSDAttributeDeclaration(); simpleAttributeDeclarationReference./*{@link XSDAttributeDeclaration#setResolvedAttributeDeclaration */setResolvedAttributeDeclaration/*}*/ (prototypeSchema./*{@link XSDConcreteComponent#resolveAttributeDeclaration */resolveAttributeDeclaration/*}*/("simpleAttributeDeclaration")); /*{@link */XSDAttributeUse/*}*/ simpleAttributeUse = xsdFactory.createXSDAttributeUse(); simpleAttributeUse./*{@link XSDAttributeUse#setContent */setContent/*}*/(simpleAttributeDeclarationReference); simpleAttributeUse./*{@link XSDAttributeUse#setUse */setUse/*}*/(/*{@link */XSDAttributeUseCategory/*}*/.OPTIONAL_LITERAL); simpleRecursiveComplexTypeDefinition./*{@link XSDComplexTypeDefinition#getAttributeContents */getAttributeContents/*}*/().add(simpleAttributeUse); /*{@link */XSDAttributeGroupDefinition/*}*/ simpleAttributeGroupDefinitionReference = xsdFactory.createXSDAttributeGroupDefinition(); simpleAttributeGroupDefinitionReference./*{@link XSDAttributeGroupDefinition#setResolvedAttributeGroupDefinition */setResolvedAttributeGroupDefinition/*}*/ (prototypeSchema./*{@link XSDConcreteComponent#resolveAttributeGroupDefinition(String) */resolveAttributeGroupDefinition/*}*/("simpleAttributeGroupDefinition"));
if (element.getLocalName().equals("schema") && /*{@link */XSDConstants/*}*/./*{@link XSDConstants#isSchemaForSchemaNamespace */isSchemaForSchemaNamespace/*}*/(element.getNamespaceURI())) /*{@link */XSDSchema/*}*/ xsdSchema = XSDFactory.eINSTANCE./*{@link XSDFactory#createXSDSchema */createXSDSchema/*}*/(); xsdSchema./*{@link XSDConcreteComponent#setElement */setElement/*}*/(element);
protected XSDParticle createXSDElementReference() { List list = xsdModelGroup.getSchema().getElementDeclarations(); XSDElementDeclaration referencedElement = null; if (list.size() > 0) { referencedElement = (XSDElementDeclaration)list.get(0); } else { referencedElement = createGlobalXSDElementDeclaration(); Text textNode = xsdSchema.getDocument().createTextNode("\n"); //$NON-NLS-1$ xsdSchema.getElement().appendChild(textNode); xsdSchema.getContents().add(referencedElement); } XSDElementDeclaration element = XSDFactory.eINSTANCE.createXSDElementDeclaration(); element.setResolvedElementDeclaration(referencedElement); XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle(); particle.setContent(element); addedXSDConcreteComponent = element; return particle; }
protected XSDAttributeDeclaration createGlobalXSDAttributeDeclaration(XSDSchema xsdSchema) { ensureSchemaElement(xsdSchema); XSDAttributeDeclaration attribute = XSDFactory.eINSTANCE.createXSDAttributeDeclaration(); attribute.setTypeDefinition(xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition("string")); //$NON-NLS-1$ attribute.setName(XSDCommonUIUtils.createUniqueElementName("NewAttribute", xsdSchema.getAttributeDeclarations())); //$NON-NLS-1$ Text textNode = xsdSchema.getDocument().createTextNode("\n"); //$NON-NLS-1$ xsdSchema.getElement().appendChild(textNode); xsdSchema.getContents().add(attribute); return attribute; }
beginRecording(xsdSchema.getElement()); XSDElementDeclaration element = createGlobalXSDElementDeclaration(); Text textNode = xsdSchema.getDocument().createTextNode("\n"); //$NON-NLS-1$ xsdSchema.getElement().appendChild(textNode); xsdSchema.getContents().add(element); addedXSDConcreteComponent = element; XSDParticle particle = factory.createXSDParticle(); xsdModelGroup = factory.createXSDModelGroup(); xsdModelGroup.setCompositor(XSDCompositor.SEQUENCE_LITERAL); particle.setContent(xsdModelGroup); xsdModelGroupDefinition.setModelGroup(xsdModelGroup); if (!isReference) xsdModelGroup.getContents().add(createXSDElementDeclarationForModelGroupDefinitions()); xsdModelGroup.getContents().add(createXSDElementReference()); XSDParticle particle = factory.createXSDParticle(); xsdModelGroup = factory.createXSDModelGroup(); xsdModelGroup.setCompositor(XSDCompositor.SEQUENCE_LITERAL); particle.setContent(xsdModelGroup); xsdComplexTypeDefinition.setContent(particle);
XSDComplexTypeDefinition complexType = factory.createXSDComplexTypeDefinition(); addedXSDConcreteComponent = complexType; String newName = getNewName(nameToAdd == null ? "NewXSDComplexType" : nameToAdd, parent.getSchema()); //$NON-NLS-1$ Text textNode = xsdSchema.getDocument().createTextNode("\n"); //$NON-NLS-1$ xsdSchema.getElement().appendChild(textNode); xsdSchema.getContents().add(complexType); ((XSDElementDeclaration) parent).setAnonymousTypeDefinition(complexType); formatChild(parent.getElement());
schema = XSDFactory.eINSTANCE.createXSDSchema(); resourceSet = XSDSchemaImpl.createResourceSet(); resourceSet.getAdapterFactories().add(new XSDSchemaLocationResolverAdapterFactory()); schema = XSDFactory.eINSTANCE.createXSDSchema(); resource.getContents().add(schema); resourceSet.getResources().add(resource); schema.setDocument(document); final Element element = document.getDocumentElement(); if (element != null) String schemaForSchemaNamespace = element.getNamespaceURI(); XSDSchemaImpl.getSchemaForSchema(schemaForSchemaNamespace);
protected void addImport(String namespace, String schemaLocation) { XSDImport xsdImport = XSDFactory.eINSTANCE.createXSDImport(); xsdImport.setNamespace(namespace); xsdImport.setSchemaLocation(schemaLocation); xsdSchema.getContents().add(0, xsdImport); }
XSDFactory factory = XSDFactory.eINSTANCE; XSDComplexTypeDefinition definition = factory.createXSDComplexTypeDefinition(); definition.setName(type.getName().getLocalPart()); definition.setDerivationMethod(XSDDerivationMethod.EXTENSION_LITERAL); XSDModelGroup attributes = factory.createXSDModelGroup(); attributes.setCompositor(XSDCompositor.SEQUENCE_LITERAL); XSDElementDeclaration attribute = factory.createXSDElementDeclaration(); attribute.setName(attributeDescriptor.getLocalName()); attribute.setNillable(attributeDescriptor.isNillable()); if (xsd.resolveTypeDefinition(name.getNamespaceURI(), name.getLocalPart()) == null) { XSDParticle particle = factory.createXSDParticle(); particle.setMinOccurs(attributeDescriptor.getMinOccurs()); particle.setMaxOccurs(attributeDescriptor.getMaxOccurs()); particle.setContent(attribute); attributes.getContents().add(particle); XSDParticle contents = factory.createXSDParticle(); contents.setContent(attributes); xsd.getContents().add(definition);
protected void makeReferenceAttribute(EReference reference, XSDComplexTypeDefinition xsdComplexTypeDefinition) { XSDAttributeDeclaration attrDecl = XSDFactory.eINSTANCE.createXSDAttributeDeclaration(); attrDecl.setName(getName(reference)); setReferenceAttribType(attrDecl); XSDAttributeUse attrUse = XSDFactory.eINSTANCE.createXSDAttributeUse(); attrUse.setContent(attrDecl); xsdComplexTypeDefinition.getAttributeContents().add(attrUse); map(attrUse, reference); }
XSDConcreteComponent elementDecl = ((XSDElementDeclaration)getModelObject()).cloneConcreteComponent(true, true); container.getSchema().getContents().add(elementDecl); XSDFactory.eINSTANCE.createXSDElementDeclaration(); elementRef.setValue(element.getValue()); elementRef.setResolvedElementDeclaration((XSDElementDeclaration)elementDecl); XSDModelGroup modelGroup = (XSDModelGroup)container; int index = modelGroup.getContents().indexOf(parent); XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle(); particle.setContent(elementRef); modelGroup.getContents().add(index, particle); if (parentParticle.isSetMinOccurs()) { particle.setMinOccurs(parentParticle.getMinOccurs()); parentParticle.unsetMinOccurs(); container.getSchema().updateElement(true); formatChild(elementDecl.getElement());
XSDComplexTypeDefinition type = f.createXSDComplexTypeDefinition(); type.setTargetNamespace(featureType.getName().getNamespaceURI()); type.setName(featureType.getTypeName() + "Type"); type.setBaseTypeDefinition(schemaIndex.getTypeDefinition(gml.qName("AbstractFeatureType"))); XSDModelGroup group = f.createXSDModelGroup(); group.setCompositor(XSDCompositor.SEQUENCE_LITERAL); XSDElementDeclaration element = f.createXSDElementDeclaration(); element.setName(attribute.getLocalName()); element.setNillable(attribute.isNillable()); XSDParticle particle = f.createXSDParticle(); particle.setMinOccurs(attribute.getMinOccurs()); particle.setMaxOccurs(attribute.getMaxOccurs()); particle.setContent(element); particle.setElement( dom.createElementNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, "element")); group.getContents().add(particle); XSDParticle particle = f.createXSDParticle(); particle.setContent(group); particle.setElement(
protected void addElementDeclarationReference(XSDSchema schema, XSDModelGroup modelGroup, String reference) { XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle(); XSDElementDeclaration elementDeclaration = XSDFactory.eINSTANCE.createXSDElementDeclaration(); elementDeclaration.setResolvedElementDeclaration(schema.resolveElementDeclaration(reference)); particle.setContent(elementDeclaration); modelGroup.getContents().add(particle); }
protected void makeReferenceElement(EReference reference, XSDComplexTypeDefinition xsdComplexTypeDefinition) { XSDModelGroup modelGroup = getModelGroup(xsdComplexTypeDefinition); XSDElementDeclaration xsdElementDeclaration = XSDFactory.eINSTANCE.createXSDElementDeclaration(); xsdElementDeclaration.setName(getName(reference)); if (reference.isUnsettable() && !reference.isMany()) { xsdElementDeclaration.setNillable(true); } setReferenceElementType(reference, xsdElementDeclaration); XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle(); particle.setContent(xsdElementDeclaration); setReferenceElementMultiplicity(reference, particle); modelGroup.getContents().add(particle); map(particle, reference); }
protected void importXMI() { Map<String, String> namespaces = this.xsdSchema.getQNamePrefixToNamespaceMap(); if (namespaces.put(XMI_PREFIX, XMI_URI) == null) { XSDImport xmiImport = XSDFactory.eINSTANCE.createXSDImport(); xmiImport.setNamespace(XMI_URI); xmiImport.setSchemaLocation(EcorePackage.eNS_URI.equals(xsdSchema.getTargetNamespace()) ? XMI_SCHEMA_LOCATION : "platform:/plugin/org.eclipse.emf.ecore/model/" + XMI_SCHEMA_LOCATION); this.xsdSchema.getContents().add(0, xmiImport); } } }