【发布时间】:2018-12-19 17:44:04
【问题描述】:
我有一个解析 Visio 文件的 XML 数据的程序。在这个文件中有一个由几个主形状组成的分组形状。像这样:
每个形状都有一个称为 Pin 的属性
引脚 1 是保存在主形状中的默认值。当我解压 Visio 文件并查看 XML 数据时,“Pin”属性不会显示在 pin 1 上,但它会出现在所有其他 pin 上。
<PageContents xmlns="http://schemas.microsoft.com/office/visio/2012/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xml:space="preserve">
<Shapes>
<Shape ID="2010" Type="Group" LineStyle="7" FillStyle="7" TextStyle="7" UniqueID="{B849B0B2-94FC-4CC7-843F-6A55BDBD37E6}">
<Cell N="PinX" V="8.484814432615094"/>
<...etc>
<Section N="Property">
<Row N="REF">
<Cell N="Value" V="X999" U="STR"/>
<...etc>
</Row>
</Section>
<Shapes>
<Shape ID="2" NameU="Pin.1994" IsCustomNameU="1" Name="Pin.1994" IsCustomName="1" Type="Group" Master="126" UniqueID="{216A72DB-F8E9-4C30-9C34-DE9A8448552B}">
<Cell N="PinX" V="0.07874015748031506" F="Sheet.1!Width*0.5"/>
<...etc>
<Shapes>
<Text callout and background shapes>
</Shapes>
</Shape>
<Shape ID="6" NameU="Pin.2002" IsCustomNameU="1" Name="Pin.2002" IsCustomName="1" Type="Group" Master="126">
<Cell N="PinX" V="0.07874015748031506" F="Sheet.1!Width*0.5"/>
<...etc>
<Section N="Property">
<Row N="Pin">
<Cell N="Value" V="2" U="STR"/>
</Row>
</Section>
<Shapes>
<Text callout and background shapes>
</Shapes>
</Shape>
</Shapes>
</Shape>
</Shapes>
</PageContents>
如果我将“Pin”属性重命名为“1”以外的任何内容,该属性将像在 Pin 2 上一样显示。我认为这是因为它存储在 Master Shape 中,但没有“Property” " 标记在主文件中。
<MasterContents xmlns="http://schemas.microsoft.com/office/visio/2012/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xml:space="preserve">
<Shapes>
<Shape ID="5" Type="Group" LineStyle="0" FillStyle="0" TextStyle="0" UniqueID="{F811FFC2-FDBC-4EFF-97CF-13F5FFBC677C}">
<Cell N="PinX" V="0"/>
<...etc>
<Section N="User">...</Section>
<Section N="Geometry">...</Section>
<Shapes>
<Shape ID="6" NameU="Text callout" IsCustomNameU="1" Name="Text callout" IsCustomName="1" Type="Group" LineStyle="3" FillStyle="3" TextStyle="3" UniqueID="{4CF654FB-78A6-413C-A551-70A86FC63644}">...</Shape>
</Shapes>
</Shapes>
</MasterContents>
由于 Visio 正在显示值,它必须从某处获取属性名称和值,但我不知道它在哪里执行此操作。
当我解析文件时,我会查找“Pin”属性并从形状中的其他属性中提取数据,但是当“Pin”属性不存在时,它将跳过每个 Pin 1 中的所有信息文件。
如果有人想看,我会在此处附上完整的 xml 文件。
*编辑:Zipfile with all XML files
*编辑2:VSDX file
【问题讨论】:
-
嗨,我猜你在找错误的主人,但不可能从 sn-ps 清楚地看到文件结构(链接对我不起作用,我是害怕)。您能否发布完整的 vsdx 文件以便我们进行适当的查看?
-
嗨,我在开头的帖子中放了一个带有 XML 文件的 Dropbox 链接。
-
我认为这只是 xml 部分。你有一个完整的 .vsdx 文件吗?查看所有活动部件会有所帮助。
-
我无法显示实际文件,因为它包含专有的电气原理图。但是我已经将给我问题的主形状复制到了一个新文档中,并在其中复制了这个问题。它似乎给出了相同的行为,即主形状的默认值未显示在页面 XML 文件中。我已将其附加到新的编辑中。