XML IDREF 仅用作属性而不用作元素

XML IDREF works only as an attribute but not as an element

我有以下 XML:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="simple_model.xsd">
    <cars>
        <passengers>
            <person idref="ud9e69b75-1604-4a85-9747-5ec530b3641b"/>
        </passengers>
    </cars>
    <persons>
        <person myid="ud9e69b75-1604-4a85-9747-5ec530b3641b">
            <name>Paul</name>
        </person>
    </persons>
</root>

具有相应的模式:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:element name="root" type="root"/>

  <xs:complexType name="root">
    <xs:sequence>
      <xs:element name="cars" type="car" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="persons" minOccurs="0">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="person" type="person" minOccurs="0" maxOccurs="unbounded"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="car">
    <xs:sequence>
      <xs:element name="passengers" minOccurs="0">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="person" type="referencePerson" minOccurs="0" maxOccurs="unbounded"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="referencePerson">
    <xs:sequence/>
    <xs:attribute name="idref" type="xs:IDREF"/>
  </xs:complexType>

  <xs:complexType name="person">
    <xs:sequence>
      <xs:element name="name" type="xs:string" minOccurs="0"/>
    </xs:sequence>
    <xs:attribute name="myid" type="xs:ID"/>
  </xs:complexType>
</xs:schema>

当我现在打电话给 idref("ud9e69b75-1604-4a85-9747-5ec530b3641b")/.. 时 returns 我: <person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" idref="ud9e69b75-1604-4a85-9747-5ec530b3641b"/>

到目前为止一切顺利。但是当我将 idref 从属性更改为元素时。像这样:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="simple_model.xsd">
    <cars>
        <passengers>
            <person>u74835c8c-e793-4fca-a370-27ff6f3f06d7</person>
        </passengers>
    </cars>
    <persons>
        <person myid="u74835c8c-e793-4fca-a370-27ff6f3f06d7">
            <name>Paul</name>
        </person>
    </persons>
</root>

相应的架构更改为:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:element name="root" type="root"/>

  <xs:complexType name="root">
    <xs:sequence>
      <xs:element name="cars" type="car" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="persons" minOccurs="0">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="person" type="person" minOccurs="0" maxOccurs="unbounded"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="car">
    <xs:sequence>
      <xs:element name="passengers" minOccurs="0">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="person" type="xs:IDREF" minOccurs="0" maxOccurs="unbounded"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="person">
    <xs:sequence>
      <xs:element name="name" type="xs:string" minOccurs="0"/>
    </xs:sequence>
    <xs:attribute name="myid" type="xs:ID"/>
  </xs:complexType>
</xs:schema>

然后调用idref("u74835c8c-e793-4fca-a370-27ff6f3f06d7")returns什么都没有。我用 BaseX 和 XML 作者试过了,但都没有结果。 你知道我错过了什么吗?

它在 Saxon 中按预期工作,所以我认为这要么是特定于产品的问题,要么与您 运行 查询的方式有关。