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: Jean-Christophe Helary <email@hidden>
- Date: Mon, 29 Jan 2018 17:20:13 +0900
Two more questions related to the "refining/understanding" of my code.
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?
What I have now is this:
repeat with child in project_tags
set child to (current application's NSXMLNode's elementWithName:child
stringValue:"default")
(project's addChild:child)
end repeat
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.
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...
Similarly (?), I have:
theProject's setCharacterEncoding:"UTF-8"
But when I try:
theProject's CharacterEncoding()
I get an error...
Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune
_______________________________________________
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