[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: XML with embedded docs?
>We are building a slide presentation application for Linux. I have >been suggesting that we use XML for the file format of saved >presentations. This has obvious benefits but it has one major drawback >in our case: > >We are creating this app with a component system (Bonobo) which allows >the user to, for example, save a spreadsheet *within* their >presentation slide. So here we have another file format(not XML) that >needs to be embedded into an xml file. As far as my knowledge takes >me, XML is a bit too "flat" for this - or is it? How can this be >handled in such a way that we still end up with a valid XML document? >Can it? XML certainly isn't too 'flat' for what you need. Assuming that Bonobo (which I am not familiar with) allows you to serialize the state of embedded objects into a stream, there is nothing stopping you from writing out this binary data formatted as ASCII hex characters as the CDATA of an XML element. Disadvantage: it might be a little verbose ;-) Here's an example (using terminology from Microsoft's OLE as a parallel to Bonobo): <?xml version="1.0"?> <doc> <object CLSID="{7F340832-FBE9-11D3-9211-0050DA33CC7B}"> <position left="100" top="150"/> <dimensions width="400" height="300"/> <state>0A60f23920192394ff83945000000000001012f27712</state> </object> </doc> This provides you with enough information to re-create the object (based on its CLSID) and place it in the correct position with the correct dimensions You can then create an IStream object on the contents of the <state> element and use it to initialize the object's state. Alternatively, you could serialize the binary data in the <state> tag into a seperate file and then reference that external file by name. i.e. <?xml version="1.0"?> <doc> <object CLSID="{7F340832-FBE9-11D3-9211-0050DA33CC7B}" state_ref=".\7F340832-FBE9-11D3-9211-0050DA33CC7B.000405.124536.1.bin"> <position left="100" top="150"/> <dimensions width="400" height="300"/> </object> </doc> This might be less verbose but you'll probably run into loads of potential problems trying to keep the bin files together with the mail XML document. You also have to guarantee that the file name specified as the state_ref value will be unique when the file is created _and_ after any form of file transmission/duplication. This presents a potential nightmare. Personally, I wouldn't bother with this solution. Hope this helps, Simon *************************************************************************** This is xml-dev, the mailing list for XML developers. To unsubscribe, mailto:majordomo@x...&BODY=unsubscribe%20xml-dev List archives are available at http://xml.org/archives/xml-dev/ ***************************************************************************
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|