質問

This is really getting into my nerve...

I already have all the ecore models up and running but I've been unable to load an XML file into those models.This is the code I'm using to do so:

        ResultType res = ScheduleTableFactory.eINSTANCE.createResultType(); 
    ByteArrayInputStream is;

    try {

        /* Read XML file to a string and send it to a buffer */
        is = new ByteArrayInputStream((this.xml2String(fileName)).getBytes("UTF-8"));

        ResourceSet rs = new ResourceSetImpl();
        rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xml", 
        new ScheduleTableResourceFactoryImpl());

        Map options = new Properties();

        // Just a dummy url to specify the type of the document
        URI uri = URI.createURI("http://www.baderous.de/doomz/trankz.xml");
        ScheduleTableResourceImpl resource = (ScheduleTableResourceImpl) rs.createResource(uri);    

        ((org.eclipse.emf.ecore.resource.Resource) resource).load(is, options);
    }
    catch (IOException e) {

        e.printStackTrace();
        System.exit(0);
    }

After a long struggle, now it's reaching the last method inside the try block, but it's giving me this error:

org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Value '2013-04-23.07:55:00' is not legal. (http://www.baderous.de/doomz/trankz.xml, 4, 56)

I wanted to be more precise in this description, but I'm quite new with EMF, so I will just stick to the basics. I would be really grateful if you can help me on this issue.

Thanks in advance!

役に立ちましたか?

解決 2

The problem was that the date format couldn't be handled, so I had to edit the model in EMf, and now I'm treating dates as Strings.And now everything is working properly!

Hope that in the future someone can benefit from this answer, and save some time.

他のヒント

Try to enclose the value '2013-04-23.07:55:00' in the block CDATA.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top