1
我有這個現有的XSD,它試圖限制一個值到一個URL,但它不工作。該ID爲空白,文檔仍然有效。它還驗證我何時輸入任何文本。限制元素到URL
<xsd:schema xmlns:atom="http://www.w3.org/2005/Atom" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3.org/2005/Atom" elementFormDefault="qualified" attributeFormDefault="unqualified">
...
<xsd:complexType name="feedType">
<xsd:choice minOccurs="3" maxOccurs="unbounded">
<xsd:element name="id" type="atom:idType" minOccurs="1" maxOccurs="1"/>
...
<xsd:complexType name="idType">
<xsd:annotation>
<xsd:documentation>
The Atom id construct is defined in section 4.2.6 of the format spec.
</xsd:documentation>
</xsd:annotation>
<xsd:simpleContent>
<xsd:extension base="xsd:anyURI">
<xsd:attributeGroup ref="atom:commonAttributes"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
............
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2005/Atom ../XMLschemas/atom/2005/v/0.2/atom.xsd">
<id>https://mydomain.com</id>
請不要在「XSD:」等前加上標題。這就是標籤的用途。 –
你在做什麼驗證工作? –
@John,是的,我不知道這是爲什麼這樣設置的,但無論如何,其他元素的限制都在起作用,它只是有問題的ID。 Petru,我正在使用Altova XMLSpy和Eclipse驗證器。兩者都有相同的結果。 – user994165