public XSDSimpleTypeDefinition resolveSimpleTypeDefinition(String namespace, String localName) { XSDSchema xsdSchema = getSchema(); if (xsdSchema != null) { return xsdSchema.resolveSimpleTypeDefinition(namespace, localName); } else { return createUnresolvedSimpleTypeDefinition(namespace, localName); } }
public XSDSimpleTypeDefinition resolveSimpleTypeDefinition(String namespace, String localName) { XSDSchema xsdSchema = getSchema(); if (xsdSchema != null) { return xsdSchema.resolveSimpleTypeDefinition(namespace, localName); } else { return createUnresolvedSimpleTypeDefinition(namespace, localName); } }
protected XSDElementDeclaration createElementDeclaration(XSDSchema schema, String name, String type, boolean schemaType) { XSDElementDeclaration elementDeclaration = XSDFactory.eINSTANCE.createXSDElementDeclaration(); elementDeclaration.setName(name); if (schemaType) { elementDeclaration.setTypeDefinition(schema.getSchemaForSchema().resolveSimpleTypeDefinition(type)); } else { elementDeclaration.setTypeDefinition(schema.resolveSimpleTypeDefinition(type)); } return elementDeclaration; }
protected XSDElementDeclaration createElementDeclaration(XSDSchema schema, String name, String type, boolean schemaType) { XSDElementDeclaration elementDeclaration = XSDFactory.eINSTANCE.createXSDElementDeclaration(); elementDeclaration.setName(name); if (schemaType) { elementDeclaration.setTypeDefinition(schema.getSchemaForSchema().resolveSimpleTypeDefinition(type)); } else { elementDeclaration.setTypeDefinition(schema.resolveSimpleTypeDefinition(type)); } return elementDeclaration; }
protected XSDDiagnostic checkBuiltInTypeConstraint (String builtInTypeName, String value, String part, String anchor, Element element, String attributeName, boolean isRequired) { XSDSimpleTypeDefinition builtInType = getSchema().getSchemaForSchema().resolveSimpleTypeDefinition(builtInTypeName); return checkSimpleTypeConstraint(builtInType, value, part, anchor, element, attributeName, isRequired); }
public XSDSimpleTypeDefinition resolveSimpleTypeDefinition(String localName) { XSDSchema xsdSchema = getSchema(); if (xsdSchema != null) { return xsdSchema.resolveSimpleTypeDefinition(xsdSchema.getTargetNamespace(), localName); } else { return createUnresolvedSimpleTypeDefinition(null, localName); } }
protected void setReferenceAttribType(XSDAttributeDeclaration xsdAttributeDeclaration) { addEMFSchema(); xsdAttributeDeclaration.setTypeDefinition(xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition(REFERENCE_TYPE_NAME)); }
protected XSDDiagnostic checkBuiltInTypeConstraint (String builtInTypeName, String value, String part, String anchor, Element element, String attributeName, boolean isRequired) { XSDSimpleTypeDefinition builtInType = getSchema().getSchemaForSchema().resolveSimpleTypeDefinition(builtInTypeName); return checkSimpleTypeConstraint(builtInType, value, part, anchor, element, attributeName, isRequired); }
protected void setReferenceAttribType(XSDAttributeDeclaration xsdAttributeDeclaration) { addEMFSchema(); xsdAttributeDeclaration.setTypeDefinition(xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition(REFERENCE_TYPE_NAME)); }
public XSDSimpleTypeDefinition resolveSimpleTypeDefinition(String localName) { XSDSchema xsdSchema = getSchema(); if (xsdSchema != null) { return xsdSchema.resolveSimpleTypeDefinition(xsdSchema.getTargetNamespace(), localName); } else { return createUnresolvedSimpleTypeDefinition(null, localName); } }
protected void createEMFSchema() { emfSchema = XSDFactory.eINSTANCE.createXSDSchema(); emfSchema.setTargetNamespace(EMF_SCHEMA_URI); emfSchema.setSchemaForSchemaQNamePrefix("xsd"); Map<String, String> namespaces = emfSchema.getQNamePrefixToNamespaceMap(); namespaces.put(EMF_SCHEMA_PREFIX, emfSchema.getTargetNamespace()); namespaces.put(emfSchema.getSchemaForSchemaQNamePrefix(), XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001); XSDSimpleTypeDefinition list = XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition(); list.setName(REFERENCE_TYPE_NAME); XSDSimpleTypeDefinition union = XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition(); union.getMemberTypeDefinitions().add(emfSchema.getSchemaForSchema().resolveSimpleTypeDefinition("IDREF")); union.getMemberTypeDefinitions().add(emfSchema.getSchemaForSchema().resolveSimpleTypeDefinition("QName")); union.getMemberTypeDefinitions().add(emfSchema.getSchemaForSchema().resolveSimpleTypeDefinition("anyURI")); list.setItemTypeDefinition(union); list.getContents().add(union); emfSchema.getContents().add(list); }
protected void createEMFSchema() { emfSchema = XSDFactory.eINSTANCE.createXSDSchema(); emfSchema.setTargetNamespace(EMF_SCHEMA_URI); emfSchema.setSchemaForSchemaQNamePrefix("xsd"); Map<String, String> namespaces = emfSchema.getQNamePrefixToNamespaceMap(); namespaces.put(EMF_SCHEMA_PREFIX, emfSchema.getTargetNamespace()); namespaces.put(emfSchema.getSchemaForSchemaQNamePrefix(), XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001); XSDSimpleTypeDefinition list = XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition(); list.setName(REFERENCE_TYPE_NAME); XSDSimpleTypeDefinition union = XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition(); union.getMemberTypeDefinitions().add(emfSchema.getSchemaForSchema().resolveSimpleTypeDefinition("IDREF")); union.getMemberTypeDefinitions().add(emfSchema.getSchemaForSchema().resolveSimpleTypeDefinition("QName")); union.getMemberTypeDefinitions().add(emfSchema.getSchemaForSchema().resolveSimpleTypeDefinition("anyURI")); list.setItemTypeDefinition(union); list.getContents().add(union); emfSchema.getContents().add(list); }
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; }
public void visitElementDeclaration(org.eclipse.xsd.XSDElementDeclaration element) { if (element.getTypeDefinition() == target) { XSDSimpleTypeDefinition type = target.getSchema().getSchemaForSchema().resolveSimpleTypeDefinition("string"); //$NON-NLS-1$ element.setTypeDefinition(type); } super.visitElementDeclaration(element); } };
protected XSDParticle createXSDElementDeclarationForComplexType() { XSDSimpleTypeDefinition type = xsdModelGroup.getSchema().getSchemaForSchema().resolveSimpleTypeDefinition("string"); //$NON-NLS-1$ XSDElementDeclaration element = XSDFactory.eINSTANCE.createXSDElementDeclaration(); ArrayList usedAttributeNames = new ArrayList(); usedAttributeNames.addAll(XSDCommonUIUtils.getAllAttributes(xsdComplexTypeDefinition)); usedAttributeNames.addAll(XSDCommonUIUtils.getInheritedAttributes(xsdComplexTypeDefinition)); element.setName(XSDCommonUIUtils.createUniqueElementName( nameToAdd == null ? "NewElement" : nameToAdd , usedAttributeNames)); //$NON-NLS-1$ element.setTypeDefinition(type); XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle(); particle.setContent(element); addedXSDConcreteComponent = element; return particle; }
protected XSDParticle createXSDElementDeclarationForModelGroupDefinitions() { XSDSimpleTypeDefinition type = xsdModelGroup.getSchema().getSchemaForSchema().resolveSimpleTypeDefinition("string"); //$NON-NLS-1$ XSDElementDeclaration element = XSDFactory.eINSTANCE.createXSDElementDeclaration(); ArrayList usedAttributeNames = new ArrayList(); usedAttributeNames.addAll(XSDCommonUIUtils.getAllAttributes(xsdModelGroupDefinition)); element.setName(XSDCommonUIUtils.createUniqueElementName( nameToAdd == null ? "NewElement" : nameToAdd , usedAttributeNames)); //$NON-NLS-1$ element.setTypeDefinition(type); XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle(); particle.setContent(element); addedXSDConcreteComponent = element; return particle; }
@Override protected boolean analyze() { if (!isAttributeDeclarationReference()) { XSDSimpleTypeDefinition theTypeDefinition = getTypeDefinition(); if (!isTypeExplicit || theTypeDefinition == null) { XSDSimpleTypeDefinition newTypeDefinition = getSchema().getSchemaForSchema().resolveSimpleTypeDefinition("anySimpleType"); if (newTypeDefinition != theTypeDefinition) { isTypeExplicit = false; setTypeDefinitionGen(newTypeDefinition); } } } return super.analyze(); }
protected XSDElementDeclaration createGlobalXSDElementDeclaration() { ensureSchemaElement(xsdSchema); XSDSimpleTypeDefinition type = xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition("string"); //$NON-NLS-1$ XSDFactory factory = XSDSchemaBuildingTools.getXSDFactory(); XSDElementDeclaration element = factory.createXSDElementDeclaration(); element.setName(XSDCommonUIUtils.createUniqueElementName( nameToAdd == null ? "NewElement" : nameToAdd , xsdSchema.getElementDeclarations())); //$NON-NLS-1$ element.setTypeDefinition(type); return element; }
/** * Each EEnum is mapped to a schema simple type that restricts the string simple type; * the schema type has an enumeration facet for each EEnumLiteral. */ protected void processEnum(EEnum eEnum) { XSDSimpleTypeDefinition enumType = XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition(); enumType.setName(getName(eEnum)); enumType.setBaseTypeDefinition(xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition("NCName")); xsdSchema.getContents().add(enumType); map(enumType, eEnum); for (EEnumLiteral literal : eEnum.getELiterals()) { XSDEnumerationFacet facet = XSDFactory.eINSTANCE.createXSDEnumerationFacet(); facet.setLexicalValue(getName(literal)); enumType.getFacetContents().add(facet); map(facet, literal); } }
/** * Each EEnum is mapped to a schema simple type that restricts the string simple type; * the schema type has an enumeration facet for each EEnumLiteral. */ protected void processEnum(EEnum eEnum) { XSDSimpleTypeDefinition enumType = XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition(); enumType.setName(getName(eEnum)); enumType.setBaseTypeDefinition(xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition("NCName")); xsdSchema.getContents().add(enumType); map(enumType, eEnum); for (EEnumLiteral literal : eEnum.getELiterals()) { XSDEnumerationFacet facet = XSDFactory.eINSTANCE.createXSDEnumerationFacet(); facet.setLexicalValue(getName(literal)); enumType.getFacetContents().add(facet); map(facet, literal); } }