jyothsna ananthula

Ranch Hand
+ Follow
since Jun 02, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by jyothsna ananthula

hi.
please anybody help me out. i want to take a input as xml file show this xml file in the form of tree grid.

i am unable to find out in google(not getting clear material and also they have direct functions with no discription). please anybody tell me how to proceed.
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>

Paul Clapham wrote:As for "urgent", please read this: EaseUp.

Let me point out that there are XML documents which can't be expressed as JSON documents. XML is just more complex than JSON is. But having said that, the way I would approach this would be to use the google keywords "xml convert json" and see what turns up.

Or did you already try that? What did you try so far?




yes i tried in google with xml-json and xml file to convert to json.

i developed the following code, in this i am unable to find the jars what ever needed for this application.and could you please suggest me for example org.json.XML is one package so for if use this package methods in class getting error.so i came to know jar is not available.but what type of jar i need to download.for this i came to know to download json-org jar.please let me know how to know jar needed for particular application.

import java.io.*;


import net.sf.json.JSONObject;
import net.sf.json.xml.XMLSerializer;
import org.apache.commons.io.IOUtils;
import net.sf.json.JSON;






class ConvertToJsonObject {

public static void main(String[] args) throws IOException{

InputStream file1 = new FileInputStream(new File("C:\\Documents and Settings\\JA0084604\\Desktop\\NMS\\XO-OpenNMS\\build.xml"));


try {
JSONObject xmlJSONObj=new JSONObject();

xmlJSONObj = XML.toJSONObject(file1);
String jsonPrettyPrintString = xmlJSONObj.toString(PRETTY_PRINT_INDENT_FACTOR);

System.out.println(jsonPrettyPrintString);
} catch (JSONException je) {
System.out.println(je.toString());
}
}}

/* String xml = IOUtils.toString(file1);

JSONObject xmlJSONObj=new JSONObject();

XMLSerializer xmlSerializer = new XMLSerializer();


JSON json= xmlSerializer.read(xml);
System.out.println( json.toString(2) );


}*/

paul please help me in the following program

import java.io.*;


import net.sf.json.JSONObject;
import net.sf.json.xml.XMLSerializer;
import org.apache.commons.io.IOUtils;

import org.json.XML;






class ConvertToJsonObject {

public static void main(String[] args) throws IOException{

InputStream file1 = new FileInputStream(new File("C:\\Documents and Settings\\JA0084604\\Desktop\\NMS\\XO-OpenNMS\\build.xml"));

String xml = IOUtils.toString(file1);
try {
JSONObject xmlJSONObj=new JSONObject();

xmlJSONObj = XML.toJSONObject(xml); // in this line error getting as required net.sf.json.JSONObject found org.json.josn object
String jsonPrettyPrintString = xmlJSONObj.toString(2);

System.out.println(jsonPrettyPrintString);
} catch (JSONException je) {
System.out.println(je.toString());
}
}}


please help me how to resolve


Ravi Kiran Va wrote:Hi ,
I am trying to use JSON in my project i am seeing that JSONObject can be from two packages .




Please tell me what is the difference between them



hi i want to know how to convert xml file to json object

please see the following code

import net.sf.json.JSON;
import net.sf.json.xml.XMLSerializer;

import org.apache.commons.io.IOUtils;
import java.io.*;
import org.json.XML;

import org.apache.commons.io.IOUtils;
import java.io.*;
import org.json.XML;

class ConvertJson {

public static void main(String[] args) throws Exception {
InputStream is = new FileInputStream(new File("C:\\Documents and Settings\\JA0084604\\Desktop\\NMS\\XO-OpenNMS\\build.xml"));
String xml = IOUtils.toString(is);

// XMLSerializer xmlSerializer = new XMLSerializer();
JsonObject jsonObject=new JsonObject();

jsonObject = XML.toJSONObject( xml );
System.out.println( json.toString(2) );
}
}

for this actually i don't have jars org.json.xml.
please let me these code is enough to get json object.
and in program how to find out there is specific jars are needed.
because i am getting error only can't find symbol with following classname.
hi. please any body suggest me how to convert xml file to json object.
any process please urgent

James Sabre wrote:

jyothsna ananthula wrote:

James Sabre wrote:Looks to be a method in your servlet since it is not explicitly associated with an object or a class instance.



hm,but i read that if we want to create a servletContext object we will use directly getServletContext() ex: ServletContext stxt=getServletContext();
but getServletContext() method is available in Servletconfig Interface. so this extractFromRequest() is also same as it is ....?
and can you tell me ServletConfig is a interface and even we are using in servlet class we will write like init(ServletConfig s){}
and in while Calling getServletContext() we are not using any object but we know that its by default called by ServletConfig object.

i didnt get this concept much.



Sorry but I don't see how that relates to extractFromRequest() . To find method extractFromRequest() just look at the source code for your Servlet or maybe a base class from which your Servlet is derived. To understand Servlet concepts go though several of the many Servlet tutorials.




ok thanks.but here this code i got in threadsafe concurency they didnt give any subclass and superclass
12 years ago

James Sabre wrote:Looks to be a method in your servlet since it is not explicitly associated with an object or a class instance.



hm,but i read that if we want to create a servletContext object we will use directly getServletContext() ex: ServletContext stxt=getServletContext();
but getServletContext() method is available in Servletconfig Interface. so this extractFromRequest() is also same as it is ....?
and can you tell me ServletConfig is a interface and even we are using in servlet class we will write like init(ServletConfig s){}
and in while Calling getServletContext() we are not using any object but we know that its by default called by ServletConfig object.

i didnt get this concept much.
12 years ago
Hi,
can any body tell me about the BigInteger i=extractFromRequest(req) method what is the purpose of this method.i am unable to find this method meaning and which method in which package which object will call this method.
12 years ago

g tsuji wrote:You can google for oracle xdk developer's guide. For 9i release 2 (9.2), this is the link:
http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96621.pdf
whereas for 11g release 1 (11.1), this:
http://download.oracle.com/docs/cd/E15523_01/appdev.1111/b28394.pdf
You can too find 10g's.

If you care to read, you will discover that generateXSL() begins to appear from 10g. For 9i version, it is not yet entered into the spec.

Other than that I don't have anything to share on how to read and do. That sounds terribly pretentious.



thanks you so much.

g tsuji wrote:>will get same output for both methods.is it rgt?
Apart from some (unsignificant) ignorable whitespaces related to formatting, they get the same output, an xslt doc.



ok thanks alot for you are support.
and let me know how to use packages (ex: default package java.lang.object)has more methods.To use those methods in application. can you suggest me the way to learn. and also actually i didn't get any proper material(understandable examples) regarding oracle.diff.xmldiff package to apply those methods in application.

please suggest me how to work with packages properly.

g tsuji wrote:>and tell me a.generateXSLDoc(),a.generateXSLFile().
What do you mean by that, telling you?

>what is the difference between two methods. i am getting same output for these two.
Watch carefully the .print() method is used following generateXSLDoc() because generateXSLDoc() return an XMLDocument which is the xslt document (itself an xml document). That is the difference and that is also the detail intended to be shown otherwise I wouldn't bother. They by the full line written output of course the same xslt document that is what I want you to see alternative or looking at the same problem at different angle. It is not meant to be read casually.

If the generateXSL() line does not work for your version, just don't use it and comment it out. You have the other two lines to output the same already. It is probably related to the xdk you're using. That's all. You've to read your manual.



you mean to say that generateXSLDoc() will return xml Document(which includes xsl) and generateXSLFile() will generate the xsl File.
if try to print xml Document will get xsl output.
and will get same output for both methods.is it rgt?

g tsuji wrote:>or else tell me code how to use generateXSL(); and where i will get xsl.

If I can recap what I said and condense it to one line:

Have you looked at System.out? (This line is positioned after a.diff() had been called.) If you had not and said it not working or something, there is no reason I am full of joy and say that's cool. I might or I might not be irritated --- that's all your words that have no concern as far as I'm concerned.

If you're not in a position to have a System.out console to look at, you may persist its output to a file for inspection. At the same time, I can show you more options the class exposed for your convenience.

or any of their variants as long as their constructor accepts.



hi,
thanks i tried what you said

a.generateXSL(new PrintWriter(System.out));
a.generateXSLFile("C:\\Documents and Settings\\JA0084604\\Desktop\\outfile.xsl");
a.generateXSLDoc().print(new FileOutputStream("C:\\Documents and Settings\\JA0084604\\Desktop\\outdoc.xsl"));

but at the line of a.generateXSL(new PrintWriter(System.out));
getting error method as genterateXSL(java.io.printwriter) is cannt find.
i missed any imports for this?
i am not getting
and tell me a.generateXSLDoc(),a.generateXSLFile().
what is the difference between two methods. i am getting same output for these two.




g tsuji wrote:x1 and a are both your notations, not even mine. I don't what you are talking about... a.generateXSL() and x1, can we mix them all up?



Actually what i am saying is x1 is a xml document and a is the object of xmlDiff class
and here what i did is i created x1,x2 XMLs and after that i differentiate with reference a(reference of xmlDiff)
i got a difference between two xmls(x1,x2)

then what my task is i want to use generateXSL(java.io.Writer);

with this method i will get the xsl of difference of two xmls (x1,x2).

please dont get irritate.if you dont understand what i written here.

or else tell me code how to use generateXSL(); and where i will get xsl.

Raj Kamal wrote:
This has nothing to do with XML. You have to give a full path and filename when you create the FileWriter object (out).

Please use CODE tags when posting code otherwise it is so very hard to read.



i tried with path and filename also even same error getting.and please tell me how to use codetags

g tsuji wrote:[0]
>here i am not understanding how to see x1, its a xmlDocument.


[1]
>so i want to know the usage of those methods.how can use it.and for ex: in this package
generateXSL
public void generateXSL(java.io.Writer out)
throws java.io.IOException,
java.lang.NullPointerException


You have also member functions which may be more useful in different settings, such as generateXSLDoc() or generateXSLFile()...

These are just for illustration of how to get XMLDocument or XMLDiff perform. I don't see any other way than studying their documentation. Speculation and guessing do not get you far.



here x1 is xmldocument and whatever you sent printwriter.i checked i got error as method not found a.generateXSL(pw);