Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » XPAND and XSD adapter: root not found(No Definition 'templates::main::Root for type::AnyType' found!)
icon5.gif  XPAND and XSD adapter: root not found [message #498173] Sun, 15 November 2009 15:07 Go to next message
Marco  is currently offline Marco Friend
Messages: 216
Registered: August 2009
Senior Member
Hi,

XPAND does not find the root element definition.
SEVERE: Error in Component  of type org.eclipse.xpand2.Generator: 
	EvaluationException : No Definition 'templates::main::Root for type::AnyType' found!
	[23,38] on line 1 'EXPAND templates::main::Root FOR model'


<workflow>
	<!-- load the file -->
	<component class="org.eclipse.xtend.typesystem.xsd.XMLReader">
		<modelSlot value="model" />
		<uri value="root.xml" />
		<metaModel id="mm" class="org.eclipse.xtend.typesystem.xsd.XSDMetaModel">
		    <schemaFile value="root.xsd" />
		</metaModel>
		<!--<option key="DEFAULT_NAMESPACE" val="http://www.example.org/test" />-->
	</component>

	<!-- clean up the target directory -->
	<component class="org.eclipse.emf.mwe.utils.DirectoryCleaner">
		<directory value="src-gen/mypackage" />
	</component>

	<!--<component class="org.eclipse.xtend.typesystem.xsd.XMLWriter">
		<metaModel idRef="mm" />
		<modelSlot value="model" />
		<uri value="src-gen/out.xml" />
	</component> -->

	<!-- generate some code -->
	<component class="org.eclipse.xpand2.Generator">
		<metaModel idRef="mm" />
		<expand value="templates::main::Root FOR model" />
		<outlet path="src-gen" />
	</component>

</workflow>


«IMPORT root»

«DEFINE Root FOR RootType»
	«FILE "entity"»
		ENTITY:
		«EXPAND entity FOREACH entity»
	«ENDFILE»
«ENDDEFINE»

«DEFINE entity FOR EntityType»
	«name.value»
«ENDDEFINE»


<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="Entity">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Name"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="Name">
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base="xs:string">
          <xs:attribute type="xs:string" name="Type" use="optional"/>
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>
  <xs:element name="root">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Entity" maxOccurs="unbounded" minOccurs="0"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>


<?xml version="1.0" encoding="UTF-8"?>
<root xmlns="http://www.example.org/test" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Entity>
    <Name Type="String">ABC</Name>
  </Entity>
</root>


For easy reproduction I uploaded the project: http://drop.io/aeypm9d

Please show me what I cannot find myself.

br
Marco
Re: XPAND and XSD adapter: root not found [message #498175 is a reply to message #498173] Sun, 15 November 2009 15:52 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hi the problem is that your xsd does not have any target namespace set

you can workaround this modifing your xmlreader like this

<component class="org.eclipse.xtend.typesystem.xsd.XMLReader">
		<modelSlot value="model" />
		<uri value="root.xml" />

		<option key="NAMESPACE_MAP">
		  <val class="org.eclipse.xtend.typesystem.xsd.lib.MapBean">
		    <mapping to=""
		             from="http://www.example.org/test" />
		  </val>
		</option>

		<metaModel id="mm" class="org.eclipse.xtend.typesystem.xsd.XSDMetaModel">
		    <schemaFile value="root.xsd" />
		</metaModel>
	</component>


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Sun, 15 November 2009 16:50]

Report message to a moderator

Re: XPAND and XSD adapter: root not found [message #498189 is a reply to message #498175] Sun, 15 November 2009 17:54 Go to previous messageGo to next message
Marco  is currently offline Marco Friend
Messages: 216
Registered: August 2009
Senior Member
Hi Christian,

Thank you for the answer. But this time I am not sure that it is right.

First, I am quite sure that it worked before with other XSDs without target namespace.

Second, I tried it as shown below, and the error message is still the same.

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3.org/2001/XMLSchema" >
  <xs:element name="Entity">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="xs:Name"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="Name">
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base="xs:string">
          <xs:attribute type="xs:string" name="Type" use="optional"/>
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>
  <xs:element name="root">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="xs:Entity" maxOccurs="unbounded" minOccurs="0"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>


And I adapted the DEFAULT_NAMESPACE option, and tried without it.

The original project is still on drop.io, if you want to check it.

br
Marco
Re: XPAND and XSD adapter: root not found [message #498190 is a reply to message #498189] Sun, 15 November 2009 18:01 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hi,

the target namespace is obvious wrong but you should still be able to change it with NAMESPACE_MAP


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Sun, 15 November 2009 18:04]

Report message to a moderator

Re: XPAND and XSD adapter: root not found [message #498195 is a reply to message #498190] Sun, 15 November 2009 19:39 Go to previous message
Marco  is currently offline Marco Friend
Messages: 216
Registered: August 2009
Senior Member
Hi,

I found the problem. Actually I don't need a target namespace. There was just the obsolete line about the namespace in the xml instance.

br
Marco
Previous Topic:Doubt in Xpand template
Next Topic:[Xtext+Xpand] Problem with MWE code generator workflow
Goto Forum:
  


Current Time: Fri Apr 19 23:23:37 GMT 2024

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

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

Back to the top