1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 import java
.io
.IOException
;
30 import java
.util
.zip
.*;
32 public class XmlWrapper
34 public static void main(String args
[]) throws IOException
36 System
.out
.println("args.length is " + args
.length
);
37 if (args
.length
< 2) {
38 System
.out
.println("Usage: java XmlWrapper [<zipfile1> <zipfile2>].");
44 XmlWrapper w
= new XmlWrapper();
45 File currdirfp
= null;
47 currdirfp
= new File(".");
48 } catch (Exception fx
) {
49 System
.out
.println("Could not get File instance for current directory \n");
58 f1
= File
.createTempFile("xmlcomp", ".tmp", currdirfp
);
59 f2
= File
.createTempFile("xmlcomp", ".tmp", currdirfp
);
60 } catch (Exception tx
) {
61 System
.out
.println("Could not create TempFile ");
62 System
.out
.println("Exception: " + tx
.toString());
67 fname1
= f1
.getAbsolutePath();
68 fname2
= f2
.getAbsolutePath();
70 // get content.xml file from zip file and copy it to temporary
72 XmlZipExtract xw1
= new XmlZipExtract(args
[0]);
74 xw1
.getContentXml(fname1
);
75 } catch (ZipException e
) {
76 System
.out
.println("Exception: file is not a ZIP file: " + args
[0]);
81 } catch (Exception e
) {
82 System
.out
.println("Exception: Could not extract XML from " + args
[0]);
83 System
.out
.println("Exception: " + e
.toString());
90 // get content.xml file from zip file and copy it to temporary
92 XmlZipExtract xw2
= new XmlZipExtract(args
[1]);
94 xw2
.getContentXml(fname2
);
95 } catch (ZipException e
) {
96 System
.out
.println("Exception: file is not a ZIP file: " + args
[0]);
101 } catch (Exception ex
) {
102 System
.out
.println(ex
.getMessage());
103 System
.out
.println("Exception: Could not extract XML from " + args
[1]);
104 System
.out
.println("Exception: " + ex
.toString());
111 boolean same
= false;
115 XmlDiff xmldiff
= new XmlDiff();
117 if (args
.length
== 2) {
118 same
= xmldiff
.diff(fname1
, fname2
);
120 same
= xmldiff
.diff();
125 System
.out
.println("XmlDiff failed");
126 System
.out
.println("Exception: " + ex
.toString());
133 System
.out
.println("Diff result: " + same
);
136 System
.out
.println("XMLDIFFRESULT:PASSED");
138 System
.out
.println("XMLDIFFRESULT:FAILED");