My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* Copyright 2012 stanislawbartkowski@gmail.com
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gwtmodel.mapxml;

import java.io.IOException;
import java.net.URL;

import javax.xml.XMLConstants;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;

import org.xml.sax.SAXException;

/**
* @author hotel Utility class for XML validation. In case of error throws
* exception
*/
public class VerifyXML {

private VerifyXML() {
}

/**
*
* @param xsdFile
* URL of xsd file (XML schema)
* @param sou
* Source XML file (in shape of StreamSource)
*
* @throws SAXException
* @throws IOException
*/
public static void verify(URL xsdFile, StreamSource sou)
throws SAXException, IOException {
SchemaFactory fa = SchemaFactory
.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema se = fa.newSchema(xsdFile);
Validator validator = se.newValidator();
validator.validate(sou);
}

}

Change log

r526 by stanislawbartkowski on Jan 1, 2012   Diff
[No log message]
Go to: 
Project members, sign in to write a code review

Older revisions

r513 by stanislawbartkowski on Dec 26, 2011   Diff
[No log message]
r501 by stanislawbartkowski on Dec 11, 2011   Diff
XML server - client data
All revisions of this file

File info

Size: 1668 bytes, 54 lines

File properties

svn:mime-type
text/plain
Powered by Google Project Hosting