Wednesday, October 27, 2004
Part 1: Visioâs XML File Format
Part 1: Visio’s XML File Format
Visio has a native XML file format for a Visio drawing, a Visio template, and a Visio stencil. We do not have the ability to save a Visio drawing into any other XML schema but our own. If users want Visio diagrams in BPEL or some other business XML format, the user needs to work with a solution provider or their IT department to write an XLST to transform the Visio XML file format to another schema. ’âll blog more about transforms later on this week. First, I wanted to give a little bit of background on the Visio XML file format itself.
You can save any Visio diagram into XML format using File | Save As and open it in an XML editor to read. Once y’uâve loaded a Visio XML document into an XML editor, you will note right away that a) the schema is quite complex and b) the XML file itself is relatively large compared to its VSD format, and c)’itâs a great way to learn about the Visio automation model and/or what comprises a Visio shape.
’hatâs because ’isioâs XML file format is a physical file format. In order to render the Visio drawing properly from XML, Visio needs the document schema to tell the app all the gory details about geometry, layout, and other behaviors for the shape. Consider the following simple flowchart.
If you save out this drawing into a VDX file, you will get a 103 KB XML fil’. (Itâs 44 KB i’ Visioâs binary drawing format.) If you click here, you can take a look at the XML. About 20% of this file is garbage because by default, when you save a Visio file, it saves with the Preview Picture option turned on in Document Properties. Once I go and turn off the Preview option (on the File | Properties dialog, look on the Summary tab and uncheck Save Preview Picture tab), the file size for the document reduces to 107 KB. Click here for the XML without Preview Picture garbage.
The good news is that the Visio XML schema is documented as part of the Office 2003 XML Reference Schemas. The bad news is that Visio XML can be clumsy for developers to extract specific information, like Shape text or Shape custom properties, from the document.
In Visio 2002 SR1, Visio introduced SolutionXML, which is customer-defined XML that developers can store at the document or cell level and retrieve by a custom (optional) namespace.
Later on this week, I will cover how to use SolutionXML, which is what I would recommend to developers to store custom data that they want to pull out of the Visio XML file format with minimal parsing.
F’r todayâs XML topic, the key takeaways are:
- You can save a document, stencil, or template i’to Visioâs XML file format. Visio does not have native support for saving a Visio document into any other XML file format. To convert a Visio XML document to another XML file format, a developer needs to write an XSLT. (to be covered later this week in my blog)
- Always turn off Preview Picture when saving to XML file format to reduce the size of your Visio XML file.
- If you plan to generate a lot of Visio XML files automatically, you might want to make sure that you have space for it on your file share. The files can get quite large.
- Developers should not have to walk the entire schema in a Visio XML file if all you want out of the file is shape-specific d’ta. Thereâs a better alternative called Visio SolutionXML. (to be covered later this week in my blog)
This posting is provided "AS IS" with no warranties, and confers no rights