Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在带有DTD的XML/SVG文件上使用XmlReader时出现验证错误(Unity/Mono C#)_C#_Xml_Validation_Mono_Dtd - Fatal编程技术网

在带有DTD的XML/SVG文件上使用XmlReader时出现验证错误(Unity/Mono C#)

在带有DTD的XML/SVG文件上使用XmlReader时出现验证错误(Unity/Mono C#),c#,xml,validation,mono,dtd,C#,Xml,Validation,Mono,Dtd,我试图读取C#(Unity/Mono C#)中的SVG文件,以便提取我感兴趣的路径元素。我实际上不想验证文档。我甚至尝试过ValidationType=ValidationType。没有一个是无效的 我不断地遇到错误,如果不修改SVG文件,我就无法得到要验证的文件或跳过验证 我已经检查了文件是否是来自的有效SVG/XML,结果很好 错误: XmlSchemaException: XmlSchema error: Element svg is not declared. // Set the v

我试图读取C#(Unity/Mono C#)中的SVG文件,以便提取我感兴趣的路径元素。我实际上不想验证文档。我甚至尝试过ValidationType=ValidationType。没有一个是无效的

我不断地遇到错误,如果不修改SVG文件,我就无法得到要验证的文件或跳过验证

我已经检查了文件是否是来自的有效SVG/XML,结果很好

错误:

XmlSchemaException: XmlSchema error: Element svg is not declared.
// Set the validation settings.
XmlReaderSettings settings = new XmlReaderSettings();
settings.XmlResolver = null;
settings.ValidationType = ValidationType.DTD;
settings.ProhibitDtd = false;
settings.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack);
settings.IgnoreWhitespace = true;

// Create the reader
XmlReader reader = XmlReader.Create(path_to_kanji, settings);

//Parse the file.
while (reader.Read())
{
    //Extraction of data
}
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2009/2010/2011 Ulrich Apel.
This work is distributed under the conditions of the Creative Commons
Attribution-Share Alike 3.0 Licence. This means you are free:
* to Share - to copy, distribute and transmit the work
* to Remix - to adapt the work

Under the following conditions:
* Attribution. You must attribute the work by stating your use of KanjiVG in
  your own copyright header and linking to KanjiVG's website
  (http://kanjivg.tagaini.net)
* Share Alike. If you alter, transform, or build upon this work, you may
  distribute the resulting work only under the same or similar license to this
  one.

See http://creativecommons.org/licenses/by-sa/3.0/ for more details.
-->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd" [
<!ATTLIST g
xmlns:kvg CDATA #FIXED "http://kanjivg.tagaini.net"
kvg:element CDATA #IMPLIED
kvg:variant CDATA #IMPLIED
kvg:partial CDATA #IMPLIED
kvg:original CDATA #IMPLIED
kvg:part CDATA #IMPLIED
kvg:number CDATA #IMPLIED
kvg:tradForm CDATA #IMPLIED
kvg:radicalForm CDATA #IMPLIED
kvg:position CDATA #IMPLIED
kvg:radical CDATA #IMPLIED
kvg:phon CDATA #IMPLIED >
<!ATTLIST path
xmlns:kvg CDATA #FIXED "http://kanjivg.tagaini.net"
kvg:type CDATA #IMPLIED >
]>
<svg xmlns="http://www.w3.org/2000/svg" width="109" height="109" viewBox="0 0 109 109">
<g id="kvg:StrokePaths_0f9ad" style="fill:none;stroke:#000000;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;">
<g id="kvg:0f9ad" kvg:element="玲">
    <g id="kvg:0f9ad-g1" kvg:element="王" kvg:original="玉" kvg:partial="true" kvg:position="left" kvg:radical="general">
        <path id="kvg:0f9ad-s1" kvg:type="㇐" d="M9.65,28.33c1.53,0.84,5.07,0.34,6.71,0.11c4.56-0.63,10.35-1.83,15.79-2.75c1.41-0.24,3.32-0.74,4.74-0.23"/>
        <path id="kvg:0f9ad-s2" kvg:type="㇑a" d="M22.42,30.71c1.06,1.06,1.31,2.04,1.31,3.38c0,4.92,0.04,35.9-0.11,39.17"/>
        <path id="kvg:0f9ad-s3" kvg:type="㇐" d="M10.16,51.37c0.49,0.33,3.93,0.35,4.43,0.31C19,51.25,27.5,49.62,32.44,48.7c0.6-0.11,1.93-0.32,3.25-0.09"/>
        <path id="kvg:0f9ad-s4" kvg:type="㇐" d="M10.77,78.95c1.03,0.83,2.01,1.11,3.51,0.33c5.6-2.9,10.93-6,18-9.92"/>
    </g>
    <g id="kvg:0f9ad-g2" kvg:element="令" kvg:position="right">
        <g id="kvg:0f9ad-g3" kvg:element="人" kvg:position="top">
            <path id="kvg:0f9ad-s5" kvg:type="㇒" d="M62.64,12.75c0.08,0.95,0.13,2.52-0.4,3.83C58.5,25.88,50.38,41.12,39,52.35"/>
            <path id="kvg:0f9ad-s6" kvg:type="㇏" d="M62.92,17.79c8.4,8.61,15.21,17.33,24.47,26.71c2.09,2.12,5.1,4.24,7.37,5.63"/>
        </g>
        <g id="kvg:0f9ad-g4" kvg:position="bottom">
            <g id="kvg:0f9ad-g5" kvg:element="一">
                <path id="kvg:0f9ad-s7" kvg:type="㇐" d="M50.9,46.1c1.76,0.72,3.84,0.36,5.65,0.14c5.4-0.66,13.08-1.76,18.48-2.24c1.88-0.17,3.54-0.23,5.37,0.21"/>
            </g>
            <g id="kvg:0f9ad-g6" kvg:element="卩" kvg:original="マ">
                <path id="kvg:0f9ad-s8" kvg:type="㇆" d="M51.4,54.6c0.61,0.15,3,1,4.21,0.87c3.29-0.37,17.99-4.02,19.51-4.17c1.52-0.15,4.28-0.29,3.95,2.89c-0.43,4.17-2.68,16.92-6,23.84c-1.89,3.94-3.18,3.45-6.23,0.46"/>
                <path id="kvg:0f9ad-s9" kvg:type="㇑" d="M58.58125,55.567708 c 0.87,0.87 1.8,2 1.8,3.5 -0.219826,13.545146 0.202719,23.466557 -0.18,37.006667"/>
            </g>
        </g>
    </g>
</g>
</g>
<g id="kvg:StrokeNumbers_0f9ad" style="font-size:8;fill:#808080">
    <text transform="matrix(1 0 0 1 3.60 28.25)">1</text>
    <text transform="matrix(1 0 0 1 15.25 39.25)">2</text>
    <text transform="matrix(1 0 0 1 3.25 52.25)">3</text>
    <text transform="matrix(1 0 0 1 3.25 81.25)">4</text>
    <text transform="matrix(1 0 0 1 54.25 15.25)">5</text>
    <text transform="matrix(1 0 0 1 69.25 22.25)">6</text>
    <text transform="matrix(1 0 0 1 53.7 44)">7</text>
    <text transform="matrix(1 0 0 1 44.6 58.1)">8</text>
    <text transform="matrix(1 0 0 1 62.5 63)">9</text>
</g>
</svg>
或者(当我编辑SVG并将本地文件放入!DOCTYPE时)

代码:

XmlSchemaException: XmlSchema error: Element svg is not declared.
// Set the validation settings.
XmlReaderSettings settings = new XmlReaderSettings();
settings.XmlResolver = null;
settings.ValidationType = ValidationType.DTD;
settings.ProhibitDtd = false;
settings.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack);
settings.IgnoreWhitespace = true;

// Create the reader
XmlReader reader = XmlReader.Create(path_to_kanji, settings);

//Parse the file.
while (reader.Read())
{
    //Extraction of data
}
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2009/2010/2011 Ulrich Apel.
This work is distributed under the conditions of the Creative Commons
Attribution-Share Alike 3.0 Licence. This means you are free:
* to Share - to copy, distribute and transmit the work
* to Remix - to adapt the work

Under the following conditions:
* Attribution. You must attribute the work by stating your use of KanjiVG in
  your own copyright header and linking to KanjiVG's website
  (http://kanjivg.tagaini.net)
* Share Alike. If you alter, transform, or build upon this work, you may
  distribute the resulting work only under the same or similar license to this
  one.

See http://creativecommons.org/licenses/by-sa/3.0/ for more details.
-->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd" [
<!ATTLIST g
xmlns:kvg CDATA #FIXED "http://kanjivg.tagaini.net"
kvg:element CDATA #IMPLIED
kvg:variant CDATA #IMPLIED
kvg:partial CDATA #IMPLIED
kvg:original CDATA #IMPLIED
kvg:part CDATA #IMPLIED
kvg:number CDATA #IMPLIED
kvg:tradForm CDATA #IMPLIED
kvg:radicalForm CDATA #IMPLIED
kvg:position CDATA #IMPLIED
kvg:radical CDATA #IMPLIED
kvg:phon CDATA #IMPLIED >
<!ATTLIST path
xmlns:kvg CDATA #FIXED "http://kanjivg.tagaini.net"
kvg:type CDATA #IMPLIED >
]>
<svg xmlns="http://www.w3.org/2000/svg" width="109" height="109" viewBox="0 0 109 109">
<g id="kvg:StrokePaths_0f9ad" style="fill:none;stroke:#000000;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;">
<g id="kvg:0f9ad" kvg:element="玲">
    <g id="kvg:0f9ad-g1" kvg:element="王" kvg:original="玉" kvg:partial="true" kvg:position="left" kvg:radical="general">
        <path id="kvg:0f9ad-s1" kvg:type="㇐" d="M9.65,28.33c1.53,0.84,5.07,0.34,6.71,0.11c4.56-0.63,10.35-1.83,15.79-2.75c1.41-0.24,3.32-0.74,4.74-0.23"/>
        <path id="kvg:0f9ad-s2" kvg:type="㇑a" d="M22.42,30.71c1.06,1.06,1.31,2.04,1.31,3.38c0,4.92,0.04,35.9-0.11,39.17"/>
        <path id="kvg:0f9ad-s3" kvg:type="㇐" d="M10.16,51.37c0.49,0.33,3.93,0.35,4.43,0.31C19,51.25,27.5,49.62,32.44,48.7c0.6-0.11,1.93-0.32,3.25-0.09"/>
        <path id="kvg:0f9ad-s4" kvg:type="㇐" d="M10.77,78.95c1.03,0.83,2.01,1.11,3.51,0.33c5.6-2.9,10.93-6,18-9.92"/>
    </g>
    <g id="kvg:0f9ad-g2" kvg:element="令" kvg:position="right">
        <g id="kvg:0f9ad-g3" kvg:element="人" kvg:position="top">
            <path id="kvg:0f9ad-s5" kvg:type="㇒" d="M62.64,12.75c0.08,0.95,0.13,2.52-0.4,3.83C58.5,25.88,50.38,41.12,39,52.35"/>
            <path id="kvg:0f9ad-s6" kvg:type="㇏" d="M62.92,17.79c8.4,8.61,15.21,17.33,24.47,26.71c2.09,2.12,5.1,4.24,7.37,5.63"/>
        </g>
        <g id="kvg:0f9ad-g4" kvg:position="bottom">
            <g id="kvg:0f9ad-g5" kvg:element="一">
                <path id="kvg:0f9ad-s7" kvg:type="㇐" d="M50.9,46.1c1.76,0.72,3.84,0.36,5.65,0.14c5.4-0.66,13.08-1.76,18.48-2.24c1.88-0.17,3.54-0.23,5.37,0.21"/>
            </g>
            <g id="kvg:0f9ad-g6" kvg:element="卩" kvg:original="マ">
                <path id="kvg:0f9ad-s8" kvg:type="㇆" d="M51.4,54.6c0.61,0.15,3,1,4.21,0.87c3.29-0.37,17.99-4.02,19.51-4.17c1.52-0.15,4.28-0.29,3.95,2.89c-0.43,4.17-2.68,16.92-6,23.84c-1.89,3.94-3.18,3.45-6.23,0.46"/>
                <path id="kvg:0f9ad-s9" kvg:type="㇑" d="M58.58125,55.567708 c 0.87,0.87 1.8,2 1.8,3.5 -0.219826,13.545146 0.202719,23.466557 -0.18,37.006667"/>
            </g>
        </g>
    </g>
</g>
</g>
<g id="kvg:StrokeNumbers_0f9ad" style="font-size:8;fill:#808080">
    <text transform="matrix(1 0 0 1 3.60 28.25)">1</text>
    <text transform="matrix(1 0 0 1 15.25 39.25)">2</text>
    <text transform="matrix(1 0 0 1 3.25 52.25)">3</text>
    <text transform="matrix(1 0 0 1 3.25 81.25)">4</text>
    <text transform="matrix(1 0 0 1 54.25 15.25)">5</text>
    <text transform="matrix(1 0 0 1 69.25 22.25)">6</text>
    <text transform="matrix(1 0 0 1 53.7 44)">7</text>
    <text transform="matrix(1 0 0 1 44.6 58.1)">8</text>
    <text transform="matrix(1 0 0 1 62.5 63)">9</text>
</g>
</svg>
SVG文件:

XmlSchemaException: XmlSchema error: Element svg is not declared.
// Set the validation settings.
XmlReaderSettings settings = new XmlReaderSettings();
settings.XmlResolver = null;
settings.ValidationType = ValidationType.DTD;
settings.ProhibitDtd = false;
settings.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack);
settings.IgnoreWhitespace = true;

// Create the reader
XmlReader reader = XmlReader.Create(path_to_kanji, settings);

//Parse the file.
while (reader.Read())
{
    //Extraction of data
}
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2009/2010/2011 Ulrich Apel.
This work is distributed under the conditions of the Creative Commons
Attribution-Share Alike 3.0 Licence. This means you are free:
* to Share - to copy, distribute and transmit the work
* to Remix - to adapt the work

Under the following conditions:
* Attribution. You must attribute the work by stating your use of KanjiVG in
  your own copyright header and linking to KanjiVG's website
  (http://kanjivg.tagaini.net)
* Share Alike. If you alter, transform, or build upon this work, you may
  distribute the resulting work only under the same or similar license to this
  one.

See http://creativecommons.org/licenses/by-sa/3.0/ for more details.
-->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd" [
<!ATTLIST g
xmlns:kvg CDATA #FIXED "http://kanjivg.tagaini.net"
kvg:element CDATA #IMPLIED
kvg:variant CDATA #IMPLIED
kvg:partial CDATA #IMPLIED
kvg:original CDATA #IMPLIED
kvg:part CDATA #IMPLIED
kvg:number CDATA #IMPLIED
kvg:tradForm CDATA #IMPLIED
kvg:radicalForm CDATA #IMPLIED
kvg:position CDATA #IMPLIED
kvg:radical CDATA #IMPLIED
kvg:phon CDATA #IMPLIED >
<!ATTLIST path
xmlns:kvg CDATA #FIXED "http://kanjivg.tagaini.net"
kvg:type CDATA #IMPLIED >
]>
<svg xmlns="http://www.w3.org/2000/svg" width="109" height="109" viewBox="0 0 109 109">
<g id="kvg:StrokePaths_0f9ad" style="fill:none;stroke:#000000;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;">
<g id="kvg:0f9ad" kvg:element="玲">
    <g id="kvg:0f9ad-g1" kvg:element="王" kvg:original="玉" kvg:partial="true" kvg:position="left" kvg:radical="general">
        <path id="kvg:0f9ad-s1" kvg:type="㇐" d="M9.65,28.33c1.53,0.84,5.07,0.34,6.71,0.11c4.56-0.63,10.35-1.83,15.79-2.75c1.41-0.24,3.32-0.74,4.74-0.23"/>
        <path id="kvg:0f9ad-s2" kvg:type="㇑a" d="M22.42,30.71c1.06,1.06,1.31,2.04,1.31,3.38c0,4.92,0.04,35.9-0.11,39.17"/>
        <path id="kvg:0f9ad-s3" kvg:type="㇐" d="M10.16,51.37c0.49,0.33,3.93,0.35,4.43,0.31C19,51.25,27.5,49.62,32.44,48.7c0.6-0.11,1.93-0.32,3.25-0.09"/>
        <path id="kvg:0f9ad-s4" kvg:type="㇐" d="M10.77,78.95c1.03,0.83,2.01,1.11,3.51,0.33c5.6-2.9,10.93-6,18-9.92"/>
    </g>
    <g id="kvg:0f9ad-g2" kvg:element="令" kvg:position="right">
        <g id="kvg:0f9ad-g3" kvg:element="人" kvg:position="top">
            <path id="kvg:0f9ad-s5" kvg:type="㇒" d="M62.64,12.75c0.08,0.95,0.13,2.52-0.4,3.83C58.5,25.88,50.38,41.12,39,52.35"/>
            <path id="kvg:0f9ad-s6" kvg:type="㇏" d="M62.92,17.79c8.4,8.61,15.21,17.33,24.47,26.71c2.09,2.12,5.1,4.24,7.37,5.63"/>
        </g>
        <g id="kvg:0f9ad-g4" kvg:position="bottom">
            <g id="kvg:0f9ad-g5" kvg:element="一">
                <path id="kvg:0f9ad-s7" kvg:type="㇐" d="M50.9,46.1c1.76,0.72,3.84,0.36,5.65,0.14c5.4-0.66,13.08-1.76,18.48-2.24c1.88-0.17,3.54-0.23,5.37,0.21"/>
            </g>
            <g id="kvg:0f9ad-g6" kvg:element="卩" kvg:original="マ">
                <path id="kvg:0f9ad-s8" kvg:type="㇆" d="M51.4,54.6c0.61,0.15,3,1,4.21,0.87c3.29-0.37,17.99-4.02,19.51-4.17c1.52-0.15,4.28-0.29,3.95,2.89c-0.43,4.17-2.68,16.92-6,23.84c-1.89,3.94-3.18,3.45-6.23,0.46"/>
                <path id="kvg:0f9ad-s9" kvg:type="㇑" d="M58.58125,55.567708 c 0.87,0.87 1.8,2 1.8,3.5 -0.219826,13.545146 0.202719,23.466557 -0.18,37.006667"/>
            </g>
        </g>
    </g>
</g>
</g>
<g id="kvg:StrokeNumbers_0f9ad" style="font-size:8;fill:#808080">
    <text transform="matrix(1 0 0 1 3.60 28.25)">1</text>
    <text transform="matrix(1 0 0 1 15.25 39.25)">2</text>
    <text transform="matrix(1 0 0 1 3.25 52.25)">3</text>
    <text transform="matrix(1 0 0 1 3.25 81.25)">4</text>
    <text transform="matrix(1 0 0 1 54.25 15.25)">5</text>
    <text transform="matrix(1 0 0 1 69.25 22.25)">6</text>
    <text transform="matrix(1 0 0 1 53.7 44)">7</text>
    <text transform="matrix(1 0 0 1 44.6 58.1)">8</text>
    <text transform="matrix(1 0 0 1 62.5 63)">9</text>
</g>
</svg>

]>
1.
2.
3.
4.
5.
6.
7.
8.
9