Sending data to libxslt
Sending data to libxslt
- Subject: Sending data to libxslt
- From: Eric Blair <email@hidden>
- Date: Fri, 10 Oct 2003 20:32:35 -0400
I apologize for (possibly) cross posting this on MacOSX-Dev. It doesn't
look like any mail from the last few days has gone out -- the OmniGroup
archive shows 5 message since 10/9 but nothing since 10/8 shows up in
either my email or the cocoa.mamasam.com archive.
I'm trying to download some data from Amazon.com (via AWS) and send it
to libxslt for parsing. I had everything working when I was just using
[NSString stringWithContentsOfURL:] to get the data, but I decided to
switch to CURLHandle because I wanted a more robust solution for data
transmission.
Sometimes, I get data back from Amazon.com that contains foreign
characters (high ASCII, I assume). When I send this data to libxml, I
get back an error that "Input is not proper UTF-8, indicate encoding !"
Also, if I dump the XML from Amazon.com to a text file (using [NSString
writeToFile:atomically"]) and open the resulting file in BBEdit, I get a
message that "The UTF-8 file "blah" is damaged or incorrectly
formatted..." and the foreign characters are displayed as boxes (
If I set the stringValue of an NSTextView to the string, though, the
string is properly rendered.
When I run the debugger and do a po of the XML string, the problematic
characters are displayed as "\301Qu\216"
I suspect that I've got the string encoding wrong, but I can't seem to
find the correct magical incantation.
Here's the code I'm using to download the data and convert it to a
string (urlHandle is a CURLHandle):
NSData * data = [[self urlHandle] resourceData];
NSString * contentType = [[self urlHandle]
propertyForKeyIfAvailable:@"content-type"];
[[self urlHandle] removeClient:self];
[self setHttpResultCode: [[self urlHandle]
propertyForKeyIfAvailable:NSHTTPPropertyStatusCodeKey]];
if(nil != data) {
NSString * bodyString = [[[NSString alloc]
initWith
Data:data encoding:NSUTF8StringEncoding]
autorelease];
[self setXmlCode:bodyString];
}
For a sample of the problematic data, try this URL:
<
http://xml.amazon.com/onca/xml3?t=raoli-20&dev-t=D3TY7KOL7GNYIA&type=
heavy&f=xml&WishlistSearch=2QD2DVPWJ28PS&page=1>
The foreign characters can be found just before the term "Great Spanish"
(aka, line 502).
For the XSLT, I'm using the libxslt Framework provided by Zveno
<
http://www.zveno.com/open_source/libxml2xslt.html> and Mark Liyanage's
libxslt interface <
http://www.entropy.ch/software/macosx/#testxslt>
Any help would be greatly appreciated,
--Eric
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.