我有一个xml文件,它的dt:dt是我以前从未见过的:
<?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时,它创建了两个文件:
<?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>和
<?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
我试着改变
<xs:import namespace="intershop.com/xml/ns/enfinity/6.5/core/impex-dt" />至
<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"/>但这仍然是不正确的。
发布于 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的本地文件。
https://stackoverflow.com/questions/69196722
复制相似问题