Element ordering not according to XSD [message #771461] |
Tue, 27 December 2011 10:27 |
Roded Bahat Messages: 152 Registered: August 2011 |
Senior Member |
|
|
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>
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03446 seconds