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 (and SVG, if you are using Visio 2003). 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. I’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 you’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.
That’s because Visio’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 135 KB XML file. (It’s 44 KB in 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 checkbox), 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, 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.
For today’s XML topic, the key takeaways are:
- You can save a document, stencil, or template into Visio’s XML file format. Visio does not have native support for saving a Visio document into any other XML file format than its own and SVG. 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 data. 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