在XML中将属性类型声明为实体时的验证错误

时间:2017-12-24 15:50:28

标签: xml xsd dtd

这是我的DTD文件。

?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XML Spy v3.0.7 NT (http://www.xmlspy.com) by Manukyan (YSU) -->
<!ENTITY xxx "ccc">
<!ENTITY yyy "ddd">
<!ELEMENT book (author+, title, publisher)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT publisher (#PCDATA)>
<!ATTLIST title
    aaa ENTITY  #IMPLIED
>

这是相应的DSD文件。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book SYSTEM "C:\Users\PC\Desktop\XML\XMLDB\XML\BOOK.DTD">
<book>
    <author>asd</author>
    <title aaa="xxx"/>
    <publisher/>
</book>

我得到了一个验证错误。 属性'aaa'的值部分'xxx'必须是未解析实体的名称。

1 个答案:

答案 0 :(得分:2)

作为@Daniel Haley explains in his answer对类似的问题,如果你为private int LIMIT = 10; 添加实体声明和符号(NDATA)声明,那么XML现在有效:

mRestaurantsRecycler.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);

            final int mLastVisibleItemPosition = mManager.findLastVisibleItemPosition();

            if ( mLastVisibleItemPosition == (LIMIT-1)) {
                LIMIT = LIMIT*2;
                showSpotDialog();

                // save RecyclerView state
                mBundleRecyclerViewState = new Bundle();
                Parcelable listState = mRestaurantsRecycler.getLayoutManager().onSaveInstanceState();
                mBundleRecyclerViewState.putParcelable(KEY_RECYCLER_STATE, listState);

                loadMore(query);
                new Handler().postDelayed(new Runnable() {

                    @Override
                    public void run() {

                        // restore RecyclerView state
                        if (mBundleRecyclerViewState != null) {
                            Parcelable listState = mBundleRecyclerViewState.getParcelable(KEY_RECYCLER_STATE);
                            mRestaurantsRecycler.getLayoutManager().onRestoreInstanceState(listState);
                        }

                        hideSpotDialog();
                    }

                }, 500);

            }
        }
    });