1
Xib的新手。我使用XQIB(「瀏覽器中的XQuery」,即用JavaScript實現的Zorba)來處理客戶端。通過XQIB修改XQuery中已更新的DOM
在下面的測試文檔中,如果我點擊第一個按鈕「添加段落」,然後是第二個按鈕「使某些段落變粗體」,則按預期工作。但是,如果我單擊「添加段落」兩次(不管是否單擊中間的第二個按鈕),第二個按鈕將停止工作。
這可能是XQIB中的錯誤還是XQuery的行爲與我預期的不同?
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>XQIB Test</title>
<meta charset="UTF-8"/>
<script type="text/javascript" src="mxqueryjs/mxqueryjs.nocache.js"></script>
<script type="application/xquery">
declare default element namespace "http://www.w3.org/1999/xhtml";
declare namespace hresume="http://microformats.org/profile/hresume";
declare namespace hcard="http://microformats.org/profile/hcard";
declare updating function local:addparas($loc, $evtObj) {
insert node <p>test1</p>
as last into b:dom()//body,
insert node <p>test2</p>
as last into b:dom()//body
};
b:addEventListener(b:dom()//input[@value='Add paragraphs'], "onclick", xs:QName("local:addparas"))
</script>
<script type="application/xquery">
declare updating function local:boldparas($loc, $evtObj) {
replace node b:dom()//p[.='test1'] with <p><b>test1</b></p>
};
b:addEventListener(b:dom()//input[@value='Make some parapgraphs bold'], "onclick", xs:QName("local:boldparas"))
</script>
</head>
<body>
<h1>Insert example</h1>
<input type="button" value="Add paragraphs" />
<input type="button" value="Make some parapgraphs bold" />
<p>Hey</p>
</body>
</html>