Koushik Ghosh

Greenhorn
+ Follow
since May 26, 2013
Koushik likes ...
Eclipse IDE Oracle Java
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
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 Koushik Ghosh

Thanks..that helps. I didn't know what were the default processing rules.
However I solved the problem by putting <xsl:template match="text()"/> in the code.
my xml file is the following :


My expected output xml is the following :


My xslt code is as follows :


But the actual output is

My question is why is it getting abc ?
Why is it not working properly?
Ashish, I'll tell you where you instantiated list variable twice.
See this is your code.

Ashish Dutt wrote:So the updated code with kind corrections from Winston and Koushik clarifying it for me is as follows, but like i posted earlier, this code is now throwing NullPointerException at line 41



The first time when you write this

it's actually creating a default global variable.
Next in the constructor when you write
it's again a declaration.
I've just changed it to
10 years ago
This is your code which is working perfectly now. I've just removed one word from your code.

PS: Change the directory as required.
10 years ago
And I think you are getting NullPointerException because you are declaring list twice. just remove one and make corresponding changes. It should work then.
10 years ago
Yes, that is true. Global variables should be avoided if possible. You can avoid using that global variable as well. in that case no need to change the method return type.
10 years ago

Ashish Dutt wrote:So the updated code with kind corrections from Winston and Koushik clarifying it for me is as follows, but like i posted earlier, this code is now throwing NullPointerException at line 41


here you have declared list 2 times. 1st time as a global variable; 2nd time in the constructor.
it should be somewhat like this

10 years ago
Ashish, you have declared list as a global variable right? So here you don't need to return the list. modify the return type as void. When you modify list in the method the global variable (list) is modified. When you access the list from another method you get the modified list.
10 years ago

Winston Gutkowski wrote:

Ashish Dutt wrote:So the updated code with kind corrections from Winston and Koushik clarifying it for me is as follows, but like i posted earlier, this code is now throwing NullPointerException at line 41


Why is 'list' defined as static? I'm not sure if that's the problem, but it's sure as hell NOT a good idea.

Winston



Even if the list is static it wont create any problem.
10 years ago

Ashish Dutt wrote:Dear all,

Before asking this question i have already checked this forum for question similar to this and have concluded that the only method to be able to copy an ArrayList into a String Array is to iterate through the ArrayList and then use the get method but i'm unable to do so?



Just a second here, I missed this one before. you said // Here list is an ArrayList of type <String, Integer> An ArrayList can not have <String, Integer> , it can have only one.

10 years ago
He's trying to tell you to instantiate the arraylist like this :

I'm not quite sure whether this is the root of the exeption, but try it anyway. If problem persist then let us know.
10 years ago
He's trying to tell you to instantiate the arraylist like this :

I'm not quite sure whether this is the root of the exeption, but try it anyway. If problem persist then let us know.
10 years ago
I don't get any exception when I run this code :
10 years ago
IOException can never occur from System.out.println(). But NUmberFormatException can occur in the following case :

I hope this clears your doubt.
Give him a punch in the face....That should do it.
10 years ago