This is the second topic in a series discussing the essential features that make up the Visio application.
Essential Feature: Drawings, Stencils and Templates
In the previous post on Drag and Drop, we mentioned that Stencils were separate documents from the drawing and thus Visio has to make a local copy of a master shape when you drag one onto the page. So what is the difference between a stencil and a drawing? And what about templates?
Actually, there is very little difference between these three types of Visio documents. That's because there is really only one document type in Visio. Drawings, stencils and templates are the same technically. The difference is in the “view” of the document information presented to the user.
Try this: make a simple flowchart by starting from the Basic Flowchart template. Drag some shapes onto the drawing page from the Basic Flowchart Shapes stencil. Save the drawing as MyDrawing.vsd and exit Visio. Now rename the file, changing the extension from 'VSD' to 'VSS'. Reopen the drawing in Visio. What do you see? You should see a stencil with just the master shapes you dragged into your drawing. Close Visio and change the extension to 'VST'. Now what do you see when the file is reopened? You should see your drawing but with a generic filename like Drawing1.
What's going on? Every Visio document has a drawing surface - the page that you drop shapes on. Every document also has a stencil containing masters, called the Document Stencil. The file extension tells Visio whether to open a document showing the drawing surface or the stencil. You can see the Document Stencil for your drawing by choosing File > Shapes > Show Document Stencil. Templates are just like drawings. The only difference is that Visio will open a template as a copy of the original document by default. This explains the change in filename.
Another part of a Visio document is the workspace information. Whenever you save a drawing, Visio records the names of the stencils that were opened with your drawing. These stencil documents are automatically reopened the next time your file is reopened.
Those of you who are familiar with Visio's file format history know that there are now two sets of Visio file extensions. VSD, VSS and VST are the drawing, stencil and template extensions for Visio's binary document format. There is a companion set of VDX, VSX and VTX extensions for Visio's XML document format. The XML document format is a full fidelity peer of the binary format that was introduced in Visio 2002. The XML formats offer an under the hood view of the contents of a Visio document. They allow developers to write programs that build new drawings from scratch or read the contents of a drawing – all without having to launch the Visio application.
Try saving out a drawing as XML and then opening the file in a text editor. You can rename the file to give it a .XML extension and view it in Internet Explorer too. There is a lot of information, but if you dig around you'll find the Masters collection that makes up the Document Stencil and the Pages collection that makes up the drawing. You may even find the workspace information.