Re: XML generation details (was Re: ASObjC alloc and object creation)
Re: XML generation details (was Re: ASObjC alloc and object creation)
- Subject: Re: XML generation details (was Re: ASObjC alloc and object creation)
- From: Shane Stanley <email@hidden>
- Date: Mon, 29 Jan 2018 21:49:14 +1100
On 29 Jan 2018, at 7:20 pm, Jean-Christophe Helary
<email@hidden> wrote:
>
> 1) I'm using a list and a repeat with/in loop to create the various XML
> elements in the document. That works well enough. Is there a way to do
> something equivalent but using ASObjC methods with an array that I'd create
> from that list?
You mean create them as a batch? No.
>
> 2) There is an element in the document that has a non trivial content (namely
> a list of other elements, vs simple string values). I decided to not put that
> element in the list above and create it separately so that I create its
> contents independently of the original loop. What I'd rather do is put it in
> the original tag list, create it as a child of the root element and only
> *then* when all the children have been created add content to that specific
> element.
As long as you have a reference to it, you can do that.
>
> What I have now is this:
>
> set source_dir_excludes to (current application's NSXMLNode's
> elementWithName:"source_dir_excludes")
> (project's addChild:source_dir_excludes)
>
> repeat with mask in masks
> set mask to (current application's NSXMLNode's
> elementWithName:"mask" stringValue:mask)
> (source_dir_excludes's addChild:mask)
> end repeat
>
>
> I'd rather have the source_dir_excludes element created in the original loop
> and do something like this to create it's <mask> contents:
>
> repeat with mask in masks
> set mask to (current application's NSXMLNode's elementWithName:"mask"
> stringValue:mask)
> (theProject's source_dir_excludes's addChild:mask)
> end repeat
>
> But I can't seem to find a way to do that...
source_dir_excludes is source_dir_excludes, whether you've added it as a child
element of something or detached it from its parent. So if I understand
correctly, that "theProject's" is unnecessary (and wrong).
> Similarly (?), I have:
>
> theProject's setCharacterEncoding:"UTF-8"
>
> But when I try:
>
> theProject's CharacterEncoding()
>
> I get an error...
Because case matters. The setter is setCharacterEncoding: and the getter is
characterEncoding().
--
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