aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Input as xml in dojo unable to load Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Input as xml in dojo unable to load" Watch "Input as xml in dojo unable to load" New topic
Author

Input as xml in dojo unable to load

jyothsna ananthula
Ranch Hand

Joined: Jun 02, 2011
Posts: 33
hi
in the following example anything mistake i am unable to load xml url.while running this getting error as lookup fail and unable to load
../WEB-INF/books.xml.please help me out as soon as possible
/

<%--
Document : xmltotreegrid
Created on : Jun 23, 2011, 11:53:07 AM
Author : JA0084604
--%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html dir="ltr">

<head>
<style type="text/css">
body, html { font-family:helvetica,arial,sans-serif; font-size:90%; }
</style>
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dojo/dojo.xd.js"
djConfig="parseOnLoad: true">
</script>
<script>
dojo.require("dojox.data.XmlStore");
dojo.require("dijit.form.Button");
dojo.require("dijit.form.TextBox");
dojo.require("dijit.form.CheckBox");

//This function performs some basic dojo initialization. In this case it connects the button
//onClick to a function which invokes the fetch(). The fetch function queries for all items
//and provides callbacks to use for completion of data retrieval or reporting of errors.
function init3() {
//Function to perform a fetch on the datastore when a button is clicked
function search() {
var queryObj = {};

//Build up the query from the input boxes.
var isbn = isbnBox.getValue();
if (isbn && dojo.trim(isbn) !== "") {
queryObj["isbn"] = isbn;
}

var qNode = dojo.byId("query");
if (qNode) {
qNode.innerHTML = dojo.toJson(queryObj);
}

//Callback to perform an action when the data items are starting to be returned:
function clearOldList(size, request) {
var list = dojo.byId("list3");
if (list) {
while (list.firstChild) {
list.removeChild(list.firstChild);
}
}
}

//Callback for processing a returned list of items.
function gotItems(items, request) {
var list = dojo.byId("list3");
if (list) {
var i;
for (i = 0; i < items.length; i++) {
var item = items[i];
list.appendChild(document.createTextNode("ISBN: " + bookStore.getValue(item, "isbn") + " TITLE:" + bookStore.getValue(item, "title")));
list.appendChild(document.createElement("br"));
}
}
}

//Callback for if the lookup fails.
function fetchFailed(error, request) {
alert("lookup failed.");
alert(error);
}

//Fetch the data.
bookStore.fetch({
query: queryObj,
onBegin: clearOldList,
onComplete: gotItems,
onError: fetchFailed
});

}
//Link the click event of the button to driving the fetch.
dojo.connect(button3, "onClick", search);
}
//Set the init function to run when dojo loading and page parsing has completed.
dojo.addOnLoad(init3);
</script>
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dijit/themes/claro/claro.css"
/>
</head>

<body class=" claro ">
<b>
ISBN:
</b>
<input dojoType="dijit.form.TextBox" jsId="isbnBox" value="*">
</input>
<br>
<br>
<div dojoType="dojox.data.XmlStore" jsId="bookStore" url="../WEB-INF/books.xml">
</div>
<div dojoType="dijit.form.Button" jsId="button3">
Click to search!
</div>
<br>
<br>
<b>
Query used:
</b>
<span id="query">
</span <br>
<br>
<b>
Books located:
</b>
<br>
<span id="list3">
</span>
<!-- NOTE: the following script tag is not intended for usage in real
world!! it is part of the CodeGlass and you should just remove it when
you use the code -->
<script type="text/javascript">
dojo.addOnLoad(function() {
if (document.pub) {
document.pub();
}
});
</script>
</body>

</html>

xml in WEB_INF/books.xml i created as follows
<?xml version="1.0" encoding="UTF-8"?>

<!--
Document : books.xml
Created on : June 23, 2011, 12:12 PM
Author : JA0084604
Description:
Purpose of the document follows.
-->

<?xml version="1.0" encoding="ISO-8859-1"?>
<books>
<book>
<isbn>1</isbn>
<title>Title of 1</title>
<author>Author of 1</author>
</book>
<book>
<isbn>2</isbn>
<title>Title of 2</title>
<author>Author of 2</author>
</book>
<book>
<isbn>3</isbn>
<title>Title of 3</title>
<author>Author of 3</author>
</book>
<book>
<isbn>4</isbn>
<title>Title of 4</title>
<author>Author of 4</author>
</book>
<book>
<isbn>5</isbn>
<title>Title of 5</title>
<author>Author of 5</author>
</book>
<book>
<isbn>6</isbn>
<title>Title of 6</title>
<author>Author of 6</author>
</book>
...
</books>

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Input as xml in dojo unable to load