Re: A question about LN Softwares XML Tools
Re: A question about LN Softwares XML Tools
- Subject: Re: A question about LN Softwares XML Tools
- From: Mark Alldritt <email@hidden>
- Date: Thu, 08 Aug 2002 11:36:31 -0700
>
If anyone from LNS is reading - why doesn't <dealerwebsite></dealerwebsite>
>
parse to XML tag:"dealerwebsite",XML Contents:{""} ? I'm sure there's an
>
answer but it would have made my life so much easier if an empty tag parsed
>
to an empty string instead of nothing at all!
The presence or absence of the XML contents property indicates the presence
or absence of content within an XML tag.
Part of the problem is the lack of object model support within AppleScript
for lists and records. If AppleScript were better behaved, one could do the
following:
if exists XML contents of ... Then
-- process the XML contents property...
end if
Instead, you have to do something like this:
set xxx to parse XML "<tag><tag1></tag1></tag>"
try
-- create a reference to the XML contents property
set theContents to XML contents of item 1 of XML contents of xxx
-- process theContents...
on error number -1728
display dialog "xml contents missing..."
end try
I've filed a feature request to add a flag to the parse XML command to have
it always create an empty XML contents property. However, XML is
sufficiently variable that I think you have to develop code that is
defensive against this and other issues.
The XML contents property has one of three states:
- non-existent meaning that the tag is "empty" (e.g. <tag></tag> or <tag/>)
- contains a string meaning that the tag contains a single text range
- contains a list of XML element objects and/or strings meaning that the tag
contains other XML tags and/or strings
A validating XML parser might offer a more usable solution as it would
ensure that the input XML stream is correct according to a DTD or better, an
XML Schema. However, since Apple has indicated that it is going to offer
its own XML support in AppleScript at some point in the future, I'm not sure
there's much point improving XML Tools.
Cheers
-Mark
---------------------------------------------------------------------
Mark Alldritt Late Night Software Ltd.
Phone: 250-380-1725 333 Moss Street
FAX: 250-383-3204 Victoria, B.C.
WEB:
http://www.latenightsw.com/ CANADA V8V-4M9
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.