• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Lists to XML ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>


 _______________________________________________
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

  • Follow-Ups:
    • Re: Lists to XML ?
      • From: Jean-Christophe Helary <email@hidden>
    • Re: Lists to XML ?
      • From: Jean-Christophe Helary <email@hidden>
    • Re: Lists to XML ?
      • From: Jean-Christophe Helary <email@hidden>
References: 
 >Lists to XML ? (From: Jean-Christophe Helary <email@hidden>)
 >Re: Lists to XML ? (From: Shane Stanley <email@hidden>)
 >Re: Lists to XML ? (From: Jean-Christophe Helary <email@hidden>)
 >Re: Lists to XML ? (From: Steve Mills <email@hidden>)
 >Re: Lists to XML ? (From: Jean-Christophe Helary <email@hidden>)
 >Re: Lists to XML ? (From: Jean-Christophe Helary <email@hidden>)
 >Re: Lists to XML ? (From: Shane Stanley <email@hidden>)
 >Re: Lists to XML ? (From: Jean-Christophe Helary <email@hidden>)

  • Prev by Date: Re: Lists to XML ?
  • Next by Date: Re: Lists to XML ?
  • Previous by thread: Re: Lists to XML ?
  • Next by thread: Re: Lists to XML ?
  • Index(es):
    • Date
    • Thread