如何使用schemaLocation或noNamespaceSchemaLocation将XML链接到XSD?
我找到了一些解决这个问题的方法,但仍然没有帮到我 这是我的XML如何使用schemaLocation或noNamespaceSchemaLocation将XML链接到XSD?,xml,xsd,xsd-validation,xml-validation,Xml,Xsd,Xsd Validation,Xml Validation,我找到了一些解决这个问题的方法,但仍然没有帮到我 这是我的XML <?xml version="1.0" encoding="UTF-8"?> <work xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.w3.org/2001/XMLSchema-instance" tns:schemaLocation="myXSDSchema.xsd"> <tns:Objec
<?xml version="1.0" encoding="UTF-8"?>
<work xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://www.w3.org/2001/XMLSchema-instance"
tns:schemaLocation="myXSDSchema.xsd">
<tns:Objects>
<tns:Object Name=":" Location=":">
</tns:Object>
</tns:Objects>
</work>
这是我的XSD文件:
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:tns = "http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
(some checks)
</schema>
(一些支票)
我的XSD文件与XML文件位于同一文件夹中
如何链接这两个文件?如何将XSD链接到XML文档取决于XML文档是否使用名称空间
没有名称空间
使用xsi:noNamespaceSchemaLocation
提供有关要使用的XSD的提示:
- XML
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="example.xsd"> <!-- ... --> </root>
<ns:root xmlns:ns="http://example.com/ns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://example.com/ns example-ns.xsd"> <!-- ... --> </ns:root>
- XSD
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="root"> <!-- ... --> </xsd:element> </xsd:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://example.com/ns"> <xsd:element name="root"> <!-- ... --> </xsd:element> </xsd:schema>
xsd
的语法是否相同?是的,本地或远程的xsd语法相同;两者都是URL。如果在指定本地URL时遇到问题,请参阅