我有一个 xml 架构
<xs:complexType>
...
<xs:attribute ref="unaryOperator"></xs:attribute>
</xs:complexType>
<xs:attribute name="unaryOperator">
我尝试在我的 xml 文件中使用它
像这样
<inv_constraint unaryOperator="not">
编辑给我这个错误:
描述 资源路径 位置类型
[Xerces] cvc-complex-type.3.2.2:属性“unaryOperator”不允许出现在元素“inv_constraint”中。
@看:http://www.w3.org/TR/xmlschema-1/#cvc-complex-type http://www.w3.org/TR/xmlschema-1/#cvc-complex-typeabc.xml /prova 第 28 行 XML 问题
编辑建议我这样做
<inv_constraint xmlns:ns1="http://abc/abcd" ns1:unaryOperator="not" >
如果我不使用 xml 模式中的 ref 而是复制粘贴属性而不是引用它,那么我的 xml 文件就可以工作,
所以我的问题是如何在没有那个奇怪的标签的情况下使我的 xml 有效并将引用保留在 xml 模式中?
我在这里没有看到任何问题。以下对我来说效果很好:
架构.xsd:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="ct">
<xs:attribute ref="unaryOperator"/>
</xs:complexType>
<xs:attribute name="unaryOperator"/>
<xs:element name="inv_constraint" type="ct"/>
</xs:schema>
文件.xml:
<?xml version="1.0"?>
<inv_constraint unaryOperator="non" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="schema.xsd"></inv_constraint>
我已经在 Xerces、Saxon、XSV 和其他一些验证器上进行了测试。
所以,如果您仍然遇到这个问题:
- 提供完整的示例 - 简化的架构文件和 XML 文件,我们可以在其上重现此问题。
- 你用什么编辑器?
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)