显示此 XSD 的示例 XML?
Show me sample XML for this XSD?
我正在尝试为此模式编写有效的 XML:
<xsd:complexType name="resourceType">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
A resource root within a deployment.
</documentation>
</annotation>
<xsd:all>
<xsd:element name="filter" type="filterType" minOccurs="0">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
A path filter specification for this resource root (optional). By default all paths are accepted.
</documentation>
</annotation>
</xsd:element>
</xsd:all>
<xsd:attribute name="name" type="xsd:string" use="optional">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
The name of this resource root (optional). If not specified, defaults to the value of the path
attribute.
</documentation>
</annotation>
</xsd:attribute>
<xsd:attribute name="path" type="xsd:string" use="required">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
The path of this resource root, relative to the path in which the module.xml file is found.
</documentation>
</annotation>
</xsd:attribute>
</xsd:complexType>
我是 XML 和 XSD 的新手,如果能提供一点帮助,我将不胜感激:根据此 XSD?
有两个问题会阻止任何 XML 对您的 XSD 有效:
- XSD 包含对未定义类型的引用,
filterType
。
- XSD 没有指定根元素。
通过将 filterType
替换为 xsd:string
并添加根元素 r
类型等于 XSD 中的 top-level complexType,然后这个修改 XSD,
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="r" type="resourceType"/>
<xsd:complexType name="resourceType">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
A resource root within a deployment.
</documentation>
</annotation>
<xsd:all>
<xsd:element name="filter" type="xsd:string" minOccurs="0">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
A path filter specification for this resource root
(optional). By default all paths are accepted.
</documentation>
</annotation>
</xsd:element>
</xsd:all>
<xsd:attribute name="name" type="xsd:string" use="optional">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
The name of this resource root (optional). If not specified,
defaults to the value of the path attribute.
</documentation>
</annotation>
</xsd:attribute>
<xsd:attribute name="path" type="xsd:string" use="required">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
The path of this resource root, relative to the path in
which the module.xml file is found.
</documentation>
</annotation>
</xsd:attribute>
</xsd:complexType>
</xsd:schema>
将成功验证以下 XML,例如:
<?xml version="1.0" encoding="UTF-8"?>
<r path="">
<filter/>
</r>
我正在尝试为此模式编写有效的 XML:
<xsd:complexType name="resourceType">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
A resource root within a deployment.
</documentation>
</annotation>
<xsd:all>
<xsd:element name="filter" type="filterType" minOccurs="0">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
A path filter specification for this resource root (optional). By default all paths are accepted.
</documentation>
</annotation>
</xsd:element>
</xsd:all>
<xsd:attribute name="name" type="xsd:string" use="optional">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
The name of this resource root (optional). If not specified, defaults to the value of the path
attribute.
</documentation>
</annotation>
</xsd:attribute>
<xsd:attribute name="path" type="xsd:string" use="required">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
The path of this resource root, relative to the path in which the module.xml file is found.
</documentation>
</annotation>
</xsd:attribute>
</xsd:complexType>
我是 XML 和 XSD 的新手,如果能提供一点帮助,我将不胜感激:根据此 XSD?
有两个问题会阻止任何 XML 对您的 XSD 有效:
- XSD 包含对未定义类型的引用,
filterType
。 - XSD 没有指定根元素。
通过将 filterType
替换为 xsd:string
并添加根元素 r
类型等于 XSD 中的 top-level complexType,然后这个修改 XSD,
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="r" type="resourceType"/>
<xsd:complexType name="resourceType">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
A resource root within a deployment.
</documentation>
</annotation>
<xsd:all>
<xsd:element name="filter" type="xsd:string" minOccurs="0">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
A path filter specification for this resource root
(optional). By default all paths are accepted.
</documentation>
</annotation>
</xsd:element>
</xsd:all>
<xsd:attribute name="name" type="xsd:string" use="optional">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
The name of this resource root (optional). If not specified,
defaults to the value of the path attribute.
</documentation>
</annotation>
</xsd:attribute>
<xsd:attribute name="path" type="xsd:string" use="required">
<annotation xmlns="http://www.w3.org/2001/XMLSchema">
<documentation>
The path of this resource root, relative to the path in
which the module.xml file is found.
</documentation>
</annotation>
</xsd:attribute>
</xsd:complexType>
</xsd:schema>
将成功验证以下 XML,例如:
<?xml version="1.0" encoding="UTF-8"?>
<r path="">
<filter/>
</r>