xml - 根架构没有匹配的全局声明的验证错误
问题描述
我知道有很多这些错误的实例,但这些类型的验证错误对我来说没有多大意义
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Artwork">
<xs:complexType>
<xs:sequence>
<xs:element name="title" type="xs:string"/>
<xs:element name="media" type="xs:string"/>
<xs:element name="description" type="xs:string"/>
<xs:element name="created" type="xs:string"/>
<xs:element name="display" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
我尝试切换模式名称,但没有做任何事情。我还需要显示 XML 文件来解决这个问题吗?我在那里拥有的唯一代码是将其链接到相同模式的代码命名空间对我来说似乎很好..这是XML
`
<Schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="artwork.xsd">
<Artworks>
<Artwork>
<Title>Xtreme Air</Title>
<Media>Glass Sculpture</Media>
<Description>An amazing work that uses glass balloon shaps to illustrate a rainbow of balloons circuling a glass earth.</Description>
<Created>April 2010</Created>
<Display>Orlando Museum of Arts</Display>
</Artwork>
</Artworks>
</Schema>
`
解决方案
请尝试以下 XML/XSD 对。您需要xsi:noNamespaceSchemaLocation
使用环境中的 XSD 文件位置更新该值。
XML
<?xml version="1.0"?>
<Artworks xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:///e:/Temp/Artwork.xsd">
<Artwork>
<Title>Xtreme Air</Title>
<Media>Glass Sculpture</Media>
<Description>An amazing work that uses glass balloon shaps to illustrate a rainbow of balloons circuling a glass earth.</Description>
<Created>April 2010</Created>
<Display>Orlando Museum of Arts</Display>
</Artwork>
</Artworks>
XSD
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="Artworks">
<xs:complexType>
<xs:sequence>
<xs:element ref="Artwork"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Artwork">
<xs:complexType>
<xs:sequence>
<xs:element name="Title" type="xs:string"/>
<xs:element name="Media" type="xs:string"/>
<xs:element name="Description" type="xs:string"/>
<xs:element name="Created" type="xs:string"/>
<xs:element name="Display" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
推荐阅读
- python - 找不到 Django 页面
- python - 如何将元组转换为具有浮点和字符串值的列表
- javascript - 无法从渲染内部调用渲染外部的函数(在 reactjs 中)
- .net - 针对多个框架的项目上的“dotnet build”仅构建“netstandard2.0”而不生成 nupkg 文件
- javascript - 仅当承诺处于活动状态时如何显示和隐藏弹出窗口?反应
- bash - 有没有办法在 bash 中分配 bool 变量?
- amazon-web-services - 在私有子网中的 EC2 上安装 Cloudwatch 代理
- perl - 标量上的实验键现在被禁止警告
- scala - 在火花数据框中连接并替换 groupBy 之后的字符串
- networking - 如何在 4.2 中使用 macvlan CNI 插件创建额外的网络附件?