Strange Visio 2003 behavior

V

V.Aks

When Visio read the next file:

<?xml version="1.0"?>
<VisioDocument xmlns="http://schemas.microsoft.com/visio/2003/core">
<Masters>
<Master ID="7">
<Shapes>
<Shape ID="6">
<Shapes> <Shape ID="5"> </Shape> </Shapes>
</Shape>
</Shapes>
</Master>
</Masters>
<Pages>
<Page ID="0">
<Shapes>
<Shape ID="1" Master="7"> </Shape>
<Shape ID="2" Master="7"> </Shape>
</Shapes>
</Page>
</Pages>
</VisioDocument>

I got the message:

[Warning] DataType:
Context: Line 20 --- <VisioDocument><Pages><Page><Shapes><Shape>
ID='2'
Description: This file contains a duplicate of an element that can
exist only once. Visio has ignored the duplicate element.

But I do not see any duplicated elements!

Moreover, Visio 2003 read the next file (almost the same as previous
file - only different order of two <Shape> elements) without any
warnings.

<?xml version="1.0"?>
<VisioDocument xmlns="http://schemas.microsoft.com/visio/2003/core">
<Masters>
<Master ID="7">
<Shapes>
<Shape ID="6">
<Shapes> <Shape ID="5"></Shape> </Shapes>
</Shape>
</Shapes>
</Master>
</Masters>
<Pages>
<Page ID="0">
<Shapes>
<Shape ID="2" Master="7"></Shape>
<Shape ID="1" Master="7"></Shape>
</Shapes>
</Page>
</Pages>
</VisioDocument>

Who knows, where is the reason of such behavior?
 
M

Mark Nelson [MS]

Good question here. The issue is that the master shape really includes two
shapes (ID's 6 and 5). When listing the shape instances on the page, the ID
numbering must account for this. Thus the first shape can be ID = 1, but
this shape includes a subshape which Visio will implicitly assign ID = 2 to.
The second shape should use the next available ID, which would be 3 in this
case.

The second file works because of the specific way Visio implicitly assigns
ID's. The first shape has ID = 2 specified. Visio implicitly assigns ID =
3 to the subshape as the next available shape ID. The second shape has ID =
1 specified, which is legal because the ID has not been used yet. Visio
then chooses the next available shape ID for the sub-shape, which would be
4.

The conflict occurs when Visio makes an implicit ID assignment for
sub-shapes, and then the XML explicitly declares another shape to use that
ID. To avoid the problem, the program that is generating the Visio XML file
must know to count subshapes and appropriately skip ID values. This is
admittedly a poor design but one inherent in Visio's schema.

--
Mark Nelson
Office Graphics - Visio
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
 
V

V.Aks

"""Mark Nelson [MS] ÐÉÓÁÌ(Á):
"""
Good question here. The issue is that the master shape really includes two
shapes (ID's 6 and 5). When listing the shape instances on the page, the ID
numbering must account for this. Thus the first shape can be ID = 1, but
this shape includes a subshape which Visio will implicitly assign ID = 2 to.
The second shape should use the next available ID, which would be 3 in this
case.

The second file works because of the specific way Visio implicitly assigns
ID's. The first shape has ID = 2 specified. Visio implicitly assigns ID =
3 to the subshape as the next available shape ID. The second shape has ID =
1 specified, which is legal because the ID has not been used yet. Visio
then chooses the next available shape ID for the sub-shape, which would be
4.

The conflict occurs when Visio makes an implicit ID assignment for
sub-shapes, and then the XML explicitly declares another shape to use that
ID. To avoid the problem, the program that is generating the Visio XML file
must know to count subshapes and appropriately skip ID values. This is
admittedly a poor design but one inherent in Visio's schema.

--
Mark Nelson
Office Graphics - Visio
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
Thank you very much for the answer.
To my mind it would be rather useful to have a method (in Visio API)
for generating right ID or, at least a method for validation new ID.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top