]>
git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.core/src/main/java/org/argeo/slc/unit/UnitXmlUtils.java
1 package org
.argeo
.slc
.unit
;
3 import java
.io
.IOException
;
5 import javax
.xml
.transform
.Source
;
7 import junit
.framework
.TestCase
;
9 import org
.springframework
.xml
.validation
.XmlValidator
;
10 import org
.springframework
.xml
.xsd
.XsdSchema
;
11 import org
.xml
.sax
.SAXParseException
;
13 import org
.apache
.commons
.logging
.Log
;
14 import org
.apache
.commons
.logging
.LogFactory
;
16 public abstract class UnitXmlUtils
{
17 private final static Log log
= LogFactory
.getLog(UnitXmlUtils
.class);
19 public static void assertXsdSchemaValidation(XsdSchema schema
, Source source
)
21 XmlValidator validator
= schema
.createValidator();
22 assertXmlValidation(validator
, source
);
25 public static void assertXmlValidation(XmlValidator validator
, Source source
)
27 SAXParseException
[] exceptions
= validator
.validate(source
);
28 if (exceptions
.length
!= 0) {
29 for (SAXParseException ex
: exceptions
) {
30 log
.error(ex
.getMessage());
32 TestCase
.fail("Could not validate");
36 private UnitXmlUtils() {