Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!

Nikhil Jain

Ranch Hand
+ Follow
since May 15, 2005
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 Nikhil Jain

Does this help?

<?xml version="1.0" encoding="UTF-8"?>
<XML1>
   <CMD>
      <ID>1</ID>
      <LOCATION>Delhi</LOCATION>
      <PIN>112200</PIN>
   </CMD>
   <CMD>
      <ID>2</ID>
      <LOCATION>Bangalore</LOCATION>
      <PIN>xxxxx</PIN>
   </CMD>
   <CMD>
      <ID>3</ID>
      <LOCATION>Delhi</LOCATION>
      <PIN>112200</PIN>
<LINK>
<ID>1</ID>
  </LINK>

   </CMD>
   <CMD>
      <ID>4</ID>
      <LOCATION>Mumbai</LOCATION>
      <PIN>112200</PIN>
   </CMD>
</XML1>

Re-Pasting my target XML snippet to be more clear.
Hello Experts,

I have a XML snippet

<?xml version="1.0" encoding="UTF-8"?>
<XML1>
   <CMD>
      <ID>1</ID>
      <LOCATION>Delhi</LOCATION>
      <PIN>112200</PIN>
   </CMD>
   <CMD>
      <ID>2</ID>
      <LOCATION>Bangalore</LOCATION>
      <PIN>xxxxx</PIN>
   </CMD>
   <CMD>
      <ID>3</ID>
      <LOCATION>Delhi</LOCATION>
      <PIN>112200</PIN>
   </CMD>
   <CMD>
      <ID>4</ID>
      <LOCATION>Mumbai</LOCATION>
      <PIN>112200</PIN>
   </CMD>
</XML1>

I want to add a link node to above CMD tags such that when 2 or more node have location match, I create a link node that has the ID of the matching node. So I want my Target XML to be as below

<?xml version="1.0" encoding="UTF-8"?>
<XML1>
   <CMD>
      <ID>1</ID>
      <LOCATION>Delhi</LOCATION>
      <PIN>112200</PIN>
   </CMD>
   <CMD>
      <ID>2</ID>
      <LOCATION>Bangalore</LOCATION>
      <PIN>xxxxx</PIN>
   </CMD>
   <CMD>
      <ID>3</ID>
      <LOCATION>Delhi</LOCATION>
      <PIN>112200</PIN>
  <LINK>
<ID>1</ID>
  </LINK>
   </CMD>
   <CMD>
      <ID>4</ID>
      <LOCATION>Mumbai</LOCATION>
      <PIN>112200</PIN>
   </CMD>
</XML1>

In my XSLT i have created 2 for-each loops against the same XML.
After first loop, I create first CMD Tag and then in the second loop, if I find a match I add link node to subsequent nodes.

I need to make sure in the first loop that if any nodes has already been processed with link node I need to ignore them. My question is do we have some mechanism in XSLT where my I can check for a variable for ID's that has already been processed, so that I can ignore them in my first loop?

Not sure if my question makes sense.
Apologies for attaching screen shot. Just wanted to convey the configuration on my rest client. Thanks for removing it.

I am trying to do POST operation.
2 years ago
I am trying to perform post.



I still get "Content Not Supported Error". I am able to invoke this from Chrome Client (Attached Screen Shot)

I set the body as Raw & sent the json request.

2 years ago
I tried with application/json, but it replied with error "Not Supported Content Type", i am not even able to invoke this from other rest clients like Chrome rest client, I don't see any option of setthign this mime type.

Can someone explain me, why one would have used custom mime type?

Thanks
2 years ago
Hello Experts,

I am trying to invoke Rest service through Jersey Client, that expect custom mime type or media type "application/vnd.com.oracle.oracloud.datagrid.Service+json". I get the below error


Exception in thread "main" com.sun.jersey.api.client.ClientHandlerException: com.sun.jersey.api.client.ClientHandlerException: A message body writer for Java type, class com.sun.jersey.core.util.MultivaluedMapImpl, and MIME media type, application/vnd.com.oracle.oracloud.datagrid.Service+json, was not found
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:155)
at com.sun.jersey.api.client.Client.handle(Client.java:652)
at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682)
at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74)
at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:570)
at com.oracle.demo.OracleCloudControllerAPIs.OracleCloudAPIs.addCoherenceDataTierCluster(OracleCloudAPIs.java:112)
at com.oracle.demo.OracleCloudControllerAPIs.OracleCloudAPIs.main(OracleCloudAPIs.java:129)
Caused by: com.sun.jersey.api.client.ClientHandlerException: A message body writer for Java type, class com.sun.jersey.core.util.MultivaluedMapImpl, and MIME media type, application/vnd.com.oracle.oracloud.datagrid.Service+json, was not found
at com.sun.jersey.api.client.RequestWriter.writeRequestEntity(RequestWriter.java:288)
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:217)
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:153)
... 6 more



The code which I have is below. The below code works for the rest services which expects JSON or XML as mime type.


I am trying to programatically invoke this REST API

I have never come across custom mime type. The code works for all other mime types. Is there any other configuration which one has to make?
2 years ago
Hello Experts,

I have a requirement in which I have to extract speech in text from an video file. For instance, say we have an video. I have to capture the audio from it, in text, so that I could store some of the words in DB or similar. I am not sure if this is possible, but just wanted to know the options available.

Thanks
4 years ago
I have been reading about Tired Compiliation support which has been added in java 7.

I don't exactly get it why it is used for.

So will this compiler be useful for client applications or only server applications.

Snippet from Java Site

Tiered Compilation

Tiered compilation, introduced in Java SE 7, brings client startup speeds to the server VM. Normally, a server VM uses the interpreter to collect profiling information about methods that is fed into the compiler. In the tiered scheme, in addition to the interpreter, the client compiler is used to generate compiled versions of methods that collect profiling information about themselves. Since the compiled code is substantially faster than the interpreter, the program executes with greater performance during the profiling phase. In many cases, a startup that is even faster than with the client VM can be achieved because the final code produced by the server compiler may be already available during the early stages of application initialization. The tiered scheme can also achieve better peak performance than a regular server VM because the faster profiling phase allows a longer period of profiling, which may yield better optimization.

Both 32 and 64 bit modes are supported, as well as compressed oops (see the next section). Use the -XX:+UseTieredCompilation flag with the java command to enable tiered compilation.

So when will this kind of of compilation will be useful to us?

Thanks
Shashank

4 years ago
Is it possible to compare 2 XMLs and get difference out with the help of XSLT?

For instnace
XML1
<Employees>
<Employee>
<Id>101</Id>
<Name>John</Name>
<Employee>
<Employee>
<Id>102</Id>
<Name>Rambo</Name>
<Employee>
<Employees>


XML2
<Employees>
<Employee>
<Id>101</Id>
<Name>John</Name>
<Employee>
<Employee>
<Id>103</Id>
<Name>Brett</Name>
<Employee>
<Employees>

XMLDiff
<Employees>
<Employee>
<Id>101</Id>
<Name>John</Name>
<Employee>
<Employee>
<Id>102</Id>
<Name>Rambo</Name>
<Employee>
<Employee>
<Id>103</Id>
<Name>Brett</Name>
<Employee>
<Employees>

Any suggestions?

Thanks,


which Data Structure. No DB is to be used.
This was one of the interview question that I faced.

A log file contains the text in the following format
logTime appName loglevel logText
logTime appName loglevel logText
logTime appName loglevel logText
logTime appName loglevel logText
.
.
.
.
n

which is the best suited Data structure for this. Such that we can search logs. For instance log search with condition as logTime or condition as LogTime and appName?
How to keep track of number of servlet hits in load balanced environment. If there was single JVM, this was possible by storing the count in an instance variable.
7 years ago
How should one improve his OO designing skills. I am trying to make an OO design for chess class.

As per my knowledge it should have the following classes

1. Player Interface & 2 generalized classes. It will have color as one of its attributes
2. Piece Interface - It will have generalized classes like Bishop, queen etc. Each class will have a method that return its move rules
3. Board Class
4. ChessManager class.

I am having a horrible time in taking this forward.

Any help towards this will be great.
Couple of links on http://www.coderanch.com/how-to/java/SceaOnlineResources has not been working for a while. Can someone please update the page.

Some of the links that are not wokring

1. Load Balancing Article
2. Comaprision of IOP, RMI & HTTP.