Parsing xml with polish character
- From: "saxenashyam" <saxenashyam (at) indiatimes.com>
- Date: Wed, 08 Feb 2006 16:22:28 +0530
hi Bruno,
Please have a look to my customtaghandler
public void startElement(String s, String s1, String s2, Attributes attributes)
{
setStrMethodName("startElement"); /* NOI18N */
isStackReadyForText = false;
if(getMyTags().containsKey(s2))
{
if("fontier".equals(s2))
{
BaseFont bfComic;
try {
stackThis.push( new StringBuffer() );
isStackReadyForText = true;
} catch (Exception e) {
e.printStackTrace();
}
}
} else
{
Properties properties = new Properties();
if(attributes != null)
{
for(int i = 0; i < attributes.getLength(); i++)
{
String s3 = attributes.getQName(i);
properties.setProperty(s3, attributes.getValue(i));
}
}
handleStartingTags(s2, properties);
}
}
/**
* checks the end element
*
* (at) param s2
* (at) param s1
* (at) param s
*/
public void endElement(String s, String s1, String s2)
{
setStrMethodName("endElement"); /* NOI18N */
isStackReadyForText = false;
if("fontier".equals(s2)){
Object tmp = stackThis.pop();
fontier = tmp.toString();
writeFontier();
}else if(getMyTags().containsKey(s2)) {
XmlPeer xmlpeer = (XmlPeer)getMyTags().get(s2);
handleEndingTags(xmlpeer.getTag());
} else {
handleEndingTags(s2);
}
}
/**
*
*/
private void writeFontier() {
//this line print ? in palace of polish character
System.out.println("--fontier------------ : "+fontier);
try {
BaseFont bfComic = BaseFont.createFont("c://windows/fonts/arial.ttf", "ISO-8859-2",BaseFont.EMBEDDED);
Font font = new Font(bfComic, 10);
Document doc =(Document)getDoclistener();
document.add(new Paragraph(fontier, font));
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* checks the characters
*
* (at) param length
* (at) param start
* (at) param data
*/
public void characters(char[] data,int start,int length){
setStrMethodName("characters"); /* NOI18N */
if( isStackReadyForText == true ) {
((java.lang.StringBuffer)stackThis.peek()).append( data, start, length );
//System.out.println("Tag data " + data);
}else {
//System.out.println("Super processing");
super.characters(data, start, length);
}
}
}
The writeFontier method is main method the name is name is <fontier>
Please check it ,Is it correct way to it ?
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
iText-questions mailing list
iText-questions (at) lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions