Skip to main content



      Home
Home » Archived » Sapphire » Element ordering not according to XSD
Element ordering not according to XSD [message #771461] Tue, 27 December 2011 05:27 Go to next message
Eclipse UserFriend
Hi,
As mentioned in a previous post, I'm having some issues regarding XSD based XML element ordering in a sapphire editor.
I created a test case similar to the issue I'm experiencing, attached below are the relevant files.
(For some reason, I couldn't get Sapphire to include the schema directives automatically in the XML, so I've added it there myself.)
The end result is that when editing the XML in the Sapphire editor, XSD based validation works in SSE's source tab (marks invalid elements and wrong ordering), but when starting a new model with the Sapphire editor, if I input ValueC before ValueA (in the testcase below): element ordering is not retained and ValueA is added after ValueC.
Many thanks,
Roded

The 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:element name="XSDTestCaseModel">
    	<xs:complexType>
    		<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:element>
        
</xs:schema>


The model:
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

@XmlSchema(location = "xsdtestcase.xsd", namespace = "http://www.roded.com/xsdtestcase")
@XmlNamespace(uri = "http://www.roded.com/xsdtestcase")

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);
}



The sdef:
<?xml version="1.0" encoding="UTF-8"?>
<definition>
    <editor-page>
        <id>@xsdtestcase.editor</id>
        <root-node>
            <node>
                <label>IXSDTestCaseModel</label>
                <section>
                    <content>
                        <property-editor>ValueA</property-editor>
                        <property-editor>ValueB</property-editor>
                        <property-editor>ValueC</property-editor>
                    </content>
                </section>
            </node>
        </root-node>
    </editor-page>
</definition>


Output 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 xsdtestcase.xsd ">
    <ValueC>3</ValueC>
    <ValueA>1</ValueA>
    <ValueB>2</ValueB>
</XSDTestCaseModel>

Re: Element ordering not according to XSD [message #771569 is a reply to message #771461] Tue, 27 December 2011 11:50 Go to previous messageGo to next message
Eclipse UserFriend
One thing that jumps out at me is that schema location is specified as "xsdtestcase.xsd". It is possible that Sapphire is simply not finding your schema. Schema location URL should be in public URL format, but you can re-direct the lookup to a schema packaged within the plugin via org.eclipse.wst.xml.core.catalogContributions extension point. See the samples. In particular, entries in plugin.xml file, like this one:

  <extension point="org.eclipse.wst.xml.core.catalogContributions">
    <catalogContribution>
      <system
        systemId="http://www.eclipse.org/sapphire/samples/address/1.0"
        uri="schemas/Address.xsd"/>
      <system
        systemId="http://www.eclipse.org/sapphire/samples/contacts/1.0"
        uri="schemas/Contacts.xsd"/>
    </catalogContribution>
  </extension>
Re: Element ordering not according to XSD [message #771626 is a reply to message #771569] Tue, 27 December 2011 14:28 Go to previous messageGo to next message
Eclipse UserFriend
It was exactly that Smile
Many thanks, great solution.
Re: Element ordering not according to XSD [message #947686 is a reply to message #771569] Wed, 17 October 2012 06:15 Go to previous messageGo to next message
Eclipse UserFriend
Konstantin Komissarchik wrote on Tue, 27 December 2011 11:50
Schema location URL should be in public URL format


I have the same problem illustrated above, but I couldn't solve it. I put my XSD in the "src" folder directly. What do you mean by "public URL format" ?
Re: Element ordering not according to XSD [message #947898 is a reply to message #947686] Wed, 17 October 2012 10:57 Go to previous message
Eclipse UserFriend
Quote:
What do you mean by "public URL format"?


http://...

I recommend comparing what you are doing with the contacts sample.

- Konstantin
Previous Topic:Getting XmlElement of an IModelElement
Next Topic:Simple custom constraint on a property editor
Goto Forum:
  


Current Time: Tue Jul 08 03:42:52 EDT 2025

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

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

Back to the top