Skip to content
Snippets Groups Projects
Commit 4888e2e0 authored by felmer's avatar felmer
Browse files

SE-146 Schema validation for quantML files added

SVN: 12910
parent 5daf5201
No related branches found
No related tags found
No related merge requests found
......@@ -27,6 +27,7 @@
</fileset>
<fileset dir="source">
<include name="**/*.sql" />
<include name="**/*.xsd" />
</fileset>
</recursive-jar>
</target>
......
......@@ -2,8 +2,8 @@
<quantML>
<msQuantification>
<source>msSoft</source>
<valid>true</valid>
<comment>no comment</comment>
<valid>true</valid>
<registrationDate>04-Apr-1980 12:00:21</registrationDate>
<registrator>John Doe</registrator>
<concentration>
......
......@@ -17,16 +17,23 @@
package ch.systemsx.cisd.yeastx.quant;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.SchemaOutputResolver;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.UnmarshallerHandler;
import javax.xml.transform.Result;
import javax.xml.transform.stream.StreamResult;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import ch.systemsx.cisd.base.exceptions.CheckedExceptionTunnel;
import ch.systemsx.cisd.common.utilities.XMLInfraStructure;
import ch.systemsx.cisd.yeastx.quant.dto.MSQuantificationsDTO;
/**
......@@ -46,6 +53,9 @@ class QuantMLParser
private QuantMLParser()
{
this.unmarshaller = createUnmarshaller();
unmarshaller.setSchema(XMLInfraStructure.createSchema("/"
+ QuantMLParser.class.getPackage().getName().replace('.', '/')
+ "/quantml-schema.xsd"));
}
private static Unmarshaller createUnmarshaller()
......@@ -90,7 +100,7 @@ class QuantMLParser
throw new IllegalArgumentException("Wrong type: " + object);
}
return (MSQuantificationsDTO) object;
} catch (JAXBException ex)
} catch (Exception ex)
{
throw CheckedExceptionTunnel.wrapIfNecessary(ex);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment