为什么我会收到此错误“未绑定的 XML 命名空间前缀"? [英] Why am I getting this error "Unbound XML namespace prefix"

查看:61
本文介绍了为什么我会收到此错误“未绑定的 XML 命名空间前缀"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我几乎完成了一个简单的 android 应用程序,它似乎运行良好.但是,当我运行代码分析时,我收到了大约 100 个关于 xml 文件的警告我收到的错误是未绑定 XML 命名空间前缀"和未绑定命名空间"

I am almost finished writing a simple android application which seems to be working well. However, when I run a code analysis I am getting around 100 warnings regarding xml files The error I am recieving is 'Unbound XML namespace prefix' and 'Namespace is not bound'

这是我的一个 xml 文件中的一个小示例:`

here is a small sample from one of my xml files:`

<style name="dialog_title_style" parent="android:Widget.TextView">
    <item name="android:background">@android:color/black</item>
    <item name="android:padding">10dp</item>
</style>

<style name="MySpinnerLook"
       parent="@android:style/TextAppearance.Widget.TextView.SpinnerItem">
    <item name="android:textSize">40dp</item>
    <item name="android:textColor">#FFFFFF</item>
    <item name="android:text">Currency</item>

</style>

`

我在谷歌上搜索了这个问题,但似乎找不到解释.我不确定这个问题是否太初级以至于解决方案应该是常识,或者这是否是一个晦涩的不常见问题

I have googled this problem but I cant seem to find an explanation. I amn't sure whether this problem is just so elementary that the solution should be common sense or if this is an obscure uncommon problem

推荐答案

您尚未命名生成未绑定 XML 命名空间前缀"警告的包或程序,因此很难查明问题.然而,一般来说,警告表明程序正在抱怨看起来像命名空间前缀的 XML 名称,尤其是在属性值中.例如android:Widget.TextView"或android:background".这只是过度热情(如果实际上没有损坏)代码检查器的烦恼.

You haven't named the package or program that generated the "Unbound XML namespace prefix" warning, so it's difficult to pinpoint the problem. In general terms, however, the warning suggests that the program is complaining about what look like namespace prefixed XML names, perhaps especially in attribute values. Such as "android:Widget.TextView" or "android:background". This is simply an annoyance from an overenthusiastic (if not actually broken) code checker.

你的例子本身并没有错,但这里的过度热情确实有一些基础.有些应用程序中的qnames",正如它们所说的那样,可以出现在属性值或文本内容中.(在模式规范中很常见的一个例子:'xsi:type="xs:string"'.)在这里,如果 qname 是意图,警告将是正确的",但检查器有没办法知道.

There is nothing wrong with your example per se, but the overenthusiasm here does have some basis. There are applications where "qnames", as they are called, can appear in attribute values or text content. (An example quite often found in schema specs: 'xsi:type="xs:string"'.) Here, the warning would have been "correct" if a qname were intended, but the checker has no means of knowing that.

您最好调查检查器是否提供了禁止此特定检查"的选项.

You're best off investigating whether the checker offers an option to suppress this particular "check".

这篇关于为什么我会收到此错误“未绑定的 XML 命名空间前缀"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆