私はxsdとxmlファイルを持っています。検証がオフになっている場合、xml は正常に解析されます。ただし、xsd 検証では、xsd のルート要素が null であると不平を言います。
私の xsd ファイルには複数のグローバル要素があります。したがって、基本的にこれは問題になる可能性があります。xsdから推測すると、XOMはルート要素をnullとして取得します。その上で確認できれば
xsdファイルでルート要素を宣言する方法と、それを行うための最良の方法は何か、xsdでグローバル要素を1つの要素だけに制限することは私にはよく見えません
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://www.popcornmonsters.com/"
xmlns="http://www.popcornmonsters.com/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:element name="address_book" >
<xs:complexType>
<xs:sequence>
<xs:element ref="entry" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="email" type="xs:string"/>
<xs:element name="first_name" type="xs:string"/>
<xs:element name="last_name" type="xs:string"/>
<xs:element name="entry">
<xs:complexType>
<xs:sequence>
<xs:element ref="first_name" minOccurs="0"/>
<xs:element ref="last_name" minOccurs="0"/>
<xs:element ref="email" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<?xml version="1.0" encoding="UTF-8"?>
<address_book xmlns="http://www.popcornmonsters.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.popcornmonsters.com/address_book.xsd">
<entry>
<first_name>Ken</first_name>
<last_name>Cochrane</last_name>
<email>ken@fakeURL.no</email>
</entry>
<entry>
<first_name>Emily</first_name>
<last_name>Cochrane</last_name>
<email>Emily@fakeURL.no</email>
</entry>
</address_book>