Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » XSD schema not generated when ns prefix empty in ecore?
XSD schema not generated when ns prefix empty in ecore? [message #518746] Thu, 04 March 2010 21:24 Go to next message
keller_jens is currently offline keller_jensFriend
Messages: 21
Registered: March 2010
Location: Germany
Junior Member
Hi,
in my genmodel I've set generateSchema=true, and observed the following:

When the Ns Prefix in the ecore package is empty
(nsPrefix="") and I generate the model classes, the
.xsd and the .xsd2ecore file are not generated.

But in our xml files which are modelled here, the elements don't have a prefx, so I must maintain nsPrefix="" in the ecore, right? Otherwise, when I create an xml file using the generated wizard and edit with the generated editor, all elements have this prefix in the file.

But on the other hand I want the ecore file to be the "leading" model artifact, because it is much easier to read and to maintain changes here.

But our xsd schemas should be consistent with the ecore, so whenever I want to make a change to the model in the ecore and re-generate the model classes, I want that the xsd file is also re-generated.

How can I achieve this?

Best regards,
Jens
Re: XSD schema not generated when ns prefix empty in ecore? [message #518750 is a reply to message #518746] Thu, 04 March 2010 21:29 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Jens,

Comments below.

Jens Keller wrote:
> Hi,
> in my genmodel I've set generateSchema=true, and observed the following:
That schema generator is really horrible. You should be using the
Export facility to produce schemas.
>
> When the Ns Prefix in the ecore package is empty
> (nsPrefix="") and I generate the model classes, the xsd and the
> .xsd2ecore file are not generated.
>
> But in our xml files which are modelled here, the elements don't have
> a prefx, so I must maintain nsPrefix="" in the ecore, right?
> Otherwise, when I create an xml file using the generated wizard and
> edit with the generated editor, all elements have this prefix in the
> file.
Don't confuse there being a default prefix with there being no prefix
though...
>
> But on the other hand I want the ecore file to be the "leading" model
> artifact, because it is much easier to read and to maintain changes here.
>
> But our xsd schemas should be consistent with the ecore, so whenever I
> want to make a change to the model in the ecore and re-generate the
> model classes, I want that the xsd file is also re-generated.
What kind of serialization do you use? Can you show an example of the XML?
>
> How can I achieve this?
>
> Best regards,
> Jens


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: XSD schema not generated when ns prefix empty in ecore? [message #518889 is a reply to message #518750] Fri, 05 March 2010 11:38 Go to previous messageGo to next message
keller_jens is currently offline keller_jensFriend
Messages: 21
Registered: March 2010
Location: Germany
Junior Member
Hi Ed,
I've tried this "Export model" functionality and selected "XML Schema" in the pop-up window.

But I got an error - InvocationTargetException.
The details showed the following

java.lang.IllegalArgumentException: The default prefix should represented as null rather than as a zero length String
at org.eclipse.xsd.impl.XSDSchemaImpl$1.put(XSDSchemaImpl.java:768)


I'm sure it's because of the nsPrefix="" in the ecore. But if I don't maintain this attribute at all, I get an exception "The namespace prefix 'null' is not well formed.

My ecore file is:

<?xml version="1.0" encoding="UTF-8"?>
<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="prettyurl"
    nsURI="http://www.test.org/prettyurl" nsPrefix="">
  <eClassifiers xsi:type="ecore:EClass" name="AppPUrlType">
    <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
      <details key="name" value="appPUrlType"/>
      <details key="kind" value="elementOnly"/>
    </eAnnotations>
    <eStructuralFeatures xsi:type="ecore:EReference" name="moduleRule" lowerBound="1"
        eType="#//ModuleRuleType" containment="true" resolveProxies="false">
      <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
        <details key="kind" value="element"/>
        <details key="name" value="moduleRule"/>
        <details key="namespace" value="##targetNamespace"/>
      </eAnnotations>
    </eStructuralFeatures>
    <eStructuralFeatures xsi:type="ecore:EReference" name="commonRule" lowerBound="1"
        upperBound="-1" eType="#//CommonRuleType" containment="true" resolveProxies="false">
      <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
        <details key="kind" value="element"/>
        <details key="name" value="commonRule"/>
        <details key="namespace" value="##targetNamespace"/>
      </eAnnotations>
    </eStructuralFeatures>
    <eStructuralFeatures xsi:type="ecore:EReference" name="pageRule" lowerBound="1"
        upperBound="-1" eType="#//PageRuleType" containment="true" resolveProxies="false">
      <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
        <details key="kind" value="element"/>
        <details key="name" value="pageRule"/>
        <details key="namespace" value="##targetNamespace"/>
      </eAnnotations>
    </eStructuralFeatures>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="CommonRuleType">
    <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
      <details key="name" value="commonRuleType"/>
      <details key="kind" value="elementOnly"/>
    </eAnnotations>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="prettyUrl" lowerBound="1"
        eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//String">
      <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
        <details key="kind" value="element"/>
        <details key="name" value="prettyUrl"/>
        <details key="namespace" value="##targetNamespace"/>
      </eAnnotations>
    </eStructuralFeatures>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="internalUrl" lowerBound="1"
        eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//String">
      <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
        <details key="kind" value="element"/>
        <details key="name" value="internalUrl"/>
        <details key="namespace" value="##targetNamespace"/>
      </eAnnotations>
    </eStructuralFeatures>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="id" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//String">
      <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
        <details key="kind" value="attribute"/>
        <details key="name" value="id"/>
      </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#//EStringToStringMapEntry"
        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#//EStringToStringMapEntry"
        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="appPUrl" upperBound="-2"
        eType="#//AppPUrlType" 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="appPUrl"/>
        <details key="namespace" value="##targetNamespace"/>
      </eAnnotations>
    </eStructuralFeatures>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="ModuleRuleType">
    <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
      <details key="name" value="moduleRuleType"/>
      <details key="kind" value="elementOnly"/>
    </eAnnotations>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="prettyUrl" lowerBound="1"
        eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//String">
      <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
        <details key="kind" value="element"/>
        <details key="name" value="prettyUrl"/>
        <details key="namespace" value="##targetNamespace"/>
      </eAnnotations>
    </eStructuralFeatures>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="internalUrl" lowerBound="1"
        eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//String">
      <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
        <details key="kind" value="element"/>
        <details key="name" value="internalUrl"/>
        <details key="namespace" value="##targetNamespace"/>
      </eAnnotations>
    </eStructuralFeatures>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="PageRuleType">
    <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
      <details key="name" value="pageRuleType"/>
      <details key="kind" value="elementOnly"/>
    </eAnnotations>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="prettyUrl" lowerBound="1"
        eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//String">
      <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
        <details key="kind" value="element"/>
        <details key="name" value="prettyUrl"/>
        <details key="namespace" value="##targetNamespace"/>
      </eAnnotations>
    </eStructuralFeatures>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="internalUrl" lowerBound="1"
        eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//String">
      <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
        <details key="kind" value="element"/>
        <details key="name" value="internalUrl"/>
        <details key="namespace" value="##targetNamespace"/>
      </eAnnotations>
    </eStructuralFeatures>
    <eStructuralFeatures xsi:type="ecore:EReference" name="ruleSet" lowerBound="1"
        eType="#//RuleSetType" containment="true" resolveProxies="false">
      <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
        <details key="kind" value="element"/>
        <details key="name" value="ruleSet"/>
        <details key="namespace" value="##targetNamespace"/>
      </eAnnotations>
    </eStructuralFeatures>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="RuleSetType">
    <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
      <details key="name" value="ruleSetType"/>
      <details key="kind" value="elementOnly"/>
    </eAnnotations>
    <eStructuralFeatures xsi:type="ecore:EReference" name="rule" lowerBound="1" eType="#//RuleType"
        containment="true" resolveProxies="false">
      <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
        <details key="kind" value="element"/>
        <details key="name" value="rule"/>
        <details key="namespace" value="##targetNamespace"/>
      </eAnnotations>
    </eStructuralFeatures>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="RuleType">
    <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
      <details key="name" value="ruleType"/>
      <details key="kind" value="empty"/>
    </eAnnotations>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="ref" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//String">
      <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
        <details key="kind" value="attribute"/>
        <details key="name" value="ref"/>
      </eAnnotations>
    </eStructuralFeatures>
  </eClassifiers>
</ecore:EPackage>





An example for the corresponding XML file:


<?xml version="1.0" encoding="UTF-8"?>
<appPUrl xmlns="http://www.test.org/prettyurl">
	<moduleRule>
		<prettyUrl>/$i18n:example.ui.prettyurl.test$
		</prettyUrl>
		<internalUrl>/example
		</internalUrl>
	</moduleRule>
	<commonRule id="cr1">
		<prettyUrl>/$i18n:example.ui.prettyurl.test1$/$word$
		</prettyUrl>
		<internalUrl>exampleId=$1</internalUrl>
	</commonRule>
	<commonRule id="cr2">
		<prettyUrl>/$word$</prettyUrl>
		<internalUrl>exampleId=$1</internalUrl>
	</commonRule>
	<pageRule>
		<prettyUrl>/$i18n:example.ui.prettyurl.main$
		</prettyUrl>
		<internalUrl>$page_sep$Example$target_sep$list.xhtml
		</internalUrl>
		<ruleSet>
			<rule ref="cr1" />
		</ruleSet>
	</pageRule>
	<pageRule>
		<prettyUrl>/details</prettyUrl>
		<internalUrl>$page_sep$Example$target_sep$details.xhtml
		</internalUrl>
		<ruleSet>
			<rule ref="cr2" />
		</ruleSet>
	</pageRule>
	<pageRule>
		<prettyUrl>/detailsWithParams</prettyUrl>
		<internalUrl>
			$page_sep$Example$target_sep$detailsWithParams.xhtml
		</internalUrl>
		<ruleSet>
			<rule ref="cr2" />
		</ruleSet>
	</pageRule>
	<pageRule>
		<prettyUrl>/dynamicui</prettyUrl>
		<internalUrl>$page_sep$DynamicUI$target_sep$dynamicUI.xhtml
		</internalUrl>
		<ruleSet>
			<rule ref="cr1" />
		</ruleSet>
	</pageRule>
</appPUrl>


Hope this answers the question regarding serialization?

Best regards,
Jens
Re: XSD schema not generated when ns prefix empty in ecore? [message #518900 is a reply to message #518889] Fri, 05 March 2010 11:55 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Jens,

Please open a bugzilla for problem of an exception when generating the
schema. The converter shouldn't pass bad data to the XSD API. I'll
fix that problem and then I'll look at the rest of this when I get back
from swimming.


Jens Keller wrote:
> Hi Ed,
> I've tried this "Export model" functionality and selected "XML Schema"
> in the pop-up window.
>
> But I got an error - InvocationTargetException.
> The details showed the following
>
> java.lang.IllegalArgumentException: The default prefix should
> represented as null rather than as a zero length String
> at org.eclipse.xsd.impl.XSDSchemaImpl$1.put(XSDSchemaImpl.java: 768)
>
> I'm sure it's because of the nsPrefix="" in the ecore. But if I don't
> maintain this attribute at all, I get an exception "The namespace
> prefix 'null' is not well formed.
>
> My ecore file is:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <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="prettyurl"
> nsURI="http://www.test.org/prettyurl" nsPrefix="">
> <eClassifiers xsi:type="ecore:EClass" name="AppPUrlType">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="appPUrlType"/>
> <details key="kind" value="elementOnly"/>
> </eAnnotations>
> <eStructuralFeatures xsi:type="ecore:EReference" name="moduleRule"
> lowerBound="1"
> eType="#//ModuleRuleType" containment="true"
> resolveProxies="false">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="element"/>
> <details key="name" value="moduleRule"/>
> <details key="namespace" value="##targetNamespace"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EReference" name="commonRule"
> lowerBound="1"
> upperBound="-1" eType="#//CommonRuleType" containment="true"
> resolveProxies="false">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="element"/>
> <details key="name" value="commonRule"/>
> <details key="namespace" value="##targetNamespace"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EReference" name="pageRule"
> lowerBound="1"
> upperBound="-1" eType="#//PageRuleType" containment="true"
> resolveProxies="false">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="element"/>
> <details key="name" value="pageRule"/>
> <details key="namespace" value="##targetNamespace"/>
> </eAnnotations>
> </eStructuralFeatures>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="CommonRuleType">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="commonRuleType"/>
> <details key="kind" value="elementOnly"/>
> </eAnnotations>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="prettyUrl"
> lowerBound="1"
> eType="ecore:EDataType
> http://www.eclipse.org/emf/2003/XMLType#//String">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="element"/>
> <details key="name" value="prettyUrl"/>
> <details key="namespace" value="##targetNamespace"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="internalUrl"
> lowerBound="1"
> eType="ecore:EDataType
> http://www.eclipse.org/emf/2003/XMLType#//String">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="element"/>
> <details key="name" value="internalUrl"/>
> <details key="namespace" value="##targetNamespace"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="id"
> lowerBound="1" eType="ecore:EDataType
> http://www.eclipse.org/emf/2003/XMLType#//String">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="attribute"/>
> <details key="name" value="id"/>
> </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="appPUrl"
> upperBound="-2"
> eType="#//AppPUrlType" 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="appPUrl"/>
> <details key="namespace" value="##targetNamespace"/>
> </eAnnotations>
> </eStructuralFeatures>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="ModuleRuleType">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="moduleRuleType"/>
> <details key="kind" value="elementOnly"/>
> </eAnnotations>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="prettyUrl"
> lowerBound="1"
> eType="ecore:EDataType
> http://www.eclipse.org/emf/2003/XMLType#//String">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="element"/>
> <details key="name" value="prettyUrl"/>
> <details key="namespace" value="##targetNamespace"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="internalUrl"
> lowerBound="1"
> eType="ecore:EDataType
> http://www.eclipse.org/emf/2003/XMLType#//String">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="element"/>
> <details key="name" value="internalUrl"/>
> <details key="namespace" value="##targetNamespace"/>
> </eAnnotations>
> </eStructuralFeatures>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="PageRuleType">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="pageRuleType"/>
> <details key="kind" value="elementOnly"/>
> </eAnnotations>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="prettyUrl"
> lowerBound="1"
> eType="ecore:EDataType
> http://www.eclipse.org/emf/2003/XMLType#//String">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="element"/>
> <details key="name" value="prettyUrl"/>
> <details key="namespace" value="##targetNamespace"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="internalUrl"
> lowerBound="1"
> eType="ecore:EDataType
> http://www.eclipse.org/emf/2003/XMLType#//String">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="element"/>
> <details key="name" value="internalUrl"/>
> <details key="namespace" value="##targetNamespace"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EReference" name="ruleSet"
> lowerBound="1"
> eType="#//RuleSetType" containment="true" resolveProxies="false">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="element"/>
> <details key="name" value="ruleSet"/>
> <details key="namespace" value="##targetNamespace"/>
> </eAnnotations>
> </eStructuralFeatures>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="RuleSetType">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="ruleSetType"/>
> <details key="kind" value="elementOnly"/>
> </eAnnotations>
> <eStructuralFeatures xsi:type="ecore:EReference" name="rule"
> lowerBound="1" eType="#//RuleType"
> containment="true" resolveProxies="false">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="element"/>
> <details key="name" value="rule"/>
> <details key="namespace" value="##targetNamespace"/>
> </eAnnotations>
> </eStructuralFeatures>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="RuleType">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="ruleType"/>
> <details key="kind" value="empty"/>
> </eAnnotations>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="ref"
> lowerBound="1" eType="ecore:EDataType
> http://www.eclipse.org/emf/2003/XMLType#//String">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="attribute"/>
> <details key="name" value="ref"/>
> </eAnnotations>
> </eStructuralFeatures>
> </eClassifiers>
> </ecore:EPackage>
>
>
>
>
> An example for the corresponding XML file:
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <appPUrl xmlns="http://www.test.org/prettyurl">
> <moduleRule>
> <prettyUrl>/$i18n:example.ui.prettyurl.test$
> </prettyUrl>
> <internalUrl>/example
> </internalUrl>
> </moduleRule>
> <commonRule id="cr1">
> <prettyUrl>/$i18n:example.ui.prettyurl.test1$/$word$
> </prettyUrl>
> <internalUrl>exampleId=$1</internalUrl>
> </commonRule>
> <commonRule id="cr2">
> <prettyUrl>/$word$</prettyUrl>
> <internalUrl>exampleId=$1</internalUrl>
> </commonRule>
> <pageRule>
> <prettyUrl>/$i18n:example.ui.prettyurl.main$
> </prettyUrl>
> <internalUrl>$page_sep$Example$target_sep$list.xhtml
> </internalUrl>
> <ruleSet>
> <rule ref="cr1" />
> </ruleSet>
> </pageRule>
> <pageRule>
> <prettyUrl>/details</prettyUrl>
> <internalUrl>$page_sep$Example$target_sep$details.xhtml
> </internalUrl>
> <ruleSet>
> <rule ref="cr2" />
> </ruleSet>
> </pageRule>
> <pageRule>
> <prettyUrl>/detailsWithParams</prettyUrl>
> <internalUrl>
> $page_sep$Example$target_sep$detailsWithParams.xhtml
> </internalUrl>
> <ruleSet>
> <rule ref="cr2" />
> </ruleSet>
> </pageRule>
> <pageRule>
> <prettyUrl>/dynamicui</prettyUrl>
> <internalUrl>$page_sep$DynamicUI$target_sep$dynamicUI.xhtml
> </internalUrl>
> <ruleSet>
> <rule ref="cr1" />
> </ruleSet>
> </pageRule>
> </appPUrl>
>
> Hope this answers the question regarding serialization?
>
> Best regards,
> Jens


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: XSD schema not generated when ns prefix empty in ecore? [message #518943 is a reply to message #518900] Fri, 05 March 2010 14:18 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------000203040202050402050504
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Jens,

So I have a patch to fix the bug once you open it. It then generates
this schema:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns="http://www.test.org/prettyurl" ecore:nsPrefix=""
ecore:package="prettyurl"
targetNamespace="http://www.test.org/prettyurl">
<xsd:element name="appPUrl" type="appPUrlType"/>
<xsd:complexType ecore:name="AppPUrlType" name="appPUrlType">
<xsd:sequence>
<xsd:element form="qualified" name="moduleRule"
type="moduleRuleType"/>
<xsd:element form="qualified" maxOccurs="unbounded"
name="commonRule" type="commonRuleType"/>
<xsd:element form="qualified" maxOccurs="unbounded"
name="pageRule" type="pageRuleType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType ecore:name="CommonRuleType" name="commonRuleType">
<xsd:sequence>
<xsd:element form="qualified" name="prettyUrl" type="xsd:string"/>
<xsd:element form="qualified" name="internalUrl"
type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:string" use="required"/>
</xsd:complexType>
<xsd:complexType ecore:name="ModuleRuleType" name="moduleRuleType">
<xsd:sequence>
<xsd:element form="qualified" name="prettyUrl" type="xsd:string"/>
<xsd:element form="qualified" name="internalUrl"
type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType ecore:name="PageRuleType" name="pageRuleType">
<xsd:sequence>
<xsd:element form="qualified" name="prettyUrl" type="xsd:string"/>
<xsd:element form="qualified" name="internalUrl"
type="xsd:string"/>
<xsd:element form="qualified" name="ruleSet" type="ruleSetType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType ecore:name="RuleSetType" name="ruleSetType">
<xsd:sequence>
<xsd:element form="qualified" name="rule" type="ruleType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType ecore:name="RuleType" name="ruleType">
<xsd:attribute name="ref" type="xsd:string" use="required"/>
</xsd:complexType>
</xsd:schema>

I generally wouldn't recommend using nsPrefix="" because once you use
the absent prefix to denote a non-null namespace, the null namespace
becomes unavailable for use. In your case that's no big deal, but if
your model was used with some other model, one with unqualified
elements, it wouldn't work well.

An alternative is to set the prefix on your document root.

documentRoot.getXMLNSPrefixMap().put("",
PrettyurlPackage.eNS_URI);

You might tailor the wizard to do that.


Ed Merks wrote:
> Jens,
>
> Please open a bugzilla for problem of an exception when generating the
> schema. The converter shouldn't pass bad data to the XSD API. I'll
> fix that problem and then I'll look at the rest of this when I get
> back from swimming.
>
>
> Jens Keller wrote:
>> Hi Ed,
>> I've tried this "Export model" functionality and selected "XML
>> Schema" in the pop-up window.
>>
>> But I got an error - InvocationTargetException.
>> The details showed the following
>>
>> java.lang.IllegalArgumentException: The default prefix should
>> represented as null rather than as a zero length String
>> at org.eclipse.xsd.impl.XSDSchemaImpl$1.put(XSDSchemaImpl.java: 768)
>>
>> I'm sure it's because of the nsPrefix="" in the ecore. But if I don't
>> maintain this attribute at all, I get an exception "The namespace
>> prefix 'null' is not well formed.
>>
>> My ecore file is:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <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="prettyurl"
>> nsURI="http://www.test.org/prettyurl" nsPrefix="">
>> <eClassifiers xsi:type="ecore:EClass" name="AppPUrlType">
>> <eAnnotations
>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> <details key="name" value="appPUrlType"/>
>> <details key="kind" value="elementOnly"/>
>> </eAnnotations>
>> <eStructuralFeatures xsi:type="ecore:EReference" name="moduleRule"
>> lowerBound="1"
>> eType="#//ModuleRuleType" containment="true"
>> resolveProxies="false">
>> <eAnnotations
>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> <details key="kind" value="element"/>
>> <details key="name" value="moduleRule"/>
>> <details key="namespace" value="##targetNamespace"/>
>> </eAnnotations>
>> </eStructuralFeatures>
>> <eStructuralFeatures xsi:type="ecore:EReference" name="commonRule"
>> lowerBound="1"
>> upperBound="-1" eType="#//CommonRuleType" containment="true"
>> resolveProxies="false">
>> <eAnnotations
>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> <details key="kind" value="element"/>
>> <details key="name" value="commonRule"/>
>> <details key="namespace" value="##targetNamespace"/>
>> </eAnnotations>
>> </eStructuralFeatures>
>> <eStructuralFeatures xsi:type="ecore:EReference" name="pageRule"
>> lowerBound="1"
>> upperBound="-1" eType="#//PageRuleType" containment="true"
>> resolveProxies="false">
>> <eAnnotations
>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> <details key="kind" value="element"/>
>> <details key="name" value="pageRule"/>
>> <details key="namespace" value="##targetNamespace"/>
>> </eAnnotations>
>> </eStructuralFeatures>
>> </eClassifiers>
>> <eClassifiers xsi:type="ecore:EClass" name="CommonRuleType">
>> <eAnnotations
>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> <details key="name" value="commonRuleType"/>
>> <details key="kind" value="elementOnly"/>
>> </eAnnotations>
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="prettyUrl"
>> lowerBound="1"
>> eType="ecore:EDataType
>> http://www.eclipse.org/emf/2003/XMLType#//String">
>> <eAnnotations
>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> <details key="kind" value="element"/>
>> <details key="name" value="prettyUrl"/>
>> <details key="namespace" value="##targetNamespace"/>
>> </eAnnotations>
>> </eStructuralFeatures>
>> <eStructuralFeatures xsi:type="ecore:EAttribute"
>> name="internalUrl" lowerBound="1"
>> eType="ecore:EDataType
>> http://www.eclipse.org/emf/2003/XMLType#//String">
>> <eAnnotations
>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> <details key="kind" value="element"/>
>> <details key="name" value="internalUrl"/>
>> <details key="namespace" value="##targetNamespace"/>
>> </eAnnotations>
>> </eStructuralFeatures>
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="id"
>> lowerBound="1" eType="ecore:EDataType
>> http://www.eclipse.org/emf/2003/XMLType#//String">
>> <eAnnotations
>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> <details key="kind" value="attribute"/>
>> <details key="name" value="id"/>
>> </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="appPUrl"
>> upperBound="-2"
>> eType="#//AppPUrlType" 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="appPUrl"/>
>> <details key="namespace" value="##targetNamespace"/>
>> </eAnnotations>
>> </eStructuralFeatures>
>> </eClassifiers>
>> <eClassifiers xsi:type="ecore:EClass" name="ModuleRuleType">
>> <eAnnotations
>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> <details key="name" value="moduleRuleType"/>
>> <details key="kind" value="elementOnly"/>
>> </eAnnotations>
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="prettyUrl"
>> lowerBound="1"
>> eType="ecore:EDataType
>> http://www.eclipse.org/emf/2003/XMLType#//String">
>> <eAnnotations
>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> <details key="kind" value="element"/>
>> <details key="name" value="prettyUrl"/>
>> <details key="namespace" value="##targetNamespace"/>
>> </eAnnotations>
>> </eStructuralFeatures>
>> <eStructuralFeatures xsi:type="ecore:EAttribute"
>> name="internalUrl" lowerBound="1"
>> eType="ecore:EDataType
>> http://www.eclipse.org/emf/2003/XMLType#//String">
>> <eAnnotations
>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> <details key="kind" value="element"/>
>> <details key="name" value="internalUrl"/>
>> <details key="namespace" value="##targetNamespace"/>
>> </eAnnotations>
>> </eStructuralFeatures>
>> </eClassifiers>
>> <eClassifiers xsi:type="ecore:EClass" name="PageRuleType">
>> <eAnnotations
>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> <details key="name" value="pageRuleType"/>
>> <details key="kind" value="elementOnly"/>
>> </eAnnotations>
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="prettyUrl"
>> lowerBound="1"
>> eType="ecore:EDataType
>> http://www.eclipse.org/emf/2003/XMLType#//String">
>> <eAnnotations
>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> <details key="kind" value="element"/>
>> <details key="name" value="prettyUrl"/>
>> <details key="namespace" value="##targetNamespace"/>
>> </eAnnotations>
>> </eStructuralFeatures>
>> <eStructuralFeatures xsi:type="ecore:EAttribute"
>> name="internalUrl" lowerBound="1"
>> eType="ecore:EDataType
>> http://www.eclipse.org/emf/2003/XMLType#//String">
>> <eAnnotations
>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> <details key="kind" value="element"/>
>> <details key="name" value="internalUrl"/>
>> <details key="namespace" value="##targetNamespace"/>
>> </eAnnotations>
>> </eStructuralFeatures>
>> <eStructuralFeatures xsi:type="ecore:EReference" name="ruleSet"
>> lowerBound="1"
>> eType="#//RuleSetType" containment="true" resolveProxies="false">
>> <eAnnotations
>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> <details key="kind" value="element"/>
>> <details key="name" value="ruleSet"/>
>> <details key="namespace" value="##targetNamespace"/>
>> </eAnnotations>
>> </eStructuralFeatures>
>> </eClassifiers>
>> <eClassifiers xsi:type="ecore:EClass" name="RuleSetType">
>> <eAnnotations
>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> <details key="name" value="ruleSetType"/>
>> <details key="kind" value="elementOnly"/>
>> </eAnnotations>
>> <eStructuralFeatures xsi:type="ecore:EReference" name="rule"
>> lowerBound="1" eType="#//RuleType"
>> containment="true" resolveProxies="false">
>> <eAnnotations
>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> <details key="kind" value="element"/>
>> <details key="name" value="rule"/>
>> <details key="namespace" value="##targetNamespace"/>
>> </eAnnotations>
>> </eStructuralFeatures>
>> </eClassifiers>
>> <eClassifiers xsi:type="ecore:EClass" name="RuleType">
>> <eAnnotations
>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> <details key="name" value="ruleType"/>
>> <details key="kind" value="empty"/>
>> </eAnnotations>
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="ref"
>> lowerBound="1" eType="ecore:EDataType
>> http://www.eclipse.org/emf/2003/XMLType#//String">
>> <eAnnotations
>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> <details key="kind" value="attribute"/>
>> <details key="name" value="ref"/>
>> </eAnnotations>
>> </eStructuralFeatures>
>> </eClassifiers>
>> </ecore:EPackage>
>>
>>
>>
>>
>> An example for the corresponding XML file:
>>
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <appPUrl xmlns="http://www.test.org/prettyurl">
>> <moduleRule>
>> <prettyUrl>/$i18n:example.ui.prettyurl.test$
>> </prettyUrl>
>> <internalUrl>/example
>> </internalUrl>
>> </moduleRule>
>> <commonRule id="cr1">
>> <prettyUrl>/$i18n:example.ui.prettyurl.test1$/$word$
>> </prettyUrl>
>> <internalUrl>exampleId=$1</internalUrl>
>> </commonRule>
>> <commonRule id="cr2">
>> <prettyUrl>/$word$</prettyUrl>
>> <internalUrl>exampleId=$1</internalUrl>
>> </commonRule>
>> <pageRule>
>> <prettyUrl>/$i18n:example.ui.prettyurl.main$
>> </prettyUrl>
>> <internalUrl>$page_sep$Example$target_sep$list.xhtml
>> </internalUrl>
>> <ruleSet>
>> <rule ref="cr1" />
>> </ruleSet>
>> </pageRule>
>> <pageRule>
>> <prettyUrl>/details</prettyUrl>
>> <internalUrl>$page_sep$Example$target_sep$details.xhtml
>> </internalUrl>
>> <ruleSet>
>> <rule ref="cr2" />
>> </ruleSet>
>> </pageRule>
>> <pageRule>
>> <prettyUrl>/detailsWithParams</prettyUrl>
>> <internalUrl>
>> $page_sep$Example$target_sep$detailsWithParams.xhtml
>> </internalUrl>
>> <ruleSet>
>> <rule ref="cr2" />
>> </ruleSet>
>> </pageRule>
>> <pageRule>
>> <prettyUrl>/dynamicui</prettyUrl>
>> <internalUrl>$page_sep$DynamicUI$target_sep$dynamicUI.xhtml
>> </internalUrl>
>> <ruleSet>
>> <rule ref="cr1" />
>> </ruleSet>
>> </pageRule>
>> </appPUrl>
>>
>> Hope this answers the question regarding serialization?
>>
>> Best regards,
>> Jens

--------------000203040202050402050504
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Jens,<br>
<br>
So I have a patch to fix the bug once you open it.  It then generates
this schema:<br>
<blockquote>&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br>
&lt;xsd:schema xmlns:xsd=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a>
xmlns:ecore=<a class="moz-txt-link-rfc2396E" href="http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/emf/2002/Ecore"</a>
xmlns=<a class="moz-txt-link-rfc2396E" href="http://www.test.org/prettyurl">"http://www.test.org/prettyurl"</a> ecore:nsPrefix=""
ecore:package="prettyurl"
targetNamespace=<a class="moz-txt-link-rfc2396E" href="http://www.test.org/prettyurl">"http://www.test.org/prettyurl"</a>&gt;<br>
  &lt;xsd:element name="appPUrl" type="appPUrlType"/&gt;<br>
  &lt;xsd:complexType ecore:name="AppPUrlType" name="appPUrlType"&gt;<br>
    &lt;xsd:sequence&gt;<br>
      &lt;xsd:element form="qualified" name="moduleRule"
type="moduleRuleType"/&gt;<br>
      &lt;xsd:element form="qualified" maxOccurs="unbounded"
name="commonRule" type="commonRuleType"/&gt;<br>
      &lt;xsd:element form="qualified" maxOccurs="unbounded"
name="pageRule" type="pageRuleType"/&gt;<br>
    &lt;/xsd:sequence&gt;<br>
  &lt;/xsd:complexType&gt;<br>
  &lt;xsd:complexType ecore:name="CommonRuleType"
name="commonRuleType"&gt;<br>
    &lt;xsd:sequence&gt;<br>
      &lt;xsd:element form="qualified" name="prettyUrl"
type="xsd:string"/&gt;<br>
      &lt;xsd:element form="qualified" name="internalUrl"
type="xsd:string"/&gt;<br>
    &lt;/xsd:sequence&gt;<br>
    &lt;xsd:attribute name="id" type="xsd:string" use="required"/&gt;<br>
  &lt;/xsd:complexType&gt;<br>
  &lt;xsd:complexType ecore:name="ModuleRuleType"
name="moduleRuleType"&gt;<br>
    &lt;xsd:sequence&gt;<br>
      &lt;xsd:element form="qualified" name="prettyUrl"
type="xsd:string"/&gt;<br>
      &lt;xsd:element form="qualified" name="internalUrl"
type="xsd:string"/&gt;<br>
    &lt;/xsd:sequence&gt;<br>
  &lt;/xsd:complexType&gt;<br>
  &lt;xsd:complexType ecore:name="PageRuleType" name="pageRuleType"&gt;<br>
    &lt;xsd:sequence&gt;<br>
      &lt;xsd:element form="qualified" name="prettyUrl"
type="xsd:string"/&gt;<br>
      &lt;xsd:element form="qualified" name="internalUrl"
type="xsd:string"/&gt;<br>
      &lt;xsd:element form="qualified" name="ruleSet"
type="ruleSetType"/&gt;<br>
    &lt;/xsd:sequence&gt;<br>
  &lt;/xsd:complexType&gt;<br>
  &lt;xsd:complexType ecore:name="RuleSetType" name="ruleSetType"&gt;<br>
    &lt;xsd:sequence&gt;<br>
      &lt;xsd:element form="qualified" name="rule" type="ruleType"/&gt;<br>
    &lt;/xsd:sequence&gt;<br>
  &lt;/xsd:complexType&gt;<br>
  &lt;xsd:complexType ecore:name="RuleType" name="ruleType"&gt;<br>
    &lt;xsd:attribute name="ref" type="xsd:string" use="required"/&gt;<br>
  &lt;/xsd:complexType&gt;<br>
&lt;/xsd:schema&gt;<br>
</blockquote>
I generally wouldn't recommend using nsPrefix="" because once you use
the absent prefix to denote a non-null namespace, the null namespace
becomes unavailable for use.  In your case that's no big deal, but if
your model was used with some other model, one with unqualified
elements, it wouldn't work well.<br>
<br>
An alternative is to set the prefix on your document root.<br>
<br>
                documentRoot.getXMLNSPrefixMap().put("",
PrettyurlPackage.eNS_URI);<br>
<br>
You might tailor the wizard to do that.<br>
<br>
<br>
Ed Merks wrote:
<blockquote cite="mid:hmqrf0$j51$1@build.eclipse.org" type="cite">Jens,
<br>
<br>
Please open a bugzilla for problem of an exception when generating the
schema.  The converter shouldn't pass bad data to the XSD API.   I'll
fix that problem and then I'll look at the rest of this when I get back
from swimming.
<br>
<br>
<br>
Jens Keller wrote:
<br>
<blockquote type="cite">Hi Ed,
<br>
I've tried this "Export model" functionality and selected "XML Schema"
in the pop-up window.
<br>
<br>
But I got an error - InvocationTargetException.
<br>
The details showed the following
<br>
<br>
java.lang.IllegalArgumentException: The default prefix should
represented as null rather than as a zero length String
<br>
at org.eclipse.xsd.impl.XSDSchemaImpl$1.put(XSDSchemaImpl.java: 768)
<br>
<br>
I'm sure it's because of the nsPrefix="" in the ecore. But if I don't
maintain this attribute at all, I get an exception "The namespace
prefix 'null' is not well formed.
<br>
<br>
My ecore file is:
<br>
<br>
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
<br>
&lt;ecore:EPackage xmi:version="2.0"
<br>
   xmlns:xmi=<a class="moz-txt-link-rfc2396E" href="http://www.omg.org/XMI">"http://www.omg.org/XMI"</a>
xmlns:xsi=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema-instance">"http://www.w3.org/2001/XMLSchema-instance"</a>
<br>
   xmlns:ecore=<a class="moz-txt-link-rfc2396E" href="http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/emf/2002/Ecore"</a> name="prettyurl"
<br>
   nsURI=<a class="moz-txt-link-rfc2396E" href="http://www.test.org/prettyurl">"http://www.test.org/prettyurl"</a> nsPrefix=""&gt;
<br>
 &lt;eClassifiers xsi:type="ecore:EClass" name="AppPUrlType"&gt;
<br>
   &lt;eAnnotations
source=<a class="moz-txt-link-rfc2396E" href="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">"http:///org/eclipse/emf/ecore/util/ExtendedMetaData"</a>&gt;
<br>
     &lt;details key="name" value="appPUrlType"/&gt;
<br>
     &lt;details key="kind" value="elementOnly"/&gt;
<br>
   &lt;/eAnnotations&gt;
<br>
   &lt;eStructuralFeatures xsi:type="ecore:EReference"
name="moduleRule" lowerBound="1"
<br>
       eType="#//ModuleRuleType" containment="true"
resolveProxies="false"&gt;
<br>
     &lt;eAnnotations
source=<a class="moz-txt-link-rfc2396E" href="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">"http:///org/eclipse/emf/ecore/util/ExtendedMetaData"</a>&gt;
<br>
       &lt;details key="kind" value="element"/&gt;
<br>
       &lt;details key="name" value="moduleRule"/&gt;
<br>
       &lt;details key="namespace" value="##targetNamespace"/&gt;
<br>
     &lt;/eAnnotations&gt;
<br>
   &lt;/eStructuralFeatures&gt;
<br>
   &lt;eStructuralFeatures xsi:type="ecore:EReference"
name="commonRule" lowerBound="1"
<br>
       upperBound="-1" eType="#//CommonRuleType" containment="true"
resolveProxies="false"&gt;
<br>
     &lt;eAnnotations
source=<a class="moz-txt-link-rfc2396E" href="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">"http:///org/eclipse/emf/ecore/util/ExtendedMetaData"</a>&gt;
<br>
       &lt;details key="kind" value="element"/&gt;
<br>
       &lt;details key="name" value="commonRule"/&gt;
<br>
       &lt;details key="namespace" value="##targetNamespace"/&gt;
<br>
     &lt;/eAnnotations&gt;
<br>
   &lt;/eStructuralFeatures&gt;
<br>
   &lt;eStructuralFeatures xsi:type="ecore:EReference" name="pageRule"
lowerBound="1"
<br>
       upperBound="-1" eType="#//PageRuleType" containment="true"
resolveProxies="false"&gt;
<br>
     &lt;eAnnotations
source=<a class="moz-txt-link-rfc2396E" href="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">"http:///org/eclipse/emf/ecore/util/ExtendedMetaData"</a>&gt;
<br>
       &lt;details key="kind" value="element"/&gt;
<br>
       &lt;details key="name" value="pageRule"/&gt;
<br>
       &lt;details key="namespace" value="##targetNamespace"/&gt;
<br>
     &lt;/eAnnotations&gt;
<br>
   &lt;/eStructuralFeatures&gt;
<br>
 &lt;/eClassifiers&gt;
<br>
 &lt;eClassifiers xsi:type="ecore:EClass" name="CommonRuleType"&gt;
<br>
   &lt;eAnnotations
source=<a class="moz-txt-link-rfc2396E" href="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">"http:///org/eclipse/emf/ecore/util/ExtendedMetaData"</a>&gt;
<br>
     &lt;details key="name" value="commonRuleType"/&gt;
<br>
     &lt;details key="kind" value="elementOnly"/&gt;
<br>
   &lt;/eAnnotations&gt;
<br>
   &lt;eStructuralFeatures xsi:type="ecore:EAttribute" name="prettyUrl"
lowerBound="1"
<br>
       eType="ecore:EDataType
<a class="moz-txt-link-freetext" href="http://www.eclipse.org/emf/2003/XMLType#//String">http://www.eclipse.org/emf/2003/XMLType#//String</a>"&gt;
<br>
     &lt;eAnnotations
source=<a class="moz-txt-link-rfc2396E" href="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">"http:///org/eclipse/emf/ecore/util/ExtendedMetaData"</a>&gt;
<br>
       &lt;details key="kind" value="element"/&gt;
<br>
       &lt;details key="name" value="prettyUrl"/&gt;
<br>
       &lt;details key="namespace" value="##targetNamespace"/&gt;
<br>
     &lt;/eAnnotations&gt;
<br>
   &lt;/eStructuralFeatures&gt;
<br>
   &lt;eStructuralFeatures xsi:type="ecore:EAttribute"
name="internalUrl" lowerBound="1"
<br>
       eType="ecore:EDataType
<a class="moz-txt-link-freetext" href="http://www.eclipse.org/emf/2003/XMLType#//String">http://www.eclipse.org/emf/2003/XMLType#//String</a>"&gt;
<br>
     &lt;eAnnotations
source=<a class="moz-txt-link-rfc2396E" href="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">"http:///org/eclipse/emf/ecore/util/ExtendedMetaData"</a>&gt;
<br>
       &lt;details key="kind" value="element"/&gt;
<br>
       &lt;details key="name" value="internalUrl"/&gt;
<br>
       &lt;details key="namespace" value="##targetNamespace"/&gt;
<br>
     &lt;/eAnnotations&gt;
<br>
   &lt;/eStructuralFeatures&gt;
<br>
   &lt;eStructuralFeatures xsi:type="ecore:EAttribute" name="id"
lowerBound="1" eType="ecore:EDataType
<a class="moz-txt-link-freetext" href="http://www.eclipse.org/emf/2003/XMLType#//String">http://www.eclipse.org/emf/2003/XMLType#//String</a>"&gt;
<br>
     &lt;eAnnotations
source=<a class="moz-txt-link-rfc2396E" href="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">"http:///org/eclipse/emf/ecore/util/ExtendedMetaData"</a>&gt;
<br>
       &lt;details key="kind" value="attribute"/&gt;
<br>
       &lt;details key="name" value="id"/&gt;
<br>
     &lt;/eAnnotations&gt;
<br>
   &lt;/eStructuralFeatures&gt;
<br>
 &lt;/eClassifiers&gt;
<br>
 &lt;eClassifiers xsi:type="ecore:EClass" name="DocumentRoot"&gt;
<br>
   &lt;eAnnotations
source=<a class="moz-txt-link-rfc2396E" href="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">"http:///org/eclipse/emf/ecore/util/ExtendedMetaData"</a>&gt;
<br>
     &lt;details key="name" value=""/&gt;
<br>
     &lt;details key="kind" value="mixed"/&gt;
<br>
   &lt;/eAnnotations&gt;
<br>
   &lt;eStructuralFeatures xsi:type="ecore:EAttribute" name="mixed"
unique="false" upperBound="-1"
<br>
       eType="ecore:EDataType
<a class="moz-txt-link-freetext" href="http://www.eclipse.org/emf/2002/Ecore#//EFeatureMapEntry">http://www.eclipse.org/emf/2002/Ecore#//EFeatureMapEntry</a>"&gt;
<br>
     &lt;eAnnotations
source=<a class="moz-txt-link-rfc2396E" href="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">"http:///org/eclipse/emf/ecore/util/ExtendedMetaData"</a>&gt;
<br>
       &lt;details key="kind" value="elementWildcard"/&gt;
<br>
       &lt;details key="name" value=":mixed"/&gt;
<br>
     &lt;/eAnnotations&gt;
<br>
   &lt;/eStructuralFeatures&gt;
<br>
   &lt;eStructuralFeatures xsi:type="ecore:EReference"
name="xMLNSPrefixMap" upperBound="-1"
<br>
       eType="ecore:EClass
<a class="moz-txt-link-freetext" href=" http://www.eclipse.org/emf/2002/Ecore#//EStringToStringMapEn try"> http://www.eclipse.org/emf/2002/Ecore#//EStringToStringMapEn try</a>"
<br>
       transient="true" containment="true" resolveProxies="false"&gt;
<br>
     &lt;eAnnotations
source=<a class="moz-txt-link-rfc2396E" href="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">"http:///org/eclipse/emf/ecore/util/ExtendedMetaData"</a>&gt;
<br>
       &lt;details key="kind" value="attribute"/&gt;
<br>
       &lt;details key="name" value="xmlns:prefix"/&gt;
<br>
     &lt;/eAnnotations&gt;
<br>
   &lt;/eStructuralFeatures&gt;
<br>
   &lt;eStructuralFeatures xsi:type="ecore:EReference"
name="xSISchemaLocation" upperBound="-1"
<br>
       eType="ecore:EClass
<a class="moz-txt-link-freetext" href=" http://www.eclipse.org/emf/2002/Ecore#//EStringToStringMapEn try"> http://www.eclipse.org/emf/2002/Ecore#//EStringToStringMapEn try</a>"
<br>
       transient="true" containment="true" resolveProxies="false"&gt;
<br>
     &lt;eAnnotations
source=<a class="moz-txt-link-rfc2396E" href="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">"http:///org/eclipse/emf/ecore/util/ExtendedMetaData"</a>&gt;
<br>
       &lt;details key="kind" value="attribute"/&gt;
<br>
       &lt;details key="name" value="xsi:schemaLocation"/&gt;
<br>
     &lt;/eAnnotations&gt;
<br>
   &lt;/eStructuralFeatures&gt;
<br>
   &lt;eStructuralFeatures xsi:type="ecore:EReference" name="appPUrl"
upperBound="-2"
<br>
       eType="#//AppPUrlType" volatile="true" transient="true"
derived="true" containment="true"
<br>
       resolveProxies="false"&gt;
<br>
     &lt;eAnnotations
source=<a class="moz-txt-link-rfc2396E" href="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">"http:///org/eclipse/emf/ecore/util/ExtendedMetaData"</a>&gt;
<br>
       &lt;details key="kind" value="element"/&gt;
<br>
       &lt;details key="name" value="appPUrl"/&gt;
<br>
       &lt;details key="namespace" value="##targetNamespace"/&gt;
<br>
     &lt;/eAnnotations&gt;
<br>
   &lt;/eStructuralFeatures&gt;
<br>
 &lt;/eClassifiers&gt;
<br>
 &lt;eClassifiers xsi:type="ecore:EClass" name="ModuleRuleType"&gt;
<br>
   &lt;eAnnotations
source=<a class="moz-txt-link-rfc2396E" href="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">"http:///org/eclipse/emf/ecore/util/ExtendedMetaData"</a>&gt;
<br>
     &lt;details key="name" value="moduleRuleType"/&gt;
<br>
     &lt;details key="kind" value="elementOnly"/&gt;
<br>
   &lt;/eAnnotations&gt;
<br>
   &lt;eStructuralFeatures xsi:type="ecore:EAttribute" name="prettyUrl"
lowerBound="1"
<br>
       eType="ecore:EDataType
<a class="moz-txt-link-freetext" href="http://www.eclipse.org/emf/2003/XMLType#//String">http://www.eclipse.org/emf/2003/XMLType#//String</a>"&gt;
<br>
     &lt;eAnnotations
source=<a class="moz-txt-link-rfc2396E" href="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">"http:///org/eclipse/emf/ecore/util/ExtendedMetaData"</a>&gt;
<br>
       &lt;details key="kind" value="element"/&gt;
<br>
       &lt;details key="name" value="prettyUrl"/&gt;
<br>
       &lt;details key="namespace" value="##targetNamespace"/&gt;
<br>
     &lt;/eAnnotations&gt;
<br>
   &lt;/eStructuralFeatures&gt;
<br>
   &lt;eStructuralFeatures xsi:type="ecore:EAttribute"
name="internalUrl" lowerBound="1"
<br>
       eType="ecore:EDataType
<a class="moz-txt-link-freetext" href="http://www.eclipse.org/emf/2003/XMLType#//String">http://www.eclipse.org/emf/2003/XMLType#//String</a>"&gt;
<br>
     &lt;eAnnotations
source=<a class="moz-txt-link-rfc2396E" href="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">"http:///org/eclipse/emf/ecore/util/ExtendedMetaData"</a>&gt;
<br>
       &lt;details key="kind" value="element"/&gt;
<br>
       &lt;details key="name" value="internalUrl"/&gt;
<br>
       &lt;details key="namespace" value="##targetNamespace"/&gt;
<br>
     &lt;/eAnnotations&gt;
<br>
   &lt;/eStructuralFeatures&gt;
<br>
 &lt;/eClassifiers&gt;
<br>
 &lt;eClassifiers xsi:type="ecore:EClass" name="PageRuleType"&gt;
<br>
   &lt;eAnnotations
source=<a class="moz-txt-link-rfc2396E" href="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">"http:///org/eclipse/emf/ecore/util/ExtendedMetaData"</a>&gt;
<br>
     &lt;details key="name" value="pageRuleType"/&gt;
<br>
     &lt;details key="kind" value="elementOnly"/&gt;
<br>
   &lt;/eAnnotations&gt;
<br>
   &lt;eStructuralFeatures xsi:type="ecore:EAttribute" name="prettyUrl"
lowerBound="1"
<br>
       eType="ecore:EDataType
<a class="moz-txt-link-freetext" href="http://www.eclipse.org/emf/2003/XMLType#//String">http://www.eclipse.org/emf/2003/XMLType#//String</a>"&gt;
<br>
     &lt;eAnnotations
source=<a class="moz-txt-link-rfc2396E" href="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">"http:///org/eclipse/emf/ecore/util/ExtendedMetaData"</a>&gt;
<br>
       &lt;details key="kind" value="element"/&gt;
<br>
       &lt;details key="name" value="prettyUrl"/&gt;
<br>
       &lt;details key="namespace" value="##targetNamespace"/&gt;
<br>
     &lt;/eAnnotations&gt;
<br>
   &lt;/eStructuralFeatures&gt;
<br>
   &lt;eStructuralFeatures xsi:type="ecore:EAttribute"
name="internalUrl" lowerBound="1"
<br>
       eType="ecore:EDataType
<a class="moz-txt-link-freetext" href="http://www.eclipse.org/emf/2003/XMLType#//String">http://www.eclipse.org/emf/2003/XMLType#//String</a>"&gt;
<br>
     &lt;eAnnotations
source=<a class="moz-txt-link-rfc2396E" href="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">"http:///org/eclipse/emf/ecore/util/ExtendedMetaData"</a>&gt;
<br>
       &lt;details key="kind" value="element"/&gt;
<br>
       &lt;details key="name" value="internalUrl"/&gt;
<br>
       &lt;details key="namespace" value="##targetNamespace"/&gt;
<br>
     &lt;/eAnnotations&gt;
<br>
   &lt;/eStructuralFeatures&gt;
<br>
   &lt;eStructuralFeatures xsi:type="ecore:EReference" name="ruleSet"
lowerBound="1"
<br>
       eType="#//RuleSetType" containment="true"
resolveProxies="false"&gt;
<br>
     &lt;eAnnotations
source=<a class="moz-txt-link-rfc2396E" href="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">"http:///org/eclipse/emf/ecore/util/ExtendedMetaData"</a>&gt;
<br>
       &lt;details key="kind" value="element"/&gt;
<br>
       &lt;details key="name" value="ruleSet"/&gt;
<br>
       &lt;details key="namespace" value="##targetNamespace"/&gt;
<br>
     &lt;/eAnnotations&gt;
<br>
   &lt;/eStructuralFeatures&gt;
<br>
 &lt;/eClassifiers&gt;
<br>
 &lt;eClassifiers xsi:type="ecore:EClass" name="RuleSetType"&gt;
<br>
   &lt;eAnnotations
source=<a class="moz-txt-link-rfc2396E" href="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">"http:///org/eclipse/emf/ecore/util/ExtendedMetaData"</a>&gt;
<br>
     &lt;details key="name" value="ruleSetType"/&gt;
<br>
     &lt;details key="kind" v


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: XSD schema not generated when ns prefix empty in ecore? [message #519009 is a reply to message #518746] Fri, 05 March 2010 16:44 Go to previous message
keller_jens is currently offline keller_jensFriend
Messages: 21
Registered: March 2010
Location: Germany
Junior Member
Hi Ed,
I've reported the bug, id=304839.

Best regards,
Jens
Previous Topic:[CDO] Undo adding first object to a list throws AssertionFailedException
Next Topic:Run from Command Line
Goto Forum:
  


Current Time: Sat Apr 20 00:48:27 GMT 2024

Powered by FUDForum. Page generated in 0.03181 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top