Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community Forums
-
XSD->Ecore->XSD and anonymous types
https://www.eclipse.org/forums/index.php/mv/msg/190548/604531/#msg_604531
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema "
xmlns="http://www.example.com/test "
targetNamespace="http://www.example.com/test ">
<xsd:element name="address-global-element">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="zip-code" type="xsd:int" nillable="true" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
When I import this XSD using XSDEcoreBuilder and then later generate an XSD from the Ecore model using EcoreSchemaBuilder, the resulting XSD looks like this:
<xsd:schema ecore:nsPrefix="test" ecore:package="com.example.test"
targetNamespace="http://www.example.com/test "
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore "
xmlns:test="http://www.example.com/test " xmlns:xsd="http://www.w3.org/2001/XMLSchema ">
<xsd:element name="address-global-element" type="test:address-global-element_._type"/>
<xsd:complexType ecore:name="AddressGlobalElementType" name="address-global-element_._type">
<xsd:sequence>
<xsd:element ecore:name="zipCode" name="zip-code" nillable="true" type="xsd:int"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
I was wondering if there is any way to generate the XSD with the anonymous type declaration (as in the original XSD), instead of a named type with the "_._type" suffix?
Thank you,
Nikita
For reference, this is the ecore model produced by XSDEcoreBuilder:
<ecore:EPackage xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI " xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance "
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore " name="com.example.test"
nsURI="http://www.example.com/test " nsPrefix="test">
<eClassifiers xsi:type="ecore:EClass" name="AddressGlobalElementType">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData ">
<details key="name" value="address-global-element_._type"/>
<details key="kind" value="elementOnly"/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="zipCode" lowerBound="1"
eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//IntObject "
unsettable="true">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData ">
<details key="kind" value="element"/>
<details key="name" value="zip-code"/>
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="DocumentRoot">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData ">
<details key="name" value=""/>
<details key="kind" value="mixed"/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="mixed" unique="false" upperBound="-1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EFeatureMapEntry ">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData ">
<details key="kind" value="elementWildcard"/>
<details key="name" value=":mixed"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EReference" name="xMLNSPrefixMap" upperBound="-1"
eType="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EStringToStringMapEn try "
transient="true" containment="true" resolveProxies="false">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData ">
<details key="kind" value="attribute"/>
<details key="name" value="xmlns:prefix"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EReference" name="xSISchemaLocation" upperBound="-1"
eType="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EStringToStringMapEn try "
transient="true" containment="true" resolveProxies="false">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData ">
<details key="kind" value="attribute"/>
<details key="name" value="xsi:schemaLocation"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EReference" name="addressGlobalElement" upperBound="-2"
eType="ecore:EClass thisResource#//AddressGlobalElementType" volatile="true"
transient="true" derived="true" containment="true" resolveProxies="false">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData ">
<details key="kind" value="element"/>
<details key="name" value="address-global-element"/>
<details key="namespace" value="##targetNamespace"/>
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>
</ecore:EPackage>]]>
Nikita Missing name
2010-03-10T15:07:52-00:00
-
Re: XSD->Ecore->XSD and anonymous types
https://www.eclipse.org/forums/index.php/mv/msg/190548/604534/#msg_604534
Comments.
Nikita wrote:
> I have an XSD with an anonymous type defined under a global element:
>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema "
> xmlns="http://www.example.com/test "
> targetNamespace="http://www.example.com/test ">
>
> <xsd:element name="address-global-element">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element name="zip-code" type="xsd:int" nillable="true" />
> </xsd:sequence>
> </xsd:complexType>
> </xsd:element>
> </xsd:schema>
>
>
> When I import this XSD using XSDEcoreBuilder and then later generate
> an XSD from the Ecore model using EcoreSchemaBuilder, the resulting
> XSD looks like this:
XSD -> Ecore -> XSD is not generally a round trip while Ecore -> XSD ->
Ecore generally is.
>
>
> <xsd:schema ecore:nsPrefix="test" ecore:package="com.example.test"
> targetNamespace="http://www.example.com/test "
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore "
> xmlns:test="http://www.example.com/test "
> xmlns:xsd="http://www.w3.org/2001/XMLSchema ">
>
> <xsd:element name="address-global-element"
> type="test:address-global-element_._type"/>
>
> <xsd:complexType ecore:name="AddressGlobalElementType"
> name="address-global-element_._type">
> <xsd:sequence>
> <xsd:element ecore:name="zipCode" name="zip-code" nillable="true"
> type="xsd:int"/>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:schema>
>
>
> I was wondering if there is any way to generate the XSD with the
> anonymous type declaration (as in the original XSD), instead of a
> named type with the "_._type" suffix?
No. If you start with a schema, it's best to just keep it around.
>
> Thank you,
> Nikita
>
> For reference, this is the ecore model produced by XSDEcoreBuilder:
>
> <ecore:EPackage xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI "
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance "
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore "
> name="com.example.test"
> nsURI="http://www.example.com/test " nsPrefix="test">
> <eClassifiers xsi:type="ecore:EClass" name="AddressGlobalElementType">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData ">
> <details key="name" value="address-global-element_._type"/>
> <details key="kind" value="elementOnly"/>
> </eAnnotations>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="zipCode"
> lowerBound="1"
> eType="ecore:EDataType
> http://www.eclipse.org/emf/2003/XMLType#//IntObject "
> unsettable="true">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData ">
> <details key="kind" value="element"/>
> <details key="name" value="zip-code"/>
> </eAnnotations>
> </eStructuralFeatures>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="DocumentRoot">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData ">
> <details key="name" value=""/>
> <details key="kind" value="mixed"/>
> </eAnnotations>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="mixed"
> unique="false" upperBound="-1"
> eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EFeatureMapEntry ">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData ">
> <details key="kind" value="elementWildcard"/>
> <details key="name" value=":mixed"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EReference"
> name="xMLNSPrefixMap" upperBound="-1"
> eType="ecore:EClass
> http://www.eclipse.org/emf/2002/Ecore#//EStringToStringMapEn try "
> transient="true" containment="true" resolveProxies="false">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData ">
> <details key="kind" value="attribute"/>
> <details key="name" value="xmlns:prefix"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EReference"
> name="xSISchemaLocation" upperBound="-1"
> eType="ecore:EClass
> http://www.eclipse.org/emf/2002/Ecore#//EStringToStringMapEn try "
> transient="true" containment="true" resolveProxies="false">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData ">
> <details key="kind" value="attribute"/>
> <details key="name" value="xsi:schemaLocation"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EReference"
> name="addressGlobalElement" upperBound="-2"
> eType="ecore:EClass thisResource#//AddressGlobalElementType"
> volatile="true"
> transient="true" derived="true" containment="true"
> resolveProxies="false">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData ">
> <details key="kind" value="element"/>
> <details key="name" value="address-global-element"/>
> <details key="namespace" value="##targetNamespace"/>
> </eAnnotations>
> </eStructuralFeatures>
> </eClassifiers>
> </ecore:EPackage>
>
>]]>
Ed Merks
2010-03-10T16:42:37-00:00