xml - 在 XSD 中使用冒号验证 XML 元素
问题描述
我尝试针对 XSD 架构验证以下 XML。
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xml:base="mynamespace">
<id>MySet</id>
<title type="text">MySet</title>
<updated>2018-05-14T08:26:35Z</updated>
<author>
<name/>
</author>
<link href="LIST" rel="self" title="LIST"/>
<entry>
<id></id>
<title type="text">MySet(value1='12345',Value2='001')</title>
<updated>2018-05-14T08:26:35Z</updated>
<category term="name.myset" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
<link href="MySet(value1='12345',Value2='001')" rel="self" title=""MySet"/>
<content type="application/xml">
<m:properties xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">
<d:value1></d:value1>
<d:value2></d:value2>
</m:properties>
</content>
</entry>
<link rel="delta" href="MySet?!deltatoken='0050568558461ED895EA10645A3EFAB7_20180514082634'"/>
</feed>
XSD 架构:
<?xml version="1.0" encoding="utf-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:m="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3.org/2005/Atom"
version="1.0" elementFormDefault="qualified"
xml:base="Mynamespace">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/03/xml.xsd"/>
<xsd:element name="feed">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="id"/>
<xsd:element name="title"/>
<xsd:element name="updated"/>
<xsd:element name="author"/>
<xsd:element name="link"/>
<xsd:element name="entry" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="id"/>
<xsd:element name="title"/>
<xsd:element name="updated"/>
<xsd:element name="category"/>
<xsd:element name="link"/>
<xsd:element name="content">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="m:properties" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Value1" minOccurs="0">
<xsd:annotation>
<xsd:documentation>Value1</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="12"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="Value2" minOccurs="0">
<xsd:annotation>
<xsd:documentation>Value2</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="12"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="type" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
<xsd:attribute ref="xml:base"/>
</xsd:complexType>
</xsd:element>
</xsd:schema>
问题是:我有名为“m:properties”和“d:value1”的元素。但这不是 xsd 中的有效 NCName。所以我的 xsd 验证失败。
有人知道如何用冒号验证名称吗?我无法更改 XML 内容。我只能更改 xsd 验证文件。
问候
比约恩
解决方案
推荐阅读
- haskell - 如何通过 Haskell Stack 包管理器使用 Hackage 和 Stackage 的清华镜像
- python - pyparsing:无法从 ParseResults 对象获取结果
- xml - 查询以获取嵌入在 XML 文件文本中的单词的排名
- asp.net-core - .Net Core 2.2,Ioc容器——构建对象后设置属性
- java - 如何使用 Spring Boot 在 Flowable 中启动事件后返回响应
- node.js - 通过容器 Web 应用程序或生产中的普通 Web 应用程序在 azure 中运行 NodeJS 应用程序
- docker - 在 docker 容器中运行带有音频的 pygame
- haskell - 实例头中的重复 tyvar:绑定还是引用?
- jquery - 用于区分单个和动态 id 输入类型的 jquery 选择器?
- c# - 该按钮无法在更新面板中第二次单击