【发布时间】:2021-09-07 04:29:49
【问题描述】:
概述
我从 Enterprise Architecture Software 下载了一个 XML 模式。我想做的一件事是开始开发符合这些以 XML 模式呈现的模型的 XML 文件。
问题
在 XML 文件中,我链接到架构。然而,我得到一个错误cannot find the declaration of element。架构中的根元素是<xs:complexType name="Product">,但我确实注意到它有一个名为注解的兄弟元素,但它没有被命名。我仍然尝试将此注释用作根,但遇到了同样的问题。
我也尝试使用“产品类型”作为根元素作为模式中类型元素的第一个标记,但也遇到了同样的错误。好像知道的元素可以作为根。
问题
我在这里做错了什么?我无法更改架构,因为这是软件的输出。
架构
<?xml version="1.0" encoding="utf-8"?>
<xs:schema targetNamespace="http://www.w3schools.com/product"
elementFormDefault="qualified"
xmlns="http://www.w3schools.com/product product.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:annotation>
<xs:documentation>The Product defines the product(s) which are in focus for the Integrated Product Support (IPS) program. Once defined, a Product will then come in one or many Product variants. </xs:documentation>
</xs:annotation>
<xs:complexType name="Product">
<xs:annotation>
<xs:documentation>Product is <<class>> that represents a family of items which share the same underlying design purpose.</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="productIdentifier" minOccurs="1" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation>productIdentifier is an identifier that establishes a unique designator for a Product and to differentiate it from other instances of Product.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="productName" minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation>productName is a name by which the Product is known and can be easily referenced.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="ProductVariant" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ProductVariant">
<xs:annotation>
<xs:documentation>A productVariant is a <<class>> that defines a member of a Product family which is configured for a specific purpose and is made available to the market.</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="productVariantIdentifier" minOccurs="1" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation>productVariantIdentifier is an identifier that establishes a unique designator for a ProductVariant and to differentiate it from other instances of ProductVariant. </xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="productVariantName" minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation>productVariantName is a name by which the ProductVariant is known and can be easily referenced.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>
XML
<?xml version="1.0" encoding="utf-8"?>
<Product xmlns="http://www.w3schools.com/product"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3schools.com/product product.xsd">
</Product>
注意
xml 和 .xsd 文件都在同一个文件夹中。
【问题讨论】:
-
你能发布XSDSchema的图表吗?您只声明了两种复杂类型,但没有声明元素。所以这个 xsd 没有有效的 xml。
-
您究竟从哪里下载了该架构?
标签: xml xsd schema enterprise-architect