Re: Lists to XML ?
Re: Lists to XML ?
- Subject: Re: Lists to XML ?
- From: Shane Stanley <email@hidden>
- Date: Sat, 25 Mar 2017 12:45:03 +1100
On 25 Mar 2017, at 12:25 pm, Jean-Christophe Helary <email@hidden> wrote:
1) How I add the DOCTYPE, which is not a requirement in TMX but I'd like to know just so that I understand how to do that:
You need to make an NSXMLDTD and pass it to setDTD: on the document. Never done it, so I'm not sure what's involved in making an NSXMLDTD. 2) What Steve Mills mentioned about "using setAttributesAsDictionary" to set the <header> attributes
I think he meant setAttributesWithDictionary:. So:
(tmxHeader's setAttributesWithDictionary:{adminlang:"en", datatype:"unknown", segType:"paragraph", ... })
3) The creation of an ISO8601 time string, since there is no way to access "hour" "minute" and "second" from "date", but I seem to remember that has been discussed here in the past so I'm not worried.
If you're running pre-10.12:
set theDate to current application's NSDate's |date|() set theFormatter to current application's NSDateFormatter's new() theFormatter's setLocale:(current application's NSLocale's localeWithLocaleIdentifier:"en_US_POSIX") theFormatter's setTimeZone:(current application's NSTimeZone's timeZoneWithAbbreviation:"GMT") -- skip for local time theFormatter's setDateFormat:"yyyy'-'MM'-'dd'T'HH':'mm':'ssXXX" set dateString to (theFormatter's stringFromDate:theDate) as text
If running 10.12, this is shorter:
set theDate to current application's NSDate's |date|() set dateString to (current application's NSISO8601DateFormatter's stringFromDate:theDate timeZone:(current application's NSTimeZone's timeZoneWithAbbreviation:"GMT") formatOptions:1907) as text -- 1907 is magic number for RFC3339
--
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden