Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sapphire » Element ordering not according to XSD (with several files)
Element ordering not according to XSD (with several files) [message #1060658] Mon, 27 May 2013 10:42 Go to next message
kon f is currently offline kon f
Messages: 112
Registered: March 2012
Senior Member
Hey,

I found this post. I extended the example being able to include several xsd files (useful if the schema is big and needs to be spread over several xsd files). I use include because I want to contribute to the same namespace.

On the given example, I just moved the type definition to a separate xsd file.

schema.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
	targetNamespace="http://www.roded.com/xsdtestcase" xmlns="http://www.roded.com/xsdtestcase">
	<xs:include schemaLocation="type.xsd" />
	<xs:element name="XSDTestCaseModel" type="XSDTestCaseModelType" />
</xs:schema>


type.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
	targetNamespace="http://www.roded.com/xsdtestcase" xmlns="http://www.roded.com/xsdtestcase"
	elementFormDefault="qualified">
	<xs:complexType name="XSDTestCaseModelType">
		<xs:sequence>
			<xs:element name="ValueA" type="xs:string"></xs:element>
			<xs:element name="ValueB" type="xs:string"></xs:element>
			<xs:element name="ValueC" type="xs:string"></xs:element>
		</xs:sequence>
	</xs:complexType>
</xs:schema>


IXSDTestCaseModel
package com.modelity.eclipse.structures.sapphire.report.xsdtestcase;

import org.eclipse.sapphire.modeling.IModelElement;
import org.eclipse.sapphire.modeling.ModelElementType;
import org.eclipse.sapphire.modeling.Value;
import org.eclipse.sapphire.modeling.ValueProperty;
import org.eclipse.sapphire.modeling.annotations.GenerateImpl;
import org.eclipse.sapphire.modeling.annotations.Label;
import org.eclipse.sapphire.modeling.xml.annotations.XmlNamespace;
import org.eclipse.sapphire.modeling.xml.annotations.XmlSchema;

@GenerateImpl
@XmlNamespace(uri = "http://www.roded.com/xsdtestcase")
@XmlSchema(namespace = "http://www.roded.com/xsdtestcase", location = "http://www.roded.com/xsdtestcase/1.0")
public interface IXSDTestCaseModel extends IModelElement {

    ModelElementType TYPE = new ModelElementType(IXSDTestCaseModel.class);

    // *** ValueA ***
    @Label(standard = "ValueA")
    ValueProperty PROP_VALUE_A = new ValueProperty(TYPE, "ValueA");

    Value<String> getValueA();

    void setValueA(String value);

    // *** ValueB ***
    @Label(standard = "ValueB")
    ValueProperty PROP_VALUE_B = new ValueProperty(TYPE, "ValueB");

    Value<String> getValueB();

    void setValueB(String value);

    // *** ValueA ***
    @Label(standard = "ValueC")
    ValueProperty PROP_VALUE_C = new ValueProperty(TYPE, "ValueC");

    Value<String> getValueC();

    void setValueC(String value);
}


plugin.xml
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension point="org.eclipse.ui.editors">
  <editor
    id="com.modelity.eclipse.structures.sapphire.report.xsdtestcase.IXSDTestCaseModel"
    name="test case xsd"
    filenames="xsdtestcase.xml"
    default="true">
    <class class="org.eclipse.sapphire.ui.swt.xml.editor.SapphireEditorForXml">
      <parameter name="sdef" value="com.modelity.eclipse.structures.sapphire.report.xsdtestcase.testcasemodel"/>
    </class>
  </editor>
</extension>
<extension
      point="org.eclipse.wst.xml.core.catalogContributions">
   <catalogContribution>
      <system
            systemId="http://www.roded.com/xsdtestcase/1.0"
            uri="schema/schema.xsd">
      </system>
   </catalogContribution>
</extension>
</plugin>


Am I doing something wrong? Thank you!

Kon
Re: Element ordering not according to XSD (with several files) [message #1060848 is a reply to message #1060658] Tue, 28 May 2013 12:04 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin Komissarchik
Messages: 935
Registered: July 2009
Senior Member
I see only one schema contributed to the catalog. You need to contribute both schemas and your include should ideally be a fully-qualified URL. The system will attempt to resolve relative paths, but the result may not be what you expect. In your setup, it's trying and failing to resolve "http://www.roded.com/xsdtestcase/type.xsd".

- Konstantin
Re: Element ordering not according to XSD (with several files) [message #1060930 is a reply to message #1060848] Wed, 29 May 2013 04:16 Go to previous messageGo to next message
kon f is currently offline kon f
Messages: 112
Registered: March 2012
Senior Member
Hey Konstantin,

thank you for your reply. I adjusted the plugin.xml, but I'm not sure if my include statement is right.

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension point="org.eclipse.ui.editors">
  <editor id="com.modelity.eclipse.structures.sapphire.report.xsdtestcase.IXSDTestCaseModel"
    name="test case xsd"
    filenames="xsdtestcase.xml"
    default="true">
    <class class="org.eclipse.sapphire.ui.swt.xml.editor.SapphireEditorForXml">
      <parameter name="sdef" value="com.modelity.eclipse.structures.sapphire.report.xsdtestcase.testcasemodel"/>
    </class>
  </editor>
</extension>
<extension
      point="org.eclipse.wst.xml.core.catalogContributions">
   <catalogContribution>
      <system
            systemId="http://www.roded.com/xsdtestcase/1.0"
            uri="schema/schema.xsd">
      </system>
      <system
            systemId="http://www.roded.com/xsdtestcase/1.0"
            uri="schema/type.xsd">
      </system>
   </catalogContribution>
</extension>
</plugin>


I searched to find an example of an fully qualified name. That's what I tried but it does not work:

<xs:include schemaLocation="platform:/plugin/com.modelity.eclipse.structures.sapphire.report.xsdtestcase/schema/type.xsd" />


I'm not sure if this is the right approach. Do you have any suggestions? Thank you.

Kon
Re: Element ordering not according to XSD (with several files) [message #1061027 is a reply to message #1060930] Wed, 29 May 2013 10:57 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin Komissarchik
Messages: 935
Registered: July 2009
Senior Member
You've mapped two files to the same URL with your catalog contribution. That will not work. You need something like this:

<extension
      point="org.eclipse.wst.xml.core.catalogContributions">
   <catalogContribution>
      <system
            systemId="http://www.roded.com/xsdtestcase/1.0/schema.xsd"
            uri="schema/schema.xsd">
      </system>
      <system
            systemId="http://www.roded.com/xsdtestcase/1.0/type.xsd"
            uri="schema/type.xsd">
      </system>
   </catalogContribution>
</extension>


In the include statement, you should use the full URL of the schema as published on the Web or declared in the catalog. So, if you are using the above declarations, your include would look like this:

<xs:include schemaLocation="http://www.roded.com/xsdtestcase/1.0/type.xsd" />
Re: Element ordering not according to XSD (with several files) [message #1061804 is a reply to message #1061027] Tue, 04 June 2013 03:43 Go to previous message
kon f is currently offline kon f
Messages: 112
Registered: March 2012
Senior Member
Hey Konstantin,

thank you. I adjusted the plugin.xml and the actual include in the schema file in the way you suggested - now it's working Smile Here the final result if anyone else is having the same issue:

schema.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.roded.com/xsdtestcase"
	xmlns="http://www.roded.com/xsdtestcase">
	<xs:include schemaLocation="http://www.roded.com/xsdtestcase/1.0/type.xsd" />
	<xs:element name="XSDTestCaseModel" type="XSDTestCaseModelType" />
</xs:schema>


type.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.roded.com/xsdtestcase"
	xmlns="http://www.roded.com/xsdtestcase" elementFormDefault="qualified">
	<xs:complexType name="XSDTestCaseModelType">
		<xs:sequence>
			<xs:element name="ValueA" type="xs:string"></xs:element>
			<xs:element name="ValueB" type="xs:string"></xs:element>
			<xs:element name="ValueC" type="xs:string"></xs:element>
		</xs:sequence>
	</xs:complexType>
</xs:schema>


And the xml file in the running sapphire editor:

xsdtestcase.xml
<?xml version="1.0" encoding="UTF-8"?>
<XSDTestCaseModel xmlns="http://www.roded.com/xsdtestcase"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.roded.com/xsdtestcase http://www.roded.com/xsdtestcase/1.0/schema.xsd">
   <ValueA>1</ValueA>
   ...
</XSDTestCaseModel>


Thank you!

Kon

Update: I've found this article about Eclipse XML Catalor afterwards - definitely worth reading!

[Updated on: Mon, 17 June 2013 12:12]

Report message to a moderator

Previous Topic:Heterogeneous list with no common property
Next Topic:Substring with expression language
Goto Forum:
  


Current Time: Wed Jul 23 22:30:26 EDT 2014

Powered by FUDForum. Page generated in 0.01663 seconds