将"fixed"键添加到引用的属性不起作用



1.xsd文件:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://schemas.android.com/apk/res/android">
<xs:attribute name="debuggable" type="xs:string"/>
</xs:schema>

2.xsd文件:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" vc:minVersion="1.1">
<xs:import xmlns:android="http://schemas.android.com/apk/res/android" namespace="http://schemas.android.com/apk/res/android" schemaLocation="1.xsd" />
...
<xs:attribute ref="android:debuggable" use="optional" fixed="false" />
...

当我尝试使用文件2.xsd调用assertValid时,它将无法检测到debuggable设置为true。但是,当我将fixed="false"移动到1.xsd(仍然将文件2加载为模式(时,它会起作用。是因为文件2中的键正在引用文件1中的属性,无法向其添加更多属性吗?无论如何,在不修改文件1的情况下绕过它?

原来lxml有问题。。。我以后会想办法的。我用xmlschema替换了lxml库,没有做任何更改,一切都像一个符咒。

lxml中的assertValid返回true,而xmlschema中的is_valid返回false,这是一个非常奇怪的情况。

如果你遇到它,希望这能帮助别人节省一点时间。

最新更新