Mahesh Mamani

Ranch Hand
+ Follow
since Jun 25, 2001
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 Mahesh Mamani

Hi Ulf Dittmer,

Thanks a lot for your help and suggestion provided. Could resolve using the StringBuffer in the characters function.

Thanks again.

Mahesh
Below is the sample code which is being referred to...Actual code is based on this code itself....

We did a System.out.println in the characters function and there itself it prints out partial characters...

Hope this info is enough

Thanks again,

Mahesh

a) Create a Sax Parser and parse the xml

private void parseDocument() {

//get a factory
SAXParserFactory spf = SAXParserFactory.newInstance();
try {

//get a new instance of parser
SAXParser sp = spf.newSAXParser();

//parse the file and also register this class for call backs
sp.parse("employees.xml", this);

}catch(SAXException se) {
se.printStackTrace();
}catch(ParserConfigurationException pce) {
pce.printStackTrace();
}catch (IOException ie) {
ie.printStackTrace();
}
}




b) In the event handlers create the Employee object and call the corresponding setter methods.


//Event Handlers
public void startElement(String uri, String localName, String qName,
Attributes attributes) throws SAXException {
//reset
tempVal = "";
if(qName.equalsIgnoreCase("Employee")) {
//create a new instance of employee
tempEmp = new Employee();
tempEmp.setType(attributes.getValue("type"));
}
}


public void characters(char[] ch, int start, int length) throws SAXException {
tempVal = new String(ch,start,length);
}

public void endElement(String uri, String localName,
String qName) throws SAXException {

if(qName.equalsIgnoreCase("Employee")) {
//add it to the list
myEmpls.add(tempEmp);

}else if (qName.equalsIgnoreCase("Name")) {
tempEmp.setName(tempVal);
}else if (qName.equalsIgnoreCase("Id")) {
tempEmp.setId(Integer.parseInt(tempVal));
}else if (qName.equalsIgnoreCase("Age")) {
tempEmp.setAge(Integer.parseInt(tempVal));
}

}

c) Iterating and printing.


private void printData(){

System.out.println("No of Employees '" + myEmpls.size() + "'.");

Iterator it = myEmpls.iterator();
while(it.hasNext()) {
System.out.println(it.next().toString());
}
}



Employee.xml
<?xml version="1.0" encoding="UTF-8"?>
<Personnel>
<Employee type="permanent">
<Name>Seagull</Name>
<Id>3674</Id>
<Age>34</Age>
</Employee>
<Employee type="contract">
<Name>Robin</Name>
<Id>3675</Id>
<Age>25</Age>
</Employee>
<Employee type="permanent">
<Name>Crow</Name>
<Id>3676</Id>
<Age>28</Age>
</Employee>
</Personnel>
You mean we need to make changes to the characters function ???

Can you please help...It's very urgent.

Thanks in advance,
Mahesh
I am using JAVA SAX parser to parse a XML file and write the contents to a text file.My program is working fine and contents are retrieved correctly when the XML is small. But when the XML file size is large(around 1.5 mb) few bytes are missing / split in contents randomly.


public void characters(char[] char, int start, int length) throws SAXException {
String str = new String(char, start, length);
}

How can I over come this issue?

Hi,

I need the installation of Linux AS 3.0, can the source of dload be provided?

Else, if any1 can post the exe, it would b highly appreciated.

Thanks,
Mahesh
15 years ago
Hi Eric/Jeanne,

I tried the link option as well as the button option, but just wanted to try out this option also, as we can inform that the Windows feature is not working, no problem with our code.

The easy way out to get out of a problem.

Mahesh
Here is code for the image part in the BODY tag of the HTML:




Can you please suggest now?

Thanks,
Mahesh
Hi All,

I need to a open a window with just the Print button/icon enabled. All the others should be either disabled or not displayed at all. I am currently using the javascript:launchwin() call to open the window.

Thanks in advance,
Mahesh
Hi All,

A new window is displayed from a website(javascript:launchwin()) which contains some text and JPEG image below the text. Am trying to print this window. I use the window.print() option in the onClick prperty of the Print button, as shown in the code below.

The image is not printed in a few attempts, what could be the reason for the same??? Is there any other option for printing the contents of the window.


Thanks in advance,
Mahesh
Hello,
I am trying to access a page on the web-server from the browser, routed through the proxy.
I get the error "Requested operation could not performed by the proxy" sometimes. This error is not frequent and very peculiar, which has been reported by the users.
Could any1 of the Java stalwarts pls help me overcome this error.
Thanks,
Mahesh
17 years ago
Hello Javaranchers,
I have a pipe-separated text file, each row representing separate data. I want to convert this file into a XML file for further processing.
Can u please guide me through the steps?
Solution needed urgently.
Thanks

Mahesh
Hello,
When trying the banking example from the BEA site, in the "Insert Cloudspace Data" section, while executing the banking.ddl statement, get the following err msg :
java.lang.ClassNotFoundException: COM.cloudscape.core.JDBCDriver
Need help
Thanks in advance,
Mahesh
18 years ago
Hi All,
I'm retrieving the systime using the Date class and offsetting it to SGT using SinpleTimeZone. The code works fine in Java 1.1.7 environment but fails on the Java 1.1.3 environ.
SimpleTimeZone stz = new SimpleTimeZone(+8*60*60*1000,"Asia/Singapore");
SimpleTimeZone.setDefault(stz);
formatter = new SimpleDateFormat("ddMMMyyyy hh:mm:ss a");
Date date = new Date();
StringBuffer timeStampBuff = new StringBuffer();
System.out.println(formatter.format(date).toString());
Is this a known bug or something which I have missed out.
Thanks in advance,
Mahesh
18 years ago
Hi,
When using the Calendar class, do take care of this functionality regd. month...
Use this URL for more info

MSM
19 years ago