Show All

# Round-Tripping DatadiagramML Files

You can save Microsoft Office Visio drawings, stencils, and templates as XML files and then open them again in Visio without any loss of information. This is called round-tripping.

However, when Visio opens an XML file created in another application or a DatadiagramML file edited in another application and then resaves the document into a DatadiagramML file, although there should be no loss of data, the files are not guaranteed to be identical after they have been saved in Visio.

The following cases illustrate some differences that occur when an XML file created in another application or a DatadiagramML file edited in another application is saved in Visio.

White space

White space is not preserved in DatadiagramML files except within elements whose data type is string, including Text elements. Visio will also preserve white space for any Solution XML or unknown XML because of the default xml:space='preserve' setting in all VDX files. In all other cases, for example in cell elements whose data type is NUM, white space is not preserved.

By default, Visio typically does not display any formatting, such as carriage returns and tab indents, in the source code of XML files. This can make these files hard to read inside a general text editor such as Notepad. To have Visio display formatting (such as indents of child elements) in XML files to make them easier to read, you must modify the following registry key:

HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Visio\Application\XMLEmitIndents

To improve readability in Notepad and other text editors, set the value of XMLEmitIndents to 1.

Caution Incorrectly editing the registry may severely damage your operating system, requiring you to reinstall it. Microsoft cannot guarantee that problems resulting from editing the registry incorrectly can be resolved. Before editing the registry, back up any valuable data. For the most recent information about using and protecting your computer's registry, see Microsoft Windows Help.

Elements that represent cells

Visio always emits local cell elements that have an explicit unit, value, and formula. If a third-party application omits portions of the element, Visio either picks default values or infers correct values for the missing components. Consider a possible fragment emitted from a third-party application:

    <PinX F='1'/>

Because only a formula was specified, Visio assigns the formula to the PinX element and then evaluates the formula to determine the value. Because the formula evaluates to a constant, Visio flags the element as a constant. A unit of measure was not specified, so Visio uses the default unit for the cell, which is inches (the default length unit or DL). When the file is resaved, the previous fragment appears like this:

    <PinX>1</PinX>

Note If the unit of measure is explicitly set in the ShapeSheet spreadsheet and is different from the default unit, Visio writes out the Unit attribute.

Elements that represent rows

A DatadiagramML file can contain a series of elements that represent indexed rows. Consider this file fragment:

    <Scratch IX='3'>
       <X> 3 <X/>
    </Scratch>
    <Scratch IX='1'>
       <X> 1 <X/>
    </Scratch>

When Visio reads the file and resaves it, it appears as follows:

    <Scratch IX='0'>
       <X F='No Formula'>0</X>
       <Y F='No Formula'>0</Y>
       ...
    </Scratch>
    <Scratch IX='1'>
       <X>1</X>
       <Y F='No Formula'>0</Y>
       ...
    </Scratch>
    <Scratch IX='2'>
       <X F='No Formula'>0</X>
       <Y F='No Formula'>0</Y>
       ...
    </Scratch>
    <Scratch IX='3'>
       <X>3</X>
       <Y F='No Formula'>0</Y>
       ...
    </Scratch>

Visio always writes indexed rows out in index order. If the original sequence of rows was indexed sparsely (there were gaps in the sequence), Visio implicitly creates the missing rows.

Note Text rows will not work as expected if the rows are not listed in ascending order.

Named rows have no specific order. If a DatadiagramML file contains a series of named rows, their order is not guaranteed when the file is round-tripped.

Geom elements

Geometry sections follow the same round-tripping rules as indexed rows. Indexed sections can appear in any order, but when round-tripped, they are written out in index order and the sparse sections are implicitly created.

For more information about Geom elements, see Working with Geometry in DatadiagramML.

Text elements

In the Visio engine, a block of text can contain ASCII control characters that represent tabs, line breaks, paragraph breaks, and field positions.

An ASCII 9, ASCII 10, or ASCII 13 character indicating a tab, paragraph break, or line break, respectively, is emitted as a normal ASCII character into DatadiagramML. These characters are considered legal Unicode characters by all XML parsers.

Any other ASCII control character between ASCII 0 and ASCII 31 (other than ASCII 9, 10, and 13) is considered an illegal Unicode character by some XML parsers. As a result, when you save a file that contains these control characters, Visio converts them into question-mark characters (?) and warns you about their existence.

For more information about working with text, see Working with a Shape's Text in DatadiagramML.

Miscellaneous

A third-party application can omit a document-level element from a DatadiagramML file, such as DocumentProperties or any of the document level child elements, such as Author. However, when the DatadiagramML file is round-tripped, Visio creates a document-level element for all non-empty document properties. For example, a DatadiagramML file can omit the TimeSaved element, but the round-tripped DatadiagramML file contains a TimeSaved element with an appropriate value.

©2003-2004 Microsoft Corporation. All rights reserved. Permission to copy, display and distribute this document is available at: http://msdn.microsoft.com/library/en-us/odcXMLRef/html/odcXMLRefLegalNotice.asp