小编McM*_*nus的帖子

C#中的XML模式1.1断言

我正在使用以下xml架构验证一些xml文件:

        String xsdMarkup = 
          "[...]

           <xsd:complexType name='connectionType'>
                <xsd:attribute name='SourceElement' type='guidType' use='required' />
                <xsd:attribute name='TargetElement' type='guidType' use='required' />
                <xsd:attribute name='GUID' type='guidType' use='required' />
                <xsd:assert test='@SourceElement == 0' />
           </xsd:complexType>

           [...]
          ";

        XmlSchemaSet schemas = new XmlSchemaSet();
        schemas.Add("", XmlReader.Create(new StringReader(xsdMarkup)));
        Console.WriteLine("Validating doc ...");
        docToValidate.Validate(schemas, (sender, e) =>
        {
            Console.WriteLine(e.Message);
            valid = false;
        }, true);
Run Code Online (Sandbox Code Playgroud)

我只是想介绍一些断言标签,以便进行更强大的验证.但这导致例外:

System.Xml.Schema.XmlSchemaException:此上下文不支持http://www.w3.org/2001/XMLSchema:assert-element.

我现在还不知道的是......

  1. 我在xsd中的错误位置使用了assert-element
  2. http://www.w3.org/2001/XMLSchema-Namespace不支持XML架构1.1版,并由此断言元素
  3. C#XmlSchemaSet不知道如何处理断言元素

提前感谢您的帮助!

c# xsd

3
推荐指数
1
解决办法
2752
查看次数

创建矩阵索引矩阵

我想创建一个二维向量矩阵.每个向量应包含矩阵中自己位置的x/y索引(或者,如果需要,则为i,j).

基本上我想要这样的东西:

具有二维向量的矩阵

我知道我可以在for循环中创建它,但有更简单的方法吗?Matlab对于这样的事情有很多有用的功能,它让我不止一次感到惊讶.

matlab

1
推荐指数
1
解决办法
156
查看次数

标签 统计

c# ×1

matlab ×1

xsd ×1