Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMF/XSD invalid xml
EMF/XSD invalid xml [message #897314] Mon, 23 July 2012 14:55 Go to next message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 244
Registered: July 2009
Senior Member
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

Re: EMF/XSD invalid xml [message #897373 is a reply to message #897314] Mon, 23 July 2012 20:02 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30353
Registered: July 2009
Senior Member
It's impossible to comment on this without information about your schema.


On 23/07/2012 4:56 PM, Sir Wayne wrote:
> 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.
Previous Topic:Problem accessing resources in other depending projects
Next Topic:Transform exiting model and save to .uml
Goto Forum:
  


Current Time: Mon Aug 19 22:20:14 GMT 2019

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

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

Back to the top