gpt4 book ai didi

java - IDREF 属性只能有本地 ID 值吗?

转载 作者:行者123 更新时间:2023-11-30 04:30:09 25 4
gpt4 key购买 nike

我有这样的元素

<xsd:element name="Car" type="carType"/>

<xsd:complexType name="carType">
<xsd:complexContent>
<xsd:extension base="basicType">
<xsd:attribute name="motor" type="xsd:IDREF" use="required"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

当电机元件在当前文档中时,它工作正常。

<Car id="car1" motor="motor1"/>
<Motor id="motor1"/>

但是当我想从另一个文件导入电机元素时

<beans:bean:import resource="motors.conf.xml"/>

Intellij Idea 说无效的 id 引用,当我运行程序时出现异常

There is no ID/IDREF binding for IDREF 

可能是我做错了什么?或者可能是 xsd:IDREF 等于 ref local,所以我不能将它与导入一起使用?

最佳答案

我是对的,xsd:IDREF等于 ref local。

关于xsd:IDREF MSDN Creating Valid ID, IDREF...

你可以看到为什么它在这里相等 -

<xsd:element name="ref">
<xsd:annotation>
<xsd:documentation><![CDATA[
Defines a reference to another bean in this factory or an external
factory (parent or included factory).
]]></xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:complexContent>
<xsd:restriction base="xsd:anyType">
<xsd:attribute name="bean" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
The name of the referenced bean.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
**<xsd:attribute name="local" type="xsd:IDREF">**
<xsd:annotation>
<xsd:documentation><![CDATA[
The name of the referenced bean. The value must be a bean ID and thus can
be checked by the XML parser. This is therefore the preferred technique
for referencing beans within the same bean factory XML file.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="parent" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
The name of the referenced bean in a parent factory.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>

是元素bean元素ref的描述。众所周知,我们可以使用 <ref local>仅适用于当前 XML 文档中的元素。

关于java - IDREF 属性只能有本地 ID 值吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14827334/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com