我需要为这个对象创建一个XmlSchemaSet:
public class ChartData
{
public string[] SeriesNames;
//enum
public ChartDataType CategoryDataType;
public int CategoryFormatCode;
public string[] CategoryNames;
public double[][] Values;
}我尝试了seriesNames的这个定义,但是它没有给出错误消息:
在此上下文中不支持
'http://www.w3.org/2001/XMLSchema:complexType'元素。
<xs:schema attributeFormDefault='unqualified' elementFormDefault='qualified' xmlns:xs='http://www.w3.org/2001/XMLSchema'>
<xs:element name='Chart'>
<xs:complexType>
<xs:attribute name='SeriesNames'>
<xs:complexType>
<xs:attribute maxOccurs='unbounded' type='xs:string'/>
</xs:complexType>
</xs:attribute>
<xs:attribute name='Values' type='xs:string' use='required' />
<xs:attribute name='CategoryDataType' type='xs:string' use='optional' />
<xs:attribute name='CategoryFormatCode' type='xs:string' use='optional' />
<xs:attribute name='CategoryNames' type='xs:string' use='required' />
<xs:attribute name='Optional' type='xs:boolean' use='optional' />
</xs:complexType>
</xs:element>
</xs:schema>如果我使用这个定义:
<xs:attribute name='SeriesNames' type='xs:string' use='required' />当我使用XPathEvaluate时,它不会读取字符串数组
如有任何帮助,将不胜感激。
发布于 2020-05-25 20:08:07
尝试以下几个方面:
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema attributeFormDefault='unqualified' elementFormDefault='qualified' xmlns:xs='http://www.w3.org/2001/XMLSchema'>
<xs:element name='Chart'>
<xs:complexType>
<xs:sequence>
<xs:element name='SeriesNames' type='xs:string' minOccurs="0" maxOccurs='unbounded'/>
</xs:sequence>
<xs:attribute name='CategoryDataType' type='xs:string' use='optional' />
<xs:attribute name='CategoryFormatCode' type='xs:string' use='optional' />
<xs:attribute name='CategoryNames' type='xs:string' use='required' />
<xs:attribute name='Optional' type='xs:boolean' use='optional' />
</xs:complexType>
</xs:element>
</xs:schema>发布于 2020-05-26 06:28:13
谢谢您的回复,但是当我执行定义时,我得到了错误:模式验证错误:“SeriesNames”属性没有声明。
我执行的代码如下:
var XsdMarkup = @"<xs:schema attributeFormDefault='unqualified' elementFormDefault='qualified' xmlns:xs='http://www.w3.org/2001/XMLSchema'>
<xs:element name='Chart'>
<xs:complexType>
<xs:sequence>
<xs:element name='SeriesNames' type='xs:string' minOccurs="0" maxOccurs='unbounded'/>
</xs:sequence>
<xs:attribute name='Values' type='xs:string' use='required' />
<xs:attribute name='CategoryDataType' type='xs:string' use='optional' />
<xs:attribute name='CategoryFormatCode' type='xs:string' use='optional' />
<xs:attribute name='CategoryNames' type='xs:string' use='required' />
<xs:attribute name='Optional' type='xs:boolean' use='optional' />
</xs:complexType>
</xs:element>
</xs:schema>";
XmlReader = XmlReader.Create(new StringReader(XsdMarkup));https://stackoverflow.com/questions/62005771
复制相似问题