首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >xsd验证失败-引用本地xsd文件

xsd验证失败-引用本地xsd文件
EN

Stack Overflow用户
提问于 2021-09-15 16:25:28
回答 1查看 55关注 0票数 0

我有一个xml文件,它的dt:dt是我以前从未见过的:

代码语言:javascript
复制
<?xml version='1.0' encoding='UTF-8'?>
<enfinity xsi:schemaLocation="http://www.intershop.com/xml/ns/enfinity/7.0/xcs/impex catalog.xsd http://www.intershop.com/xml/ns/enfinity/6.5/core/impex-dt dt.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.intershop.com/xml/ns/enfinity/7.0/xcs/impex" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:dt="http://www.intershop.com/xml/ns/enfinity/6.5/core/impex-dt" major="6" minor="1" family="enfinity" branch="enterprise" build="build">
  <offer sku="423182110">
    <custom-attributes>
      <custom-attribute name="sizeEU" dt:dt="string">42</custom-attribute>
    </custom-attributes>
  </offer>
</enfinity> 

当我使用VS基于上述xml创建一个xsd时,它创建了两个文件:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:tns="http://www.intershop.com/xml/ns/enfinity/6.5/core/impex-dt" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.intershop.com/xml/ns/enfinity/6.5/core/impex-dt" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:attribute name="dt" type="xs:string" />
</xs:schema>

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dt="http://www.intershop.com/xml/ns/enfinity/6.5/core/impex-dt" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.intershop.com/xml/ns/enfinity/7.0/xcs/impex" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:import namespace="http://www.w3.org/XML/1998/namespace" />
    <xs:import namespace="http://www.intershop.com/xml/ns/enfinity/6.5/core/impex-dt" />
    <xs:element name="enfinity">
        <xs:complexType>
            <xs:sequence>
                <xs:element maxOccurs="unbounded" name="offer">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="short-description">
                                <xs:complexType>
                                    <xs:simpleContent>
                                        <xs:extension base="xs:string">
                                            <xs:attribute ref="xml:lang" use="required" />
                                        </xs:extension>
                                    </xs:simpleContent>
                                </xs:complexType>
                            </xs:element>
                            <xs:element minOccurs="0" name="variations">
                                <xs:complexType>
                                    <xs:sequence>
                                        <xs:element name="mastered-products">
                                            <xs:complexType>
                                                <xs:sequence>
                                                    <xs:element maxOccurs="unbounded" name="mastered-product">
                                                        <xs:complexType>
                                                            <xs:attribute name="sku" type="xs:unsignedInt" use="required" />
                                                            <xs:attribute name="domain" type="xs:string" use="required" />
                                                            <xs:attribute name="default" type="xs:unsignedByte" use="required" />
                                                            <xs:attribute name="productvariationposition" type="xs:unsignedShort" use="required" />
                                                        </xs:complexType>
                                                    </xs:element>
                                                </xs:sequence>
                                            </xs:complexType>
                                        </xs:element>
                                        <xs:element name="variation-attributes">
                                            <xs:complexType>
                                                <xs:sequence>
                                                    <xs:element maxOccurs="unbounded" name="variation-attribute">
                                                        <xs:complexType>
                                                            <xs:sequence>
                                                                <xs:element name="presentation-option" type="xs:string" />
                                                                <xs:element minOccurs="0" name="presentation-product-attribute-name" type="xs:string" />
                                                                <xs:element name="custom-attributes">
                                                                    <xs:complexType>
                                                                        <xs:sequence>
                                                                            <xs:element name="custom-attribute">
                                                                                <xs:complexType>
                                                                                    <xs:simpleContent>
                                                                                        <xs:extension base="xs:string">
                                                                                            <xs:attribute name="name" type="xs:string" use="required" />
                                                                                            <xs:attribute ref="dt:dt" use="required" />
                                                                                            <xs:attribute ref="xml:lang" use="required" />
                                                                                        </xs:extension>
                                                                                    </xs:simpleContent>
                                                                                </xs:complexType>
                                                                            </xs:element>
                                                                        </xs:sequence>
                                                                    </xs:complexType>
                                                                </xs:element>
                                                            </xs:sequence>
                                                            <xs:attribute name="name" type="xs:string" use="required" />
                                                        </xs:complexType>
                                                    </xs:element>
                                                </xs:sequence>
                                            </xs:complexType>
                                        </xs:element>
                                    </xs:sequence>
                                </xs:complexType>
                            </xs:element>
                            <xs:element name="custom-attributes">
                                <xs:complexType>
                                    <xs:sequence>
                                        <xs:element maxOccurs="unbounded" name="custom-attribute">
                                            <xs:complexType>
                                                <xs:simpleContent>
                                                    <xs:extension base="xs:string">
                                                        <xs:attribute name="name" type="xs:string" use="required" />
                                                        <xs:attribute ref="dt:dt" use="required" />
                                                    </xs:extension>
                                                </xs:simpleContent>
                                            </xs:complexType>
                                        </xs:element>
                                    </xs:sequence>
                                </xs:complexType>
                            </xs:element>
                        </xs:sequence>
                        <xs:attribute name="sku" type="xs:unsignedInt" use="required" />
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
            <xs:attribute name="major" type="xs:unsignedByte" use="required" />
            <xs:attribute name="minor" type="xs:unsignedByte" use="required" />
            <xs:attribute name="family" type="xs:string" use="required" />
            <xs:attribute name="branch" type="xs:string" use="required" />
            <xs:attribute name="build" type="xs:string" use="required" />
        </xs:complexType>
    </xs:element>
</xs:schema>

我认为我需要编辑较大的xsd,这样它才能知道另一个xsd模式在哪里,但是我该怎么做呢?目前,当我在VS中打开更大的xsd时,它只有this error

我试着改变

代码语言:javascript
复制
<xs:import namespace="intershop.com/xml/ns/enfinity/6.5/core/impex-dt" />

代码语言:javascript
复制
<xs:import namespace="intershop.com/xml/ns/enfinity/6.5/core/impex-dt" dt:schemaLocation="C:\Users\TommyTam\Downloads\Upload To Exponea\Mulesoft\Item Variant Flow Poll\Item Variant Flow Poll_XML (ADDITIONAL).xsd dt.xsd"/>

但这仍然是不正确的。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-09-16 05:44:07

xs:import元素将包含该名称空间模式的文件的相对或绝对URL作为schemaLocation属性(https://www.w3.org/TR/xmlschema-0/#schemaLocation),因此<xs:import namespace="http://www.intershop.com/xml/ns/enfinity/6.5/core/impex-dt" schemaLocation="dt.xsd"/>可以指向与包含xs:import声明的文件位于同一目录中的名为dt.xsd的本地文件。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69196722

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档