you can find the above xml there is no CountryCode in the second record and 4th records. if that CountryCode is not present then i need to skip the total Customer tag. so we were using the sax parcing in our application. can you please let me know... how to handle this code in SAX Parcing.
Please find the below code which i have used..from the parcing point of view it is working very find..
/** * Atlas2CustomerBatch ? This Class used to run the Batch to update the * Customer Data in the Database Table Customer. * * @date 21/01/2009 * @revision 001 * */ public class Atlas2CustomerBatch extends DefaultHandler {
private Set accounts; // set of accounts for a single customer
public static void main(String args[]) throws Exception { ResourceBundle customerResource = ResourceBundle .getBundle("props.interfacecommon"); String cftFolderName = customerResource .getString("customer.batch.cftfolder"); String processedFolderName = customerResource .getString("customer.batch.processedfolder"); File cftcustomerFolder = new File(cftFolderName); // Create a properties collection Properties props = new Properties(); props.put(Context.INITIAL_CONTEXT_FACTORY, IBatchConstants .INITIAL_CONTEXT_FACTORY); props.put(Context.PROVIDER_URL, customerResource .getString("rmi.remoteserver.uri")); logger.debug("[Atlas2CustomerBatch][main]"+customerResource .getString("rmi.remoteserver.uri")); // Cretae a new Context Object Context ctx = new InitialContext(props); // look for the EJB using the Context Object obj = (Object) ctx .lookup(customerResource .getString("rmi.ejb.facade.lookup")); EjbFacadeHome dataHome = (EjbFacadeHome) PortableRemoteObject.narrow( obj, EjbFacadeHome.class); // Create a EJB Facade ejbFacade = dataHome.create();
if (cftcustomerFolder.exists() && cftcustomerFolder.isDirectory()) { File[] cftFiles = cftcustomerFolder.listFiles(); XMLReader xmlReader = XMLReaderFactory.createXMLReader(); Atlas2CustomerBatch handler = new Atlas2CustomerBatch(); xmlReader.setContentHandler(handler); xmlReader.setErrorHandler(handler);
for (int i = 0; i < cftFiles.length; i++) { FileReader customerXmlFile = new FileReader(cftFiles[i]); xmlReader.parse(new InputSource(customerXmlFile)); cftFiles[i].renameTo(new File(processedFolderName + "/" + cftFiles[i].getName())); } }
}
public Atlas2CustomerBatch() { super(); }
/** * This method executes on the start of the document. on start of the * document reset the table. * * @date 23/12/2008 */ public void startDocument() {
customers = new HashSet();
}
/** * endDocument-XMLParser Event handler This method executes on the end of * the document. on end of the document set the customer table. * * */ public void endDocument() {
// Truncate the Customer Table try { event = new HashMap();
/** * startElement-XMLParser Event handler This method executes on the start of * the elements. on start of the each element update the element in the * customer bean * * @param uri * @param name * @param qName * @param atts * */
public void startElement(String uri, String name, String qName, Attributes atts) { if ("".equals(uri)) { if (qName.equals(IBatchConstants.ATLAS2_CUSTOMER_QNAME_CUSTOMER)) { // Create a new Customer bean here customer = new Customer(); accounts = new HashSet(); } // intialise the stringValue stringValue = "";
} }
/** * endElement-XMLParser Event handler This method executes on the end of the * elements. on end of the each element update the element in the customer * bean * * @param uri * @param name * @param qName * */
MO mo = null; if ("".equals(uri)) { if (qName.equals(IBatchConstants.ATLAS2_CUSTOMER_QNAME_CUSTOMERNAME)) { System.err.println("Customer Name:"+stringValue); customer.setCustomerName(stringValue); } if (qName.equals(IBatchConstants.ATLAS2_CUSTOMER_QNAME_ID)) { customer.setCustomerId(stringValue); }
if (qName.equals(IBatchConstants.ATLAS2_CUSTOMER_QNAME_ACC_NMBR)) { customerAct = new CustomerAccount(); customerAct.setAccountNumber(stringValue); accounts.add(customerAct); }
if (qName.equals(IBatchConstants.ATLAS2_CUSTOMER_QNAME_ACC_NUMBERS)) { // Add the Accounts set to customer if (accounts != null) { customer.setAccounts(accounts); } }
customer.setMiddleOffice(mo.getId()); customers.add(customer); }else{ logger.error("Mo not found for Country or branch in Database."); }
}else{ logger.error("Country or branch not available in Database."); }
}
if (qName.equals(IBatchConstants.ATLAS2_CUSTOMER_QNAME_CUSTOMERS)) { // end of list of customer }
}
}
/** * * This method reads the value of XML elements.called by XML sex parser * * @param chArray - * array of characters * @param start * @param length * */ public void characters(char chArray[], int start, int length) {
Problem facing in SAX Parsing - XML Problemfacing in SAX Parsing I have facing the issue in SAXParsing... tag.
so we were using the sax parcing in our application. can you please let me know... how to handle this code in SAX Parcing.
Hi Friend,
First
Problem facing in SAX Parsing - XML Problemfacing in SAX Parsing I have facing the issue in SAXParsing... then i need to skip the total Customer tag.
so we were using the sax parcing in our application. can you please let me know... how to handle this code in SAX
Truncating issue while parsing XML with SAX Parser.
Truncating issue while parsing XML with SAX Parser. I am Parsing one xml file and after parsing I have to enter the data into the database using hibernate. The problem is while parsing some elements, its not getting the complete
parsing xml using sax parsing xml using sax how to get values if the root elements are same and their attributes are different
XML Parsing Using Sax Parser in J2ME for serverside
XML Parsing Using Sax Parser in J2ME for serverside Hai team,
i have doubt in Parsing using sax parser in serverside plz help me for xml parsing in j2me using sax parser on server side
thanks in advance...
regards
Selva
XML Parsing Using Sax Parser in J2ME
XML Parsing Using Sax Parser in J2ME Hai team,
I hope you, You should help me, I have trouble in Xml parsing...
I have decoded value, what... to do xml parsing help me for that...
Regards
Alagu
Facing - Ajax Facing Hello All, i m using ajax in my application i m fetching data from db using ajax method and returning response in xml format.
But when... the problem.
once check u r xml response format.
xml response should be like
parsing XML file to get java object - XML parsing XML file to get java object Hello,
I'm facing a problem in parsing XML file to get the java object.
I've tried to retrieve data from XML file using SAX parser.
my XML file structure is the following
parsing word xml file using SAX parser - XML parsing word xml file using SAX parser i am parsing word 2003's XML file using SAX.here my question is,i want to write some tag elements which are between in other tag to a file.
For ex
facing problem plz help me out - Framework Facingproblem plz help me out hi i am new to servlet i deployed... the web.xml file too parallel to the classes folder now i am facing this problem.plz tell me what to do... error:The requested resource (Servlet servlet
Parsing repeatitive xml elements using SAX Parser - XML Parsing repeatitive xml elements using SAX Parser Hi,
I'm using SAX Parser to read an XML file.
My XML file contains repeatitive tags. I'm... SAX parser.
Thanks.
Thanks. Hi Shailendra,
Use the following
XML parsing using Java - XML
" RenewalRate1="0.03100".
I'm facingproblem switching between tables. Like...XML parsing using Java I'm trying to parse a big XML file in JAVA.
The goal is like i will take console input from user until "Coverage
Java XML Parsing Using SAX
Java XML Parsing Using SAX
To Parse XML document using SAX parser method you.... At first Create the SAX Parser as
// getting SAXParserFactory instance... = saxParserFactory.newSAXParser();
// Parsing XML Document by calling parse method
XML parsing to Mysql database
XML parsing to Mysql database Can someone please post the code for parsing an XML file into Mysql database using SAX
Facing Problem with submit and cancel button in same page - Struts FacingProblem with submit and cancel button in same page Hi,
can u please help me out.I have placed submit and cancel button in the jsp page but i am unable to know how to write the form and action classes Hi
facing problem while retrive value from Post textarea facingproblem while retrive value from Post textarea Hi this is subha. I face a small problem while retriving value of the textbox in the java script.I use struts framework and this is my code for post textarea.
<tr>
The Simple API for XML (SAX) APIs
The Simple API for XML (SAX) APIs
The SAX Packages: The SAX parser is defined in the following...
Defines the SAX interfaces. The name
"org.xml" is the package
problems in parsing the xml with the special characters
problems in parsing the xml with the special characters Hi,
I have a problem, in while parsing the xml with special characters apstrophe('). I am getting the exception
Caused by: javax.xml.transform.TransformerException
Java SAX Examples
and column number) the
generated events while parsing a XML file using SAX APIs...
Java SAX Examples
 ... From the XML File
Here you will learn to
retrieve data from XML file using SAX
sax parser for xml sax parser for xml sax parser code that works with any XML i.e independent of any XML to extract data from XML
XML Parsing Error: mismatched tag. Expected: </br>. - JSP-Servlet
XML Parsing Error: mismatched tag. Expected: . i had an error:"XML Parsing Error: mismatched tag. Expected: ." when uploading and writing them... this problem.. Hi friend,
plz specify in detail your problem
The Simple API for XML (SAX) APIs
The Simple API for XML (SAX) APIs
The SAX Packages: The SAX parser is defined in the following...;
Package
Description
org.xml.sax
Defines the SAX
Handling Errors While Parsing an XML File
Handling Errors While Parsing an XML File
 ... parsing an XML document. JAXP (Java
API for XML Processing) is an interface which provides parsing of xml documents.
Here the Document BuilderFactory is used
Problem with cookies Problem with cookies Hello All,
i need jsp code for RememberMe module of login.
i am facingproblem with cookies. so please if any one could guide me please help and provide mme the exact code.
Please visit
SAX Parser SAX Parser
The Simple API for XML (SAX) is a serial
access parser API for XML. It is used... executes, the SAX parser recognizes and
responds to each XML structure taking
connectivity problem
connectivity problem i am facing error in Class.for name statement please help me correct it
the error is ""java.lang.ClassNotFoundException... connectivity still i am facing this error*
================================oracle
Locating the Notified Events
) the generated events while parsing a XML file using SAX
APIs.
Description of program:
This program takes a XML file at the console.
Before parsing... a content event handler. The parser
starts parsing a XML document, as soon as 
problem in programming - JSP-Servlet problem in programming Hi!
I am new with jsp. I am facing a problem in programming to calculate the time interval between login time and logout time of user
SAX Parser for huge XML file SAX Parser for huge XML file Hi....
if the XML file is small and repetitive then this will have meaning..
import javax.xml.parsers.... using sax parser... i wanna use direct file path... not by defining each and every
problem in swing-awt problem in swing-awt I am doing project in core java and i am facing one problem.
I have to add command prompt(terminal) to the fream at bottom but not getting the solution.
So please help me.
thanks and regards,
Aakash
Multiplication problem - Java Beginners
Multiplication problem I am facing a peculiar problem in java regarding a multiplication. Please see below:
19300 * 0.001 = 19.3
19400 * 0.001 = 19.400000000000002 (why is this ??)
19500 * 0.001 = 19.5
Can anybody help
struts- login problem - Struts
struts- login problem Hi all, I am a java developer, I am facing problems with the login application. The application's login page contains fields like username, password and a login button. With this functionality only
parsing xml with jquery parsing xml with jquery Please explain how to parse a xml file into jquery.
Thanks
Problem with Hibernate or 11g Problem with Hibernate or 11g Hi
I am using Hibernate and 11g in my project.
The problem I am facing is I am executing a query from java class... on Created date column by using hibernate query language.
The Problem is every
Parsing string in objective c Parsing string in objective c Hi, How can i parse a string in Objective c??
Thanks.
Parsing string in objective c
This example will also help you to separate the strings separated by one component
Problem in integration struts+ spring - Framework Problem in integration struts+ spring Problem in integration struts+ spring hi, i am facingproblem in integration struts+ spring. I am also using jstl tag. web.xml Test action org.apache.struts.action.ActionServlet config /WEB
Parsing date in Java Parsing date in Java How can i parse the date in Java in a simple format..?
SimpleDateFormat parserSDF=new SimpleDateFormat("EEE MMM d HH:mm:ss zzz yyyy
Java XML Parsing Using DOM
Java XML Parsing Using SAX
To Parse XML document using SAX parser method you.... At first Create the SAX Parser as
// getting SAXParserFactory instance... = saxParserFactory.newSAXParser();
// Parsing XML Document by calling parse method
Parsing into date object Parsing into date object Here is my code:
String de = (String) session.getAttribute("licvalid");
DateFormat df = new SimpleDateFormat("yyyy/MM/dd.... But, it is showing error at the line where i performed parsing operation. Please help me