2 Copyright (C) 2000-2005 SKYRIX Software AG
4 This file is part of SOPE.
6 SOPE is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with SOPE; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #include <SaxObjC/SaxObjC.h>
24 #include <DOM/DOMBuilderFactory.h>
25 #include <DOM/DOMXMLOutputter.h>
26 #include <DOM/DOMPYXOutputter.h>
27 #include <DOM/DOMSaxBuilder.h>
32 domxml [options] files
34 -xml|-pyx - output in XML or PYX format ...
37 int main(int argc, char **argv, char **env) {
40 NSAutoreleasePool *pool;
41 id<DOMBuilder> builder;
45 #if LIB_FOUNDATION_LIBRARY
46 [NSProcessInfo initializeWithArguments:argv count:argc environment:env];
49 pool = [[NSAutoreleasePool alloc] init];
54 builder = [[DOMBuilderFactory standardDOMBuilderFactory]
57 fprintf(stderr, "could not create DOM builder !\n");
63 paths = [[[NSProcessInfo processInfo] arguments] objectEnumerator];
64 [paths nextObject]; // skip toolname
65 while ((path = [paths nextObject])) {
66 NSAutoreleasePool *pool;
68 NSTimeInterval duration;
72 if ([path hasPrefix:@"-"]) {
73 if ([path isEqualToString:@"-pyx"]) {
74 out = [[[NGDOMPYXOutputter alloc] init] autorelease];
76 else if ([path isEqualToString:@"-xml"]) {
77 out = [[[DOMXMLOutputter alloc] init] autorelease];
79 else if ([path isEqualToString:@"-repeat"]) {
80 repeat = [[paths nextObject] intValue];
83 // a default ? skip the value
90 pool = [[NSAutoreleasePool alloc] init];
93 NSLog(@"repeat %i times ...", repeat);
96 for (i = 0; i < repeat; i++) {
97 NSAutoreleasePool *pool2;
99 pool2 = [[NSAutoreleasePool alloc] init];
100 [doc release]; doc = nil;
102 date = [NSDate date];
103 doc = [(id)builder buildFromContentsOfFile:path];
104 duration = [[NSDate date] timeIntervalSinceDate:date];
106 NSLog(@"doc(%i) is %@, parsed in %.3fs", i, doc, duration);
107 else if (doc == nil) {
108 NSLog(@"couldn't build DOM from path '%@' (%.3fs)", path, duration);
109 [pool release]; pool = nil;
117 //NSLog(@"doc is %@, parsed in %.3fs", doc, duration);
122 [out outputDocument:doc to:nil];