Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

uberamd

macrumors 68030
Original poster
May 26, 2009
2,785
2
Minnesota
I am writing a GUI application that calls the command line utility /usr/bin/xmllint. I am going to grab the output from the command and display it, however I am having issues getting it to even execute properly. Here is my code chunk:

Code:
-(IBAction)validateButtonClicked:(id)sender
{
	NSString* xsdValue = [xsdPathBar stringValue];
	NSString* xmlValue = [xmlPathBar stringValue];
	if( [xsdValue isEqualToString:@""] || [xmlValue isEqualToString:@""] )
	{
		[outBox setStringValue:@"You must select both an XML file and XSD file"];
	} else {
		
		NSString* xmllintArgs = [NSString stringWithFormat:@"--noout --schema %@ %@", xsdValue, xmlValue];
		NSLog(@"%@", xmllintArgs);
		
		NSTask *xmllint;
		xmllint = [[NSTask alloc] init];
		[xmllint setLaunchPath:@"/usr/bin/xmllint"];
		[xmllint setArguments:[NSArray arrayWithObjects:(NSString*)xmllintArgs, NULL]];
		[xmllint launch];
				
		[xmllint release];
		xmllint = nil;
		
		[outBox setStringValue:@"OK!"];
	}
}

Here is the console output:

Unknown option --noout --schema /real/path/to/file/BooksSchema.xsd /real/path/to/file/Books.xml
Usage : /usr/bin/xmllint [options] XMLfiles ...
Parse the XML files and output the result of the parsing
--version : display the version of the XML library used
--debug : dump a debug tree of the in-memory document
--shell : run a navigating shell
--debugent : debug the entities defined in the document
--copy : used to test the internal copy implementation
.... etc ....

However when I copy and paste the EXACT same command in terminal it works perfectly:

Steves-MacBook-Pro:~ morri534$ /usr/bin/xmllint --noout --schema /real/path/to/file/BooksSchema.xsd /real/path/to/file/Books.xml
/real/path/to/file/Books.xml validates
Steves-MacBook-Pro:~ morri534$

Can anyone diagnose what may be wrong with my code that is causing it to fail on me?
 
Each argument has to be a separate object in the NSArray, that is the arguments should be [NSArray arrayWithObjects:mad:"--noout", @"--schema", xsdValue, xmlValue, nil];
 
That works perfectly, thank you! Makes sense now that I think about it. I am almost done with this but I am having one more issue with the UI.

I have a NSTextField (outBox) inside of a NSScrollView. I set the contents of the outBox to the output string, however that allows the scroll view to horizontal scroll. Is there any way to restrict the ScrollView from horizontally scrolling? I would like it to instead wrap the text and just vertically scroll.

Currently my code is:

Code:
[outBox setStringValue:output];
[outBox sizeToFit];

I understand why it is doing the HZ scroll, because I am calling sizeToFit, but I cant figure out any other way to make the outBox NSTextField only vertically resize and wrap text. Any help would be appreciated.
 
I'm unfamiliar with the NSTextField but in UITextFields in interface builder, you select the text box and in the properties there are checkboxes for Horizontal scroll, Vertical scroll, scroll enabled... I just set them to have vertical scroll and scroll enabled. Then when I paste in long lines they just wrap to the next line.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.