• 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: XML to AppleScript Record
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: XML to AppleScript Record


  • Subject: Re: XML to AppleScript Record
  • From: Skeeve <email@hidden>
  • Date: Wed, 05 Mar 2008 11:41:42 +0100

Stockly, Ed wrote:
<root>
<xmlDataFormat Version="1.1">
<dataTagFoo>
<dataTagBar>
"Data"
</dataTagBar>
<dataTagMore>
"More Data Data"
</dataTagMore>
</dataTagFoo>
</root>
That's not XML. At least not well-formed.
So let's try this one instead:
<root>
   <xmlDataFormat Version="1.1"/>
   <dataTagFoo>
       <dataTagBar>
           "Data"
       </dataTagBar>
       <dataTagMore>
           "More Data Data"
       </dataTagMore>
   </dataTagFoo>
</root>

Should translate as:

{root:{{xmlDataFormat:{version:"1.1:"}}, {dataTagFoo:{dataTagBar:"Data"}},
{dataTagMore:"More Data Data"}}}
No. It shouldn't! You're mixing attributes and content.

If you need both, attributes and content you'd better go with this:
{root:{
   attributes:{},
   contents:{
       xmlDataFormat:{
           attributes:{
               version:"1.1:"
           },
           contents:{}
       }
       dataTagFoo:{
           attributes:{},
           contents:{
               dataTagBar:{
                   attributes:{},
                   contents:"\n     \"Data\"\n    "
               },
               dataTagMore:{
                   attributes:{},
                   contents:"\n     \"More Data Data\"\n    "
               }
           }
       }
   }
}}

Of course this format doesn't support mixed content. Each Ellement can only have either text content or child elements.

If you want to install some Perl Modules, you could achieve this with XML::Twig, converting the XML to AppleScript source code.

Or you create an XSLT that does the same and include (e.g.) saxon into your AppleScript application.

Of course all the other objections you already read here are still valid.
_______________________________________________
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: XML to AppleScript Record
      • From: has <email@hidden>
References: 
 >XML to AppleScript Record (From: "Stockly, Ed" <email@hidden>)

  • Prev by Date: Re: Uninstall script
  • Next by Date: Re: XML to AppleScript Record
  • Previous by thread: Re: XML to AppleScript Record
  • Next by thread: Re: XML to AppleScript Record
  • Index(es):
    • Date
    • Thread