Hello,
I generating an EMF Model using XML Schema (XSD). But the xsd:sequence tag is observed wrong.
I loading a config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<name>Name</name>
<tests>
<test>Test</test>
</tests>
</config>
and save it in a config1.xml. Resultat:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<tests>
<test>Test</test>
</tests>
<name>Name</name>
</config>
TestMain
public class TestMain
{
/**
* @param args
*/
public static void main(String[] args)
{
OutputPackageImpl.init();
OutputXMLProcessor processor = new OutputXMLProcessor();
// Create a load resource
Resource xmlResource2 = new OutputResourceFactoryImpl().createResource(null);
try
{
Resource xmlResource = processor.load("config.xml", null);
xmlResource2.getContents().add(xmlResource.getContents().get(0));
processor.save(new FileOutputStream(new File("config1.xml")), xmlResource2, null);
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Why is the <name> tag at the end of the file. So the xml is invalid.
I think the problem is the xsd:extension
<xsd:complexType name="config">
<xsd:complexContent>
<xsd:extension base="tns:abstractConfig">
<xsd:sequence>
<xsd:element name="tests" type="tns:..." />
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
[Updated on: Mon, 23 July 2012 15:14]
Report message to a moderator