如何从xml引用xsd文件

时间:2014-02-09 09:22:49

标签: c# xml xsd

1)pls.xsd档案

我已将pls.xsd中的xml.xsd包含在同一文件夹

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<!-- Externals changed by QTAssistant (http://www.paschidev.com) -->

<!--
  This is a draft schema for the XML language defined in the 
  Pronunciation Lexicon Specification 
  (latest version at <http://www.w3.org/TR/pronunciation-lexicon/>)
  At the time of writing, the specification as well as this schema are
  subject to change, and no guarantee is made on their accuracy or the fact
  that they are in sync.
  Last modified: $Date: 2007/12/11 12:08:40 $

  Copyright û 2006 World Wide Web Consortium, (Massachusetts Institute
  of Technology, ERCIM, Keio University). All Rights Reserved. See
    http://www.w3.org/Consortium/Legal/.
-->
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:p="http://www.w3.org/2005/01/pronunciation-lexicon"
targetNamespace="http://www.w3.org/2005/01/pronunciation-lexicon"
elementFormDefault="qualified" version="1.0">
<xs:annotation>
    <xs:documentation>Importing dependent namespaces</xs:documentation>
</xs:annotation>
<xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd" />

 ...
</xs:schema>

2)我的XML文件 从这个文件我引用pls.xsd

<?xml version="1.0" encoding="utf-8"?> 
<lexicon version="1.0"
xmlns="http://www.w3.org/2005/01/pronunciation-lexicon"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2005/01/pronunciation-lexicon
file://C:/xsdforproject/pls.xsd" 
alphabet="x-microsoft-ups" xml:lang="en-IN">
    <lexeme>

    </lexeme>
</lexicon>

我上面有两个代码,这些代码在我的XMLpls.xsd文件中都出现错误, 打开外部“DTD”file:///C:/xsdforproject/XMLSchema.dtd': Could not find file 'C:\xsdforproject\XMLSchema.dtd

时发生错误

我正在使用“Visual Studio 2010”。

如何解决此问题?

1 个答案:

答案 0 :(得分:0)

您正在使用的东西似乎是引用XMLSchema.dtd,所以您是否尝试下载它并将其放在xsdforproject文件夹中?

http://www.w3.org/2009/XMLSchema/XMLSchema.dtd