我在XML文件中引用我的XML Schema时遇到了这个问题.
我在这条道路上有我的XSD:
C:\environment\workspace\maven-ws\ProjectXmlSchema\email.xsd
Run Code Online (Sandbox Code Playgroud)
但是当我在我的XML文件中尝试找到这样的架构时,找不到XSD:
<?xml version="1.0" encoding="UTF-8" ?>
<email xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3schools.com
file://C://environment//workspace//maven-ws//ProjextXmlSchema//email.xsd">
Run Code Online (Sandbox Code Playgroud)
找到XSD的唯一方法是它在同一个文件夹中:
xsi:schemaLocation="http://www.w3schools.com email.xsd"
Run Code Online (Sandbox Code Playgroud)
所以问题是:如果XML文件与XSD文件不在同一个文件夹中,那么路径必须如何才能找到XSD?
顺便说一句,我一直在使用的例子来自MSDN:他们声称它应该按照我试图的方式工作.但事实并非如此.
我对XML/Schema文件的了解有限.
所以这应该是一个相当简单的问题.如何为schemaLocation指定本地文件?
<?xml version="1.0"?>
<note
xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3schools.com note.xsd">
...
</note>
Run Code Online (Sandbox Code Playgroud)
这是来自www.w3.org的示例,指定架构的部分位于schemaLocation中.我试着查看文档,但是如何指定本地文件?
就像是
xsi:schemaLocation="../relativepath/schemafolder not.xsd">
Run Code Online (Sandbox Code Playgroud)
谢谢
我正在使用Spring的ehcache.最近注意到以下错误.此外,现在http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcache-spring-1.1.xsd中缺少XSD文件.
如果有解决方法在本地加载XSD,请告诉我.
org.xml.sax.SAXParseException; lineNumber: 164; columnNumber: 59; schema_reference.4: Failed to read schema document 'http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcache-spring-1.1.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.warning(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.xs.traversers.XSDHandler.reportSchemaWarning(Unknown Source)
at org.apache.xerces.impl.xs.traversers.XSDHandler.getSchemaDocument1(Unknown Source)
at org.apache.xerces.impl.xs.traversers.XSDHandler.getSchemaDocument(Unknown Source)
at org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.findSchemaGrammar(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.emptyElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at …Run Code Online (Sandbox Code Playgroud) 我正在尝试一些XML Schema示例,并且必须使用示例XML文件对其进行验证。该架构是本地文件(someFile.xsd)。我正在使用eclipse,并希望在XML文件中包括一个指向该本地xsd文件的引用,以便eclipse可以向我建议元素。
我发现很难提出包含本地文件的语法。有什么建议么 ?