The XML I post may be big, but my problem is rather simple. Please take a look at the second Dimensions tag. The first Dimension is automatically generated. The second one is created by me in C# script. The question is: how do I make my Dimension tag have the exact same namespaces ("xsi:type="RegularMeasureGroupDimension") as the generated one? Thanks for any help!
我发布的XML可能很大,但我的问题很简单。请查看第二个Dimensions标记。第一个Dimension是自动生成的。第二个是由我在C#脚本中创建的。问题是:如何使我的Dimension标签具有与生成的完全相同的命名空间(“xsi:type =”RegularMeasureGroupDimension“)?感谢您的帮助!
This is the C# code I use to generate the Dimension:
这是我用来生成Dimension的C#代码:
XmlNode dimensions2 = doc.DocumentElement.ChildNodes[1].ChildNodes[0].ChildNodes[6].ChildNodes[0].ChildNodes[5];
dimensions2.AppendChild(dimension2);
//dimension2.SetAttribute("xmlns","http://schemas.microsoft.com/analysisservices/2003/engine");
// dimension2.SetAttribute("xmlns:xsi", "http://www.w3.org/2001/XmlSchema-instance");
dimension2.SetAttribute("type", "http://www.w3.org/2001/XmlSchema-instance", "RegularMeasureGroupDimension");
And this is the XML file:
这是XML文件:
<Create xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">
<ParentObject>
<DatabaseID>test_szymon</DatabaseID>
</ParentObject>
<ObjectDefinition>
<Cube xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ddl2="http://schemas.microsoft.com/analysisservices/2003/engine/2" xmlns:ddl2_2="http://schemas.microsoft.com/analysisservices/2003/engine/2/2" xmlns:ddl100_100="http://schemas.microsoft.com/analysisservices/2008/engine/100/100" xmlns:ddl200="http://schemas.microsoft.com/analysisservices/2010/engine/200" xmlns:ddl200_200="http://schemas.microsoft.com/analysisservices/2010/engine/200/200" xmlns:ddl300="http://schemas.microsoft.com/analysisservices/2011/engine/300" xmlns:ddl300_300="http://schemas.microsoft.com/analysisservices/2011/engine/300/300" xmlns:ddl400="http://schemas.microsoft.com/analysisservices/2012/engine/400" xmlns:ddl400_400="http://schemas.microsoft.com/analysisservices/2012/engine/400/400">
<ID>Test</ID>
<Name>Test</Name>
<Annotations>(...)</Annotations>
<Language>1033</Language>
<Collation>English</Collation>
<Dimensions>(...)</Dimensions>
<MeasureGroups>
<MeasureGroup>
<ID>FAKT</ID>
<Name>FAKT</Name>
<Measures>
<Measure>
<ID>Miara1</ID>
<Name>Miara1</Name>
<DataType>Integer</DataType>
<Source>
<DataType>Integer</DataType>
<Source xsi:type="ColumnBinding">
<TableID>dbo_FACT</TableID>
<ColumnID>measure1</ColumnID>
</Source>
</Source>
</Measure>
<Measure>
<ID>FACT</ID>
<Name>FACT</Name>
<AggregateFunction>Count</AggregateFunction>
<DataType>Integer</DataType>
<Source>
<DataType>Integer</DataType>
<DataSize>4</DataSize>
<Source xsi:type="RowBinding">
<TableID>dbo_FAKT</TableID>
</Source>
</Source>
</Measure>
</Measures>
<StorageMode>Molap</StorageMode>
<ProcessingMode>Regular</ProcessingMode>
<Dimensions>
<Dimension xsi:type="RegularMeasureGroupDimension">
<CubeDimensionID>WYMIAR</CubeDimensionID>
<Attributes>
<Attribute>
<AttributeID>Id Wymiar</AttributeID>
<KeyColumns>
<KeyColumn>
<DataType>Integer</DataType>
<NullProcessing>UnknownMember</NullProcessing>
<Source xsi:type="ColumnBinding">
<TableID>dbo_FAKT</TableID>
<ColumnID>id_wymiar</ColumnID>
</Source>
</KeyColumn>
</KeyColumns>
<Type>Granularity</Type>
</Attribute>
</Attributes>
</Dimension>
<Dimension d7p1:type="RegularMeasureGroupDimension" xmlns:d7p1="http://www.w3.org/2001/XmlSchema-instance">
<CubeDimensionID>WYMIAR2</CubeDimensionID>
<Attributes>
<Attribute>
<AttributeID>Id Wymiar2</AttributeID>
<KeyColumns>
<KeyColumn>
<DataType>Integer</DataType>
<NullProcessing>UnknownMember</NullProcessing>
<Source xmlns:xsi="http://www.w3.org/2001/XmlSchema-instance" xsi:type="ColumnBinding">
<TableID>dbo_FAKT</TableID>
<ColumnID>id_wymiar</ColumnID>
</Source>
</KeyColumn>
</KeyColumns>
<Type>Granularity</Type>
</Attribute>
</Attributes>
</Dimension>
</Dimensions>
1 个解决方案
#1
0
You can try using XmlDocument.CreateAttribute(prefix, localName, namespaceURI)
method which allows us to specify prefix of the attribute, for example :
您可以尝试使用XmlDocument.CreateAttribute(prefix,localName,namespaceURI)方法,该方法允许我们指定属性的前缀,例如:
var attr = doc.CreateAttribute("xsi", "type", "http://www.w3.org/2001/XmlSchema-instance");
attr.Value = "RegularMeasureGroupDimension";
dimension2.SetAttributeNode(attr);
#1
0
You can try using XmlDocument.CreateAttribute(prefix, localName, namespaceURI)
method which allows us to specify prefix of the attribute, for example :
您可以尝试使用XmlDocument.CreateAttribute(prefix,localName,namespaceURI)方法,该方法允许我们指定属性的前缀,例如:
var attr = doc.CreateAttribute("xsi", "type", "http://www.w3.org/2001/XmlSchema-instance");
attr.Value = "RegularMeasureGroupDimension";
dimension2.SetAttributeNode(attr);