Why am I getting this error “Unbound XML namespace prefix”

孤人 提交于 2019-12-10 14:53:41

问题


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'

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


回答1:


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.

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".




回答2:


I have encountered the same problem with tags textColor and textSize. What helped me was changing android api from version 10 (android 2.3.3) to version 7 (android 2.1), but I can't explain why. Documentation doesn't say that these tags are deprecated in newer versions of android or anything like that. Maybe some bug in api v10? I have no idea.



来源:https://stackoverflow.com/questions/13564149/why-am-i-getting-this-error-unbound-xml-namespace-prefix

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!