C# Visio主控形状属性存储在哪里?
我有一个解析Visio文件XML数据的程序。在此文件中,有一个由多个主形状组成的分组形状。像这样:C# Visio主控形状属性存储在哪里?,c#,xml,visio,C#,Xml,Visio,我有一个解析Visio文件XML数据的程序。在此文件中,有一个由多个主形状组成的分组形状。像这样: 每个形状都有一个名为Pin的属性 接点1是保存在主图形中的默认值。当我解压Visio文件并查看XML数据时,“Pin”属性不会显示在Pin 1上,但它会显示在所有其他Pin上 <PageContents xmlns="http://schemas.microsoft.com/office/visio/2012/main" xmlns:r="http://schemas.openxmlf
每个形状都有一个名为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上的属性相同。我认为这是因为它存储在主控形状中,但主控文件中也没有“属性”标记
<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文件,我将在这里附上它们
*编辑:
*编辑2:感谢vsdx,这很有帮助 正如您突出显示的,“Pin1”形状中的Pin形状数据行不会显示在实例形状xml(PageContents)中,因为它是从其主控形状继承的值。其他两个具有局部值的形状反映在实例xml中 我认为你遇到的问题是,你看错了主数据,因此找不到你想要的数据 追溯这一点的方法是,如果您查看页面xml(page1.xml),您将看到Pin形状基于主id“6”: [注意-为了更清楚地了解文件的结构,我在下面的代码片段中删去了大量xml。]
现在,您可以查看masters集合(masters.xml),并将看到ID属性为6的master(“Pin”master)的rel ID为“rId2”:
<Masters>
<Master ID='2' NameU='Dynamic connector' IsCustomNameU='1' Name='Dynamic connector' IsCustomName='1'>
<Rel r:id='rId1'/>
</Master>
<Master ID='6' NameU='Pin' IsCustomNameU='1' Name='Pin' IsCustomName='1'>
<Rel r:id='rId2'/>
</Master>
现在您已经获得了正确的rel id,并在master.xml.rels中查找了正确的master声明,您将看到rel id“rId2”指向master2.xml:
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<Relationship Id="rId3" Type="http://schemas.microsoft.com/visio/2010/relationships/master" Target="master3.xml"/>
<Relationship Id="rId2" Type="http://schemas.microsoft.com/visio/2010/relationships/master" Target="master2.xml"/>
<Relationship Id="rId1" Type="http://schemas.microsoft.com/visio/2010/relationships/master" Target="master1.xml"/>
<Relationship Id="rId5" Type="http://schemas.microsoft.com/visio/2010/relationships/master" Target="master5.xml"/>
<Relationship Id="rId4" Type="http://schemas.microsoft.com/visio/2010/relationships/master" Target="master4.xml"/>
</Relationships>
因此,您的最后一站是前往master2.xml,在那里您应该会发现顶级形状(id 5)有一个名为“Pin”的形状数据行,其值为“1”:
<MasterContents>
<Shapes>
<Shape ID='5' NameU='Pin.473' IsCustomNameU='1' Name='Pin.473' IsCustomName='1' Type='Group'>
<Section N='Property'>
<Row N='Pin'>
<Cell N='Value' V='1' U='STR'/>
<Cell N='Prompt' V='' F='No Formula'/>
<Cell N='Label' V='Pin'/>
<Cell N='Format' V='' F='No Formula'/>
<Cell N='SortKey' V='' F='No Formula'/>
<Cell N='Type' V='0'/>
<Cell N='Invisible' V='0' F='No Formula'/>
<Cell N='Verify' V='0' F='No Formula'/>
<Cell N='DataLinked' V='0' F='No Formula'/>
<Cell N='LangID' V='sv-SE'/>
<Cell N='Calendar' V='0' F='No Formula'/>
</Row>
</Section>
我猜您将vsdx视为一个zip,而忽略了System.IO.Packaging名称空间,该名称空间将帮助您导航包关系。我将添加此链接,以防万一:
<MasterContents>
<Shapes>
<Shape ID='5' NameU='Pin.473' IsCustomNameU='1' Name='Pin.473' IsCustomName='1' Type='Group'>
<Section N='Property'>
<Row N='Pin'>
<Cell N='Value' V='1' U='STR'/>
<Cell N='Prompt' V='' F='No Formula'/>
<Cell N='Label' V='Pin'/>
<Cell N='Format' V='' F='No Formula'/>
<Cell N='SortKey' V='' F='No Formula'/>
<Cell N='Type' V='0'/>
<Cell N='Invisible' V='0' F='No Formula'/>
<Cell N='Verify' V='0' F='No Formula'/>
<Cell N='DataLinked' V='0' F='No Formula'/>
<Cell N='LangID' V='sv-SE'/>
<Cell N='Calendar' V='0' F='No Formula'/>
</Row>
</Section>