我找到了一些关于这个问题的提示,但仍然没有帮助我.
这是我的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: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文档取决于XML文档是否使用命名空间…
没有名称空间
使用xsi:noNamespaceSchemaLocation提供有关要使用的XSD的提示:
> XML
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="example.xsd"> <!-- ... --> </root>
> XSD
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="root"> <!-- ... --> </xsd:element> </xsd:schema>
使用名称空间
使用xsi:schemaLocation提供有关要使用的XSD的提示:
> XML
<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" targetNamespace="http://example.com/ns"> <xsd:element name="root"> <!-- ... --> </xsd:element> </xsd:schema>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。