NSAttributedString -> XHTML 1.1
NSAttributedString -> XHTML 1.1
- Subject: NSAttributedString -> XHTML 1.1
- From: Keith Blount <email@hidden>
- Date: Tue, 16 Dec 2008 12:56:23 -0800 (PST)
Hi,
I'm building an .epub eBook exporter from my app and thus need to generate XHTML 1.1 files from my text. I am using NSAttributedString's -dataFromRange:documentAttribributes:error: to generate the XHTML, and by playing with the different combinations of documentAttributes that are used in the TextEdit example, I can generate an XHTML 1.0 strict file, but haven't been able to figure out how to generate an XHTML 1.1 file (perhaps it isn't possible via NSAttributedString as yet?). These are my document attributes to build an XHTML 1.1 file:
- (NSDictionary *)ePubXHTMLAttributes
{
// Excluded elements tell exporter to use use XHTML 1.0 Strict -
// by not including XML in this list, XHTML will be generated; by excluding the
// other elements, 1.0 Strict will be generated rather than 1.0 Transitional.
NSArray *excludedElements = [NSArray arrayWithObjects:
// *NOT* TRANSITIONAL TYPE
@"APPLET",
@"BASEFONT",
@"CENTER",
@"DIR",
@"FONT",
@"ISINDEX",
@"MENU",
@"S",
@"STRIKE",
@"U",
nil];
return [NSDictionary dictionaryWithObjectsAndKeys:
NSHTMLTextDocumentType, NSDocumentTypeDocumentOption,
[NSNumber numberWithInt:NSUTF8StringEncoding], NSCharacterEncodingDocumentAttribute,
[NSNumber numberWithInt:2], NSPrefixSpacesDocumentAttribute,
excludedElements, NSExcludedElementsDocumentAttribute,
[self title], NSTitleDocumentAttribute,
nil];
}
This generates an XHTML file with the following header declaration:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
i.e. 1.0 Strict. However, what I need is this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
As I understand it the differences between 1.0 Strict and 1.1 are few - in fact, they are only the following:
1. On every element, the lang attribute has been removed in favor of the xml:lang attribute (as defined in [XHTMLMOD]).
2. On the a and map elements, the name attribute has been removed in favor of the id attribute (as defined in [XHTMLMOD]).
3. The "ruby" collection of elements has been added (as defined in [RUBY]).
So, what is the correct way to generate XHTML 1.1 data from NSAttributedString (if it is possible). I could exclude "DOCTYPE" and insert the 1.1 declaration for myself, but that would be cheating as it may not be correct 1.1.
Thanks in advance and all the best,
Keith
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden