Biblioteca Java - Blame information for rev 3
Subversion Repositories:
Rev | Author | Line No. | Line |
---|---|---|---|
3 | mihai | 1 | package lab.scd.xml.dom; |
2 | import javax.xml.parsers.*; | ||
3 | |||
4 | /** | ||
5 | * Clasa verifica daca un document xml este corect formatat (respecta | ||
6 | * specificatiile xml). | ||
7 | */ | ||
8 | public class VerificaXML { | ||
9 | |||
10 | public static void main(String[] args) | ||
11 | { | ||
12 | if(args.length != 1) | ||
13 | { | ||
14 | System.err.println("Usage: java VerificaXML <xmlFileNameOrUrl>\nExamples:"); | ||
15 | System.err.println("\n\tjava VerificaXML c:\\1.xml"); | ||
16 | |||
17 | return; | ||
18 | } | ||
19 | |||
20 | try | ||
21 | { | ||
22 | DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); | ||
23 | DocumentBuilder domBuilder = domFactory.newDocumentBuilder(); | ||
24 | domBuilder.parse(args[0]); | ||
25 | |||
26 | System.out.println("'" + args[0] + "' este in format corect."); | ||
27 | } | ||
28 | catch(org.xml.sax.SAXException exp) | ||
29 | { | ||
30 | System.out.println("'" + args[0] + "' nu este in format corect.\n" + exp.toString()); | ||
31 | } | ||
32 | catch(FactoryConfigurationError exp) | ||
33 | { | ||
34 | System.err.println(exp.toString()); | ||
35 | } | ||
36 | catch(ParserConfigurationException exp) | ||
37 | { | ||
38 | System.err.println(exp.toString()); | ||
39 | } | ||
40 | catch(Exception exp) | ||
41 | { | ||
42 | System.err.println(exp.toString()); | ||
43 | } | ||
44 | } | ||
45 | } |