File Parsing question
Say I have a fairly big file. Many megs, for example. My file can be formatted kind of the way I want, but it contains data in a key-value pair format, where the key is a long (ordered) and the value is a string of variable length.
So, for example, it could look something like this:
1blabla
2bobob
3gugugu
99910102923tututu
Now, I know I can get the value for a specific key by parsing the lines, reading a long when reading a string. This is fine.
But I'm trying to be somewhat smarter. Since I know my longs are ordered, I'm thinking I can implement a search algorithm that looks in the middle of an interval for the looked value, to eliminate half the remaining options per pass.
I can use randomaccessfile to get to some random point in the file. That's fine. But now, since I can be at any point of the file, I could be within the long, or somewhere within the string. What I'm looking for, and can't seem to figure out, is how to get back to the beginning of the long value, to read it correctly.
Any pointers appreciated!
First reason is I'm trying to build something for unstructured data. Databases are usually good only for structured data. I could put everything in text, I suppose.
Second reason is databases are, in theory, slower than intelligent file-parsing. You have to generate the connection, have the dbms manipulate the data then return the data then have the driver translate it to something your programming language understands. I know, I Know, I'd have to work years to make something as efficient as an existing DB.
Third reason is databases usually require a database engine, so if I wanted to make a standalone application, with, say, a jar file, I could avoid requiring of my userd to install some database application. Yes, there are some embedded database thignies out there.
Fourth reason is curiosity. I want to see if I can do something like this because I've never done it before, and I'm interested in finding out if it's possible or not!
Similar Messages
-
'Import file parsing exception' while importing BIAR file
Hi All,
We use Java WebServices SDK for integrating our product with Business Objects. For installing the reports we use the InstallEntSDKWrapper jar to copy the BIAR file containing the reports on to the BO server. Till now we were using BO XI R2 and everything works fine.
But now we have decided to upgrade to BO 3.0 and the reports install no longer works. Here is the error that we get -
[InstallEntSdkWrapper.main] Connecting to CMS rwc-1950-120:6400 as administrator
[InstallEntSdkWrapper.CmsImportFile] Exception: Import file parsing exception
curred : 'Type info incomplete'
[InstallEntSdkWrapper.main] BIAR File could not be imported
Any idea what might be going wrong here? We are trying to import the same BIAR file that were created with the earlier BO version to the 3.0 version server. Couple of questions that I have is -
1. Do we need to repackage the BIAR with 3.0 before attempting to install it? Are there any issues with trying to install a BIAR which is of older BO version?
2. Do we need to add/modify any library (jar) in the runtime to get rid of the exception?
Thanks for all the help.
Regards
Manas
Edited by: Manas Mandlekar on Dec 23, 2009 1:34 AMLucas,
I have not seen this issue before. We'll investigate and contact you directly for more info. I'll post the resolution back to this forum once available.
Doug -
Tough Parsing question???
Please try to help me with the following parsing question.
I have an exert from the 2000 Tiger/Line Census files that looks
something like this:
0001 A Libby Ln -92.99999+25.87787 -92.87679+26.65543
0002 A Capri Ave -93.32343+23.3332 3 -24.34444+34.22222
0003 A Minster Grove Ln -93.23433+22.2223432 -98.343343+23.34332
0003 A Houston Ave -91.99892+22.323322 -98.434543+33.33233
0004 A I-10 Int -91.23234+32.343232 -97.333233+34.22222
0005 C Trenton Springs Ct. -90.22232+33.222123 -91.234432+23.33221
I want to parse it so I can enter it into an SQL database.
Normally this would be an easy task but, the file is not comma
deliminated. Usaully I could just break it apart at the white space
but as you can see above, some of the street names (the third column)
have whitespace in the text. I have almost declared it impossible
and am about to give up an buy prepackaged/parsable software.
I will feel very small if I have to do that.
Thanks for any help,
Ianpublic class CensusParser
String[] census = { "0001 A Libby Ln -92.99999+25.87787 -92.87679+26.65543",
"0002 A Capri Ave -93.32343+23.3332 3 -24.34444+34.22222",
"0003 A Minster Grove Ln -93.23433+22.2223432 -98.343343+23.34332",
"0003 A Houston Ave -91.99892+22.323322 -98.434543+33.33233",
"0004 A I-10 Int -91.23234+32.343232 -97.333233+34.22222",
"0005 C Trenton Springs Ct. -90.22232+33.222123 -91.234432+23.33221" };
int cur, flds;
String n = "";
void parse() {
for (int x=0; x<census.length; x++) {
flds = 0;
cur=census[x].length();
n = "";
for (int y=census[x].length()-1; y>=0 && flds < 4; y--) {
if (census[x].charAt(y) == '-' || census[x].charAt(y) == '+') {
n = "," + census[x].substring(y, cur).trim() + n;
cur = y;
flds++;
n = census[x].substring(0, cur).trim() + n;
census[x] = n;
System.out.println(n);
public static void main(String[] args) {
CensusParser cp = new CensusParser();
cp.parse();
}Not very efficient, but it works!
Mark -
Hi All,
I get an xml file by making an http request. The name of the DTD comes as a relative path in the response xml file.
Questions
1. Is there a way to handle this
2. I read somewhere that i could avoid looking at the DTD alltogether,
can someone show me how with a sample code.
Kind regardsNothing seems to help, Please help,
Im using jdk1.4 A full source codee would be great.
Thanks in advance.
This is the trace and the Code follows below:
C:\codes\parser>java -classpath xerces.jar;. ReaderConnector
Initiating Connection to System URL = http://a.b.c.com:5280/vega/
request?method=login&ui=ch16132-user&pwd=pass
Connected ..
Opening Stream for reading data
Got input stream java.io.BufferedInputStream@19821f
Got reader java.io.BufferedReader@addbf1
Read login file ...
Parsing ...
Start of Login document
\vega\xml\xrf.dtd (The system cannot find the path)
Parsed
********************************3
*****Code*****
import javax.xml.parsers.*;
import org.xml.sax.*;
import java.io.*;
import java.util.*;
import java.net.*;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.helpers.*;
import org.xml.sax.ContentHandler;
import org.xml.sax.Locator;
import org.xml.sax.Attributes;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
* @author JAVA
* @version
public class ReaderConnector{
public ReaderConnector() {
/*Login URl doesnt change*/
private String loginUrl = "http://a.b.c.com:5280/vega/request?method=login&ui=ch16132-user&pwd=pass";
//private String loginUrl = "c://temp/test.xml";
private String sessionId;
public String getSessionId(){
if(sessionId == null){
createConnection();
return sessionId;
}else{
return sessionId;
public void createConnection() {
DataInputStream inputStream = null;
BufferedReader reader = null;
InputStream in = null;
FileOutputStream fos= null;
//System.setProperty("javax.xml.parsers.SAXParserFactory", "org.apache.xerces.jaxp.SAXParserFactoryImpl");
try {
URL url = new URL(loginUrl);
URLConnection connection = url.openConnection();
connection.setUseCaches(false);
System.out.println(" Initiating Connection to System URL = " + "http://a.b.c.com:5280/vega/request?method=login&ui=ch16132-usr&pwd=pass");
connection.connect();
System.out.println(" Connected ..");
System.out.println(" Opening Stream for reading data ");
in = new BufferedInputStream (new DataInputStream (connection.getInputStream()));
System.out.println("Got input stream "+ in);
reader = new BufferedReader(new InputStreamReader(new BufferedInputStream(in)));
System.out.println("Got reader "+ reader);
System.out.println("Read login file ...");
parseStream(reader);
}catch (Exception e) {
System.out.println(e.getMessage());
}finally {
try {
in.close();
//fos.close();
if (inputStream != null) {
inputStream.close();
if(reader!=null){
reader.close();
} catch (Exception ex) {
System.out.println(ex.getMessage());
ex.printStackTrace();
public void parseStream(BufferedReader br){
System.out.println("Parsing ...");
try{
/*SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setValidating(false);
spf.setNamespaceAware(false);
org.xml.sax.Parser sp = (org.xml.sax.Parser)spf.newSAXParser();
//sp.isValidating(false);
sp.setDTDHandler(new Resolver());
//sp.setDocumentHandler(new Handler());
InputSource iSource = new InputSource(br);
Handler h = new Handler();
sp.parse(iSource ); */
XMLReader parser;
parser = XMLReaderFactory.createXMLReader();
parser.setContentHandler(new Handler());
parser.setDTDHandler(new Resolver());
parser.parse(new InputSource(br));
}catch(Exception e){
System.out.println(e.getMessage());
System.out.println("Parsed");
public static void main(String [] args){
ReaderConnector connector = new ReaderConnector ();
//connector.testParsing("c://temp/test.xml");
connector.createConnection();
private class Resolver extends DefaultHandler{
public InputSource resolveEntity(String publicId, String systemId) throws SAXException {
System.err.println(publicId + " ! " + systemId);
if (("/vega/xml/xrf.dtd").equalsIgnoreCase(systemId) || ("/vega/xml/xrf.dtd").equalsIgnoreCase(publicId))
try {
return new InputSource(new URL("http://a.b.c.com:5280"+systemId).openStream());
} catch (MalformedURLException e) {
throw new SAXException(e);
} catch (IOException e) {
throw new SAXException(e);
else return null;
private class Handler extends org.xml.sax.helpers.DefaultHandler{
public void startDocument() throws org.xml.sax.SAXException {
System.out.println("Start of Login document");
public void endDocument() throws org.xml.sax.SAXException {
System.out.println("End of document");
public void ignorableWhitespace(char[] values, int param, int param2) throws org.xml.sax.SAXException {
public void endElement(java.lang.String str, java.lang.String str1, java.lang.String str2) throws org.xml.sax.SAXException {
System.out.println("End of element reached: str, str1, str2 "+ str + " , "+ str1 + " , "+ str2);
System.out.println("Session ID "+ sessionId);
public void skippedEntity(java.lang.String str) throws org.xml.sax.SAXException {
public void processingInstruction(java.lang.String str, java.lang.String str1) throws org.xml.sax.SAXException {
public void startElement(java.lang.String str, java.lang.String str1, java.lang.String str2, org.xml.sax.Attributes attributes) throws org.xml.sax.SAXException {
if(("A").equals(str2)){
for(int i=0; i< attributes.getLength();i++){
System.out.println("Attribute "+ i + ", Name, Value "+ attributes.getQName(i) + ", " + attributes.getValue(i));
if(("v").equalsIgnoreCase(attributes.getQName(i)))
sessionId = attributes.getValue(i);
public void endPrefixMapping(java.lang.String str) throws org.xml.sax.SAXException {
public void startPrefixMapping(java.lang.String str, java.lang.String str1) throws org.xml.sax.SAXException {
public void characters(char[] values, int param, int param2) throws org.xml.sax.SAXException {
String s = new String(values);
String text = s.substring(param, param+param2);
public void setDocumentLocator(org.xml.sax.Locator locator) {
XML File
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE XRF (View Source for full doctype...)>
- <XRF r="2.11.1" c="" g="" u="ch16132-user" k="" d="20050614" t="151146">
<A k="i0005" n="3" v="1964216949" />
</XRF>
****When you view source*******
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE XRF SYSTEM "/vega/xml/xrf.dtd">
<XRF r="2.11.1" c="" g="" u="ch16132-user" k="" d="20050614" t="151722">
<A k="i0005" n="3" v="350287547"/>
</XRF> -
I got new hard driver for my MacBook I don't have the cd but I do have flash drive that has the software I need help because when I turn on my laptop it shows me a file with question mark how can I install the software from the flash driver?
Hold down the Option key while you boot your Mac. Then, it should show you a selection of devices. Click your flash drive and it will boot from that.
-
The flat files are present in a unix server .
No other application can be loaded there
i have a lunix machine from where i have to access unix server data
which is the better way
1)directly reading the file from the unix server
2)loading the file in lunix and then reading
How this can be done in java ????
Now lets say we are reading the file in some way or the other ,How to do i parse it
File parsing
different file:
1)fixed format
file size 50 mb
eg
a)the data will be in fixed column size
0-60 -name
61-70 -department
71-80 -age
b)there will be section strip data for a particular section
Note :-Here i have to parse a particular section from the flat file the size of file is 50mb?
eg
section-Finance
name department age
Smith dep1 32
john dep2 40
turner dep3 56
section-marketing
name department age
antony dep1 60
black dep2 57
2)csv file
file size 15 kb
here the data size will be not be fixed but will have a seperator
name|department|age
Smith|dep1|32
john|dep2|40
turner|dep3|56
antony|dep1|60
black|dep2|57
here seperator is | it can be anything
Thanx in advance
MeghnaXml Convert:
http://industry.java.sun.com/solutions/products/by_product/0,2348,all-4398-99,00.html
Flat File to Xml Converion:
http://www.infoloom.com/gcaconfs/WEB/philadelphia99/lyons.HTM -
HT1752 My MacBook on startup shows file with question mark ,, what now?
My Mac shows file with question mark, what now.
Press the power button down to force a emergency use only hardware shutdown.
Press and hold the Option/alt key on the built in keyboard, boot the machine.
If MacintoshHD appears, select it and click the arrow, then in System Preferences > Startup Disk reset that. Done.
Sometimes a NVRAM reset is required then the above done again.
Folder with question mark issue
..Step by Step to fix your Mac
If MacintoshHD doesn't appear, or if it boots to gray screen or other issues, then it's more complicated of a fix, but once inside OS X then reset the Startup Disk.
Gray, Blue or White screen at boot, w/spinner/progress bar
..Step by Step to fix your Mac
You might need this if you don't have a recent backup and your problem is software related, Disk Utiltiy can't fix the drive and recommends you backup, erase and install.
.Create a data recovery/undelete external boot drive
If Disk Utility + Hardware Test shows no boot drive, then you have a dead drive or cable, or Mac issue.
My computer is not working, is my personal data lost? -
Hi,
I am trying to make file parser which can parse a uploaded documents. Here is the code. For some reason this code gives me no out but except a blank web page and also no compile error.... Whats missing?
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
* @author Owner
public class VectorMap extends HttpServlet {
boolean fileLoad;
public String fieldName;
public String fileName;
public String contentType;
public boolean isInMemory;
public long sizeInBytes;
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException, FileUploadException {
response.setContentType("text/html;charset=UTF-8");
fileLoad = ServletFileUpload.isMultipartContent(request);
// Create a factory for disk-based XML file items
FileItemFactory factory = new DiskFileItemFactory();
// Create a new XML file upload handler
ServletFileUpload upload = new ServletFileUpload(factory);
List items = upload.parseRequest(request);
// Processing the uploaded XML
Iterator iter = items.iterator();
while (iter.hasNext()) {
FileItem item = (FileItem) iter.next();
// Processing a XML file upload
if (!item.isFormField()) {
fieldName = item.getFieldName();
fileName = item.getName();
contentType = item.getContentType();
isInMemory = item.isInMemory();
sizeInBytes = item.getSize();
InputStream uploadedStream = item.getInputStream();
uploadedStream.close(); // Closing reading of the uploaded file
else{
// Error parsing the file.
response.sendRedirect("http://www.x.com/error.html");
}// End of while
PrintWriter out = response.getWriter();
try {
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet VectorMap</title>");
out.println("</head>");
out.println("<body>");
out.println(fileName+"<br>"+fileName+"<br>"+contentType);
out.println("</body>");
out.println("</html>");
} finally {
out.close();
} // End of processRequest Method
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
* Handles the HTTP <code>GET</code> method.
* @param request servlet request
* @param response servlet response
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
processRequest(request, response);
} catch (FileUploadException ex) {
Logger.getLogger(VectorMap.class.getName()).log(Level.SEVERE, null, ex);
* Handles the HTTP <code>POST</code> method.
* @param request servlet request
* @param response servlet response
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
processRequest(request, response);
} catch (FileUploadException ex) {
Logger.getLogger(VectorMap.class.getName()).log(Level.SEVERE, null, ex);
} // End of classThrow in some debugging lines, find out what points execution reaches, how many times loops are executed, etc.
-
File and question mark when starting
Flashing file and question marl when i start my computer
There are four general causes of this issue:
1. The computer's PRAM no longer contains a valid startup disk setting when there aren't any problems with the disk itself. This can be checked for by pressing the Option key and seeing if the drive appears.
2. The internal drive's directory structure has become damaged. This requires usage of an alternate bootable system to perform the repair.
3. Critical system files have been deleted. This requires usage of an alternate bootable system to reinstall them.
4. The internal drive has died or become unplugged. This is the most likely case if the computer took a sharp impact or there are unusual sounds coming from its location.
(103563) -
.AVI file format question
Upgrading from CS2 to Photoshop CS5
I found out after the fact that in order to edit video you need CS5 Extended.
So, I then went and returned regular and upgraded to Photoshop CS5 extended.
(See my other thread for details, but installing the 12.01 patch is not an option at this time.)
Try to use file open to open a .AVI file from one of my cameras and get a message of "unrecognized file format".
Was able to import the 7 second video into layers.
Checked support issues, and installed Quicktime 7.6.8
Also, due to 12.01 issues, reinstalled Photoshop CS5 Extended AFTER upgraded Quicktime to 7.6.8
Machine specs: Toshiba Satellite P30 Intel Pentium 4 CPU 3.60 GHZ (Hyperthreading Dual Core) 2GB RAM ATI Mobility Radeon X600 Win XP Professional SP3 About 12 GB disk space available at install time.
Note that Quicktime will open the .AVI file in question with no problems, as well as Roxio software (trying to get rid of that with CS5)I talked to support via phone and it appears the the problem is in installation. The install of CS5 extended did not take over the regular install. So, I need to start by completely uninstalling AGAIN and installed extended from scratch AGAIN.
I did try the program mention GSPOT as well. It says AVI codecs are installed on the machine inquestion. I will get more informaiton tonight afte rI do the re-install and see what happens. -
hi,
i know i've seen plenty of posts asking how to transfer files, my question is why doesn't simplying sending a file object from the client to the server work, file just implement Serializable? is it because the contents don't travel with the object? i'm pretty sure the object will go across, via socket programming or rmi, but why not the contents, or will they?
Thank you.Because the file object, to the best of my knowledge,
does not hold the contents, it just contains
information about the file, such as its path.Very true. I never thought about it in this depth before, but the [url http://java.sun.com/j2se/1.4.1/docs/api/java/io/File.html]API says:
"An abstract representation of file and directory pathnames."
That's all it is, a representation, not an actualy file.
Cheers,
Radish21 -
Checkpointing - control file contents question
Some clarification is needed if possible...
When you commit a transaction:
- commit scn is recorded in the itl of the data block and undo segment header
- lgwr records the committed scn (for all data blocks involved) to the redo log
Checkpoint Event
- (3 seconds or possibly less passes by) CKPT wakes up and signals DBWn to write dirty (modified and committed)
blocks to disk
- CKPT records the scn of those blocks in the control file (data file and redo thread sections) and the data file
header (task of checkpoint when a log switch occurs)
- Checkpoint position in the Redo Log is forwarded
Control file contents question:
When LGWR writes the commit scn to the redo log, who writes the scn to the control file? LGWR or CKPT?
Also, when is the redo thread scn written?
MattMatt,
This is my understanding of the stuff. Feel free to correct me.
Checkpoint SCN , as I mentioned in my last reply is the marker of the point till which the data is "chekpointed" to the datafiles. This marker tells the controlfile that in the case of the crash, where to start recovery of the datafile and have to go which extent in the redo stream? This is only available in the datafile header and in the controlfile. This doesn't get recorded in the redo log file/stream.
I mentioned checkpoint queue in my reply too. Though I couldn't find any reference directly mentioned between this and in the checkpoint SCN but I believe my theory , if not totall, partially is correct. The incremental checkpoint is the stuff which makes the decision that how many redo blocks needs to be applied to the datafile if its closed without a proper checkpoint. So this part is maintained in the Datafile header itself in the form of the checkpoint SCN. When not matched with the conrolfile checkpoint SCN, which is always higher than this, a recovery is reported.
I hope its somewhat correct. Do let me know your views too.
Cheers
Aman.... -
File Parser that allows me to add/remove rows in a file
Hi,
Have been trying to write a file parser that takes as input a file containing > 100,000 lines. I am parsing each line with a given delimiter and pulling out the fields I require but the response is very slow. I'm loading the data into a JTable for viewing (So I now have a spread sheet )but what I want now is the ability to add/remove entire rows. I can't do this with a JTable, can only edit columns within rows. Does any one know of a better approach?
Thanks ... JWhat I need to do is present all the rows to the user and have them delete/edit rows at will but only through the GUI. JTable has a delete row method but the problem I'm having is getting the modified data from the JTable to a file.
ie, file looks like
Name|Address|Number
Joe|some St|111
Mick|My Rd|222
Mary|My Ave|333
I want to present this data in a JTable ... done.
Now want to remove Mick row and change Mary's number to 999
So new file should now contain
Name|Address|Number
Joe|some St|111
Mary|My Ave|999
But problem is I'm dealing with > 200 columns and > 100,000 rows -
Can't log in white screen with flashing file and Question mark
I've been have trouble with getting on line and screen freezing up. Now I have a solid white screen with a icon of a file and question mark on it flashing. Iv tried unplugging and resetting with no luck.
Have a look at > A flashing question mark appears when you start your Mac
Dennis -
JSP XML file parsing XSLT using Xalan
Hi all
I have created an XML file "view_campaign.xml" using JSP as shown in a code below and i wanna know how i should proceed to parse the XML file and so i can display this XML as the XSLT file i created.
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%
// Identify a carriage return character for each output line
int iLf = 10;
char cLf = (char)iLf;
// Create a new empty binary file, which will content XML output
File outputFile = new File("C:\\WebContent\\view_campaigns.xml");
//outputFile.createNewFile();
FileWriter outfile = new FileWriter(outputFile);
// the header for XML file
outfile.write("<?xml version='1.0' encoding='ISO-8859-1'?>"+cLf);
try {
// Define connection string and make a connection to database
//DriverManager.registerDriver (new org.apache.derby.jdbc.ClientDriver());
Connection conn = DriverManager.getConnection("jdbc:derby://localhost:1527/sample","app","app");
Statement stat = conn.createStatement();
// Create a recordset
ResultSet rset = stat.executeQuery("Select * From campagn");
// Expecting at least one record
if( !rset.next() ) {
throw new IllegalArgumentException("No data found for the campaigns table");
outfile.write("<campaigns>"+cLf);
outfile.write("<campaign>"+cLf);
outfile.write("<campaign_id>" + rset.getString("campagn_id") +"</campaign_id>"+cLf);
outfile.write("<campaign_name>" + rset.getString("campagn_name") +"</campaign_name>"+cLf);
outfile.write("<campaign_type>" + rset.getString("campagn_type") +"</campaign_type>"+cLf);
outfile.write("<client>" + rset.getString("client_name") +"</client>"+cLf);
outfile.write("<positions>" + rset.getString("positions_nbr") +"</positions>"+cLf);
outfile.write("<begin>" + rset.getString("campagn_beginning_date") +"</begin>"+cLf);
outfile.write("<close>" + rset.getString("campagn_ending_date") +"</close>"+cLf);
outfile.write("</campaign>"+cLf);
// Parse our recordset
// Parse our recordset
while(rset.next()) {
outfile.write("<campaign>"+cLf);
outfile.write("<campaign_id>" + rset.getString("campagn_id") +"</campaign_id>"+cLf);
outfile.write("<campaign_name>" + rset.getString("campagn_name") +"</campaign_name>"+cLf);
outfile.write("<campaign_type>" + rset.getString("campagn_type") +"</campaign_type>"+cLf);
outfile.write("<client>" + rset.getString("client_name") +"</client>"+cLf);
outfile.write("<positions>" + rset.getString("positions_nbr") +"</positions>"+cLf);
outfile.write("<begin>" + rset.getString("campagn_beginning_date") +"</begin>"+cLf);
outfile.write("<close>" + rset.getString("campagn_ending_date") +"</close>"+cLf);
outfile.write("</campaign>"+cLf);
outfile.write("</campaigns>"+cLf);
// Everything must be closed
rset.close();
stat.close();
conn.close();
outfile.close();
catch( Exception er ) {
%>////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
this is my .XSL file
<?xml version="1.0" encoding="iso-8859-1" ?>
- <!-- DWXMLSource="view_campaigns.xml"
-->
<!DOCTYPE xsl:stylesheet (View Source for full doctype...)>
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="iso-8859-1" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />
- <xsl:template match="/">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Gestion des campagnes</title>
</head>
- <body>
Gestion des campagnes
- <table border="1">
- <tr bgcolor="#9acd32">
<th align="left">Code</th>
<th align="left">Nom</th>
<th align="left">Type</th>
<th align="left">Client</th>
<th align="left">Nombre de positions</th>
<th align="left">Date d'ouverture</th>
<th align="left">Date de cl�ture</th>
</tr>
- <xsl:for-each select="campaigns/campaign">
- <tr>
- <td>
<xsl:value-of select="campaign_id" />
</td>
- <td>
<xsl:value-of select="campaign_name" />
</td>
- <td>
<xsl:value-of select="campaign_type" />
</td>
- <td>
<xsl:value-of select="client" />
</td>
- <td>
<xsl:value-of select="positions" />
</td>
- <td>
<xsl:value-of select="begin" />
</td>
- <td>
<xsl:value-of select="close" />
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>I would be greatful that u answer my question what i should do have any exemple case study.Hi,
Try this code
JspWriter out = pageContext.getOut(); // Get JSP output writter
javax.xml.transform.TransformerFactory tFactory = javax.xml.transform.TransformerFactory.newInstance(); //Instantiate a TransformerFactory.
String realPath = "c:/applyXsl.xsl";
java.io.File file = new java.io.File(realPath); // crearte a file object for given XSL.
// Use the TransformerFactory to process the stylesheet Source and generate a Transformer.
javax.xml.transform.Transformer transformer = tFactory.newTransformer(new javax.xml.transform.stream.StreamSource(file));
java.io.StringReader inputStream = new java.io.StringReader("c:/xmlFile.xml"); // create an input stream for given XML doc
java.io.ByteArrayOutputStream obj = new java.io.ByteArrayOutputStream(); // Create an output stream for XSL applied XML doc.
// 3. Use the Transformer to transform an XML Source and send the output to a Result object.
transformer.transform(new javax.xml.transform.stream.StreamSource(inputStream), new javax.xml.transform.stream.StreamResult(obj));
String outputString = obj.toString(); // get the XSL applied applied XML document for print
out.println(outputString); // print the XSL applied XML in to JSP.
however you need xercesImpl.jar and xml-apis.jar files to run this program.
Regards,
Ananth.P
Maybe you are looking for
-
hi, i have tryed to install os x leopard, (its a old imac) , disk utility is greyed out , my install dvd cant find any hdd to install on , my only way to format and configure is through terminal but dont know what commands to execute... i tryed diffr
-
Itunes hangs on disconnect / reconnect of internet connection
Quite often I do stream internet radio stations using Itunes. I am listening through my BeoCenter2. When I swich of the BeoCenter2, I often forget to stop the stream in Itunes. This would not a problem, but because my internet provider drops the conn
-
How to setup iMessage correctly to avoid double replys
Hi there. I have just installed Mountain Lion on my macbook air. I also have an iPhone. I now have connected my account with iMessage on the macbook. I am using the same account on my iPhone. So far so good. I then start a chat in iMessage from my ma
-
Weblogic managed servers connecting to the servers in different cluster
Hi All, We have a weired problem going on for a while. We have a cluster configuration with an admin server and two managed servers. We have the similar configuration in DEV, TEST and PROD. The problem is that
-
Hi guys, I'm installed Arch on Acer Aspire 5715Z which has an intel GM965 video card. I followed the beginners guide, this is not my first installation of Arch, but there is something that I cannot solve. You can see my problems here: http://www.pier