Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Currently my Xquery module is running in DataBase 1, I want to fetch the file fr

ID: 3919526 • Letter: C

Question

Currently my Xquery module is running in DataBase 1, I want to fetch the file from books.xml from DataBase 2 and the DataBase doesn't have any http/web/dav/xdbc server. And the DataBase 2 exists in same cluster. How can I get file from DataBase 2. My Xquery language is MARKLOGIC. Please answer if are very sure about MARKLOGIC.

Currently my books.xml file:
<catalog>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications
with XML.</description>
</book>
<book id="bk102">
<author>Ralls, Kim</author>
<title>Midnight Rain</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-12-16</publish_date>
<description>A former architect battles corporate zombies,
an evil sorceress, and her own childhood to become queen
of the world.</description>
</book>
<book id="bk103">
<author>Corets, Eva</author>
<title>Maeve Ascendant</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-11-17</publish_date>
<description>After the collapse of a nanotechnology
society in England, the young survivors lay the
foundation for a new society.</description>
</book>
<book id="bk104">
<author>Corets, Eva</author>
<title>Oberon's Legacy</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2001-03-10</publish_date>
<description>In post-apocalypse England, the mysterious
agent known only as Oberon helps to create a new life
for the inhabitants of London. Sequel to Maeve
Ascendant.</description>
</book>
<book id="bk105">
<author>Corets, Eva</author>
<title>The Sundered Grail</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2001-09-10</publish_date>
<description>The two daughters of Maeve, half-sisters,
battle one another for control of England. Sequel to
Oberon's Legacy.</description>
</book>
<book id="bk106">
<author>Randall, Cynthia</author>
<title>Lover Birds</title>
<genre>Romance</genre>
<price>4.95</price>
<publish_date>2000-09-02</publish_date>
<description>When Carla meets Paul at an ornithology
conference, tempers fly as feathers get ruffled.</description>
</book>
<book id="bk107">
<author>Thurman, Paula</author>
<title>Splish Splash</title>
<genre>Romance</genre>
<price>4.95</price>
<publish_date>2000-11-02</publish_date>
<description>A deep sea diver finds true love twenty
thousand leagues beneath the sea.</description>
</book>
<book id="bk108">
<author>Knorr, Stefan</author>
<title>Creepy Crawlies</title>
<genre>Horror</genre>
<price>4.95</price>
<publish_date>2000-12-06</publish_date>
<description>An anthology of horror stories about roaches,
centipedes, scorpions and other insects.</description>
</book>
<book id="bk109">
<author>Kress, Peter</author>
<title>Paradox Lost</title>
<genre>Science Fiction</genre>
<price>6.95</price>
<publish_date>2000-11-02</publish_date>
<description>After an inadvertant trip through a Heisenberg
Uncertainty Device, James Salway discovers the problems
of being quantum.</description>
</book>
<book id="bk110">
<author>O'Brien, Tim</author>
<title>Microsoft .NET: The Programming Bible</title>
<genre>Computer</genre>
<price>36.95</price>
<publish_date>2000-12-09</publish_date>
<description>Microsoft's .NET initiative is explored in
detail in this deep programmer's reference.</description>
</book>
<book id="bk111">
<author>O'Brien, Tim</author>
<title>MSXML3: A Comprehensive Guide</title>
<genre>Computer</genre>
<price>36.95</price>
<publish_date>2000-12-01</publish_date>
<description>The Microsoft MSXML3 parser is covered in
detail, with attention to XML DOM interfaces, XSLT processing,
SAX and more.</description>
</book>
<book id="bk112">
<author>Galos, Mike</author>
<title>Visual Studio 4: A Comprehensive Guide</title>
<genre>Computer</genre>
<price>49.95</price>
<publish_date>2001-04-16</publish_date>
<description>Microsoft Visual Studio 28 is explored in depth,
looking at how Visual Basic, Visual C++, C#, and ASP+ are
integrated into a comprehensive development
environment.</description>
</book>
</catalog>

Explanation / Answer

To get the required book data from .xml file into html file use the below script

<script language="JavaScript" type="text/javascript">

function loadXMLDoc(dname)

{

if (window.XMLHttpRequest)

{

xhttp=new XMLHttpRequest();

}

else

{

xhttp=new ActiveXObject("Microsoft.XMLHTTP");

}

xhttp.open("GET",dname,false);

xhttp.send();

return xhttp.responseXML;

}

function searchXML()

{

xmlDoc=loadXMLDoc("books.xml");

x=xmlDoc.getElementsByTagName("book id");

input = document.getElementById("input").value;

size = input.length;

if (input == null || input == "")

{

document.getElementById("results").innerHTML= "Please enter a Book ID!";

return false;

}

for (i=0;i<x.length;i++)

{

startString = book id.substring(0,size);

if (startString.toLowerCase() == input.toLowerCase())

{

author=xmlDoc.getElementsByTagName("author")[i].childNodes[0].nodeValue;

title=xmlDoc.getElementsByTagName("title")[i].childNodes[0].nodeValue;

genre=xmlDoc.getElementsByTagName("genre")[i].childNodes[0].nodeValue;

price=xmlDoc.getElementsByTagName("price")[i].childNodes[0].nodeValue;

publish_date=xmlDoc.getElementsByTagName("publish_date")[i].childNodes[0].nodeValue;

description=xmlDoc.getElementsByTagName("description")[i].childNodes[0].nodeValue;

divText = "<h1>The Book details are:</h1><br /><table border=1><tr><th>author</th><th>title</th><th>genre</th><th>price</th><th>publish_date</th><th>description</th></tr>" + "<tr><td>" + author + "</td><td>" + title + "</td><td>" + genre + "</td><td>" + price + "</td><td>" + publish_date + "</td><td>" + description + "</td></tr>" + "</table>";

break;

}

else

{

divText = "<h2>The Book does not exist.</h2>";

}

}

document.getElementById("results").innerHTML= divText;

}

</script>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote