// —————————————————————————–
// SAXExample.java
// —————————————————————————–
// imports
import java.io.*;
import java.net.URL;
import org.xml.sax.*;
import org.xml.sax.helpers.DefaultHandler;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
/**
* —————————————————————————–
* Demonstrate how to use SAX.
*
* @version 1.0
* @author Muhammad Abid (abidshafiq479@hotmail.com)
* @author http://www.techstop.abidshafiq.com
* —————————————————————————–
*/
public class SAXExample extends HandlerBase{
// Store the locator
Locator locator;
/*
** +———————————————–+
** | METHOD: main |
** +———————————————–+
*/
static public void main(String[] argv) {
try {
if (argv.length != 1) {
// must pass in the name of the XML file
System.err.println(“Usage: java SAXExample filename”);
System.exit(1);
}
// Create a new handler for the parser
SAXExample sample = new SAXExample();
//get instance of factory
SAXParserFactory factory = SAXParserFactory.newInstance();
// Get an instance of the parser
SAXParser parser = factory.newSAXParser();
// Convert file to URL and parse
try {
parser.parse(fileToURL(new File(argv[0])).toString(),sample);
} catch (SAXParseException e) {
System.out.println(e.getMessage());
} catch (SAXException e) {
System.out.println(e.getMessage());
}
} catch (Exception e) {
System.out.println(e.toString());
}
}
/*
** +———————————————+
** | METHOD: fileToURL |
** +———————————————+
*/
static URL fileToURL(File file) {
String path = file.getAbsolutePath();
String fSep = System.getProperty(“file.separator”);
if (fSep != null && fSep.length() == 1) {
path = path.replace(fSep.charAt(0), ‘/’);
}
if (path.length() > 0 && path.charAt(0) != ‘/’) {
path = ‘/’ + path;
}
try {
return new URL(“file”, null, path);
} catch (java.net.MalformedURLException e) {
throw new Error(“unexpected MalformedException”);
}
}
/*
** +————————————————————-+
** | ———————————————————– |
** | Sample Implementation of DocumentHandler Interface |
** | ———————————————————– |
** +————————————————————-+
*/
/*
** +———————————————+
** | METHOD: setDocumentLocator |
** +———————————————+
*/
public void setDocumentLocator(Locator locator) {
System.out.println(“SetDocumentLocator:”);
this.locator = locator;
}
/*
** +———————————————+
** | METHOD: startDocument |
** +———————————————+
*/
public void startDocument() {
System.out.println(“StartDocument”);
}
/*
** +———————————————+
** | METHOD: endDocument |
** | Receive notification of the end of the document.|
** +———————————————+
*/
public void endDocument() throws SAXException {
System.out.println(“EndDocument”);
}
/*
** +———————————————+
** | METHOD: startElement |
** +———————————————+
*/
public void startElement(String name,Attributes atts) throws SAXException {
System.out.println (“StartElement: ” + name);
for (int i=0; i
String type = atts.getType(i);
String value = atts.getValue(i);
System.out.println(" " + aname + "("+type+") = " + value);
}
}
/*
** +---------------------------------------------+
** | METHOD: endElement |
** +---------------------------------------------+
*/
public void endElement(String name) throws SAXException {
System.out.println("EndElement:" + name);
}
/*
** +---------------------------------------------+
** | METHOD: chracters |
** +---------------------------------------------+
*/
public void chracters(char[] cbuf, int start, int len) {
System.out.print("Characters: ");
System.out.println(new String(cbuf, start, len));
}
/*
** +---------------------------------------------+
** | METHOD: ignorableWhitespace |
** +---------------------------------------------+
*/
public void ignorableWhitespace(char[] cbuf, int start, int len) {
System.out.println("ignorableWhitespace:");
}
/*
** +---------------------------------------------+
** | METHOD: processingInstruction |
** +---------------------------------------------+
*/
public void processingInstruction(String target, String data) throws SAXException {
System.out.println("processingInstruction: " + target + " " + data);
}
/*
** +-------------------------------------------------------------+
** | ----------------------------------------------------------- |
** | Sample Implementation of EntityResolver Interface |
** | ----------------------------------------------------------- |
** +-------------------------------------------------------------+
*/
/*
** +---------------------------------------------+
** | METHOD: resolveEntity |
** +---------------------------------------------+
*/
public InputSource resolveEntity(String publicID, String systemID) throws SAXException{
System.out.println("resolveEntity:" + publicID + " " + systemID);
System.out.println("Locator:" + locator.getPublicId() + " " + locator.getSystemId() +
" " + locator.getLineNumber() + " " + locator.getColumnNumber());
return null;
}
/*
** +-------------------------------------------------------------+
** | ----------------------------------------------------------- |
** | Sample Implementation of DTDHandler Interface |
** | ----------------------------------------------------------- |
** +-------------------------------------------------------------+
*/
/*
** +---------------------------------------------+
** | METHOD: notationDec1 |
** +---------------------------------------------+
*/
public void notationDec1(String name, String publicID, String systemID) {
System.out.println("NotationDec1: " + name + " " + publicID + " " + systemID);
}
/*
** +---------------------------------------------+
** | METHOD: unparsedEntityDec1 |
** +---------------------------------------------+
*/
public void unparsedEntityDec1(String name, String publicID, String systemID, String notationName) {
System.out.println("unparsedEntityDec1: " + name + " " + publicID + " " + systemID + " " + notationName);
}
/*
** +-------------------------------------------------------------+
** | ----------------------------------------------------------- |
** | Sample Implementation of ErrorHandler Interface |
** | ----------------------------------------------------------- |
** +-------------------------------------------------------------+
*/
/*
** +---------------------------------------------+
** | METHOD: warning |
** +---------------------------------------------+
*/
public void warning(SAXParseException e) throws SAXException {
System.out.println("Warning: " + e.getMessage());
}
/*
** +---------------------------------------------+
** | METHOD: error |
** +---------------------------------------------+
*/
public void error(SAXParseException e) throws SAXException {
throw new SAXException(e.getMessage());
}
/*
** +---------------------------------------------+
** | METHOD: fatalError |
** +---------------------------------------------+
*/
public void fatalError(SAXParseException e) throws SAXException {
System.out.println("Fatal Error");
throw new SAXException(e.getMessage());
}
}
Posted in
Tags: 
Nice web. Maybe you should try to monetize it with
http://tiny.cc/05mrc
They do have 40 days cookie and they pay 10-15% commisions. Now compare this to adsense, ebay or amazon
affiliate programs.
There are several posts out there about this, I think taking there reference could have made this post or article really informative. I am not saying this information is not good.
Terrific work! This is the type of information that should be shared around the web. Shame on the search engines for not positioning this post higher!
I choose realize sure and bookmark this servant, I intent come endorse to succeed you more.
Thank you for sharing this. Well done and very informative.
I agree! This article is very impressive! The information here should be shared. I got this already bookmarked for future reference.
I’ve recently started a blog, the information you provide on this site has helped me tremendously. Thank you for all of your time & work.
I am sure that i will come back to your blog soon. Keep us posting interesting articles
Thank you for another great article. Where else could anyone get that kind of information in such a perfect way of writing? I have a presentation next week, and I am on the look for such information.
Intimately, the post is in reality the freshest topic on this registry related issue. I concur with your conclusions and will eagerly look forward to your forthcoming updates. Saying thanks will not just be enough, for the wonderful clarity in your writing. I will immediately grab your rss feed to stay abreast of any updates.
This has truly sparked up an idea in my mind. This can be a superb website submit.
I’m grateful for you because of this excellent information. You actually did make my day :
I eat recently started using the blogengine.net and I having some problems here? in your blog you stated that we need to capacitate write permissions on the App_Details folder…unfortunately I don’t agree how to empower it.
Spacious possessions as usual…
Hey, awesome blogging. Want to get money for blogging? Check out: http://bit.ly/BlogPaid
Good to see a collection of relevant info.I truly hate Blogs with all advertisement,but your blog is something which i can describe a great blog made to provide Info.I have Bookmarked your blog to my list of daily surfing blog.Greetings
interesting blog. It would be great if you can provide more details about it. Thanks you
, thank for this astonishing information. Therefore, I would like to ask for your allowance to add some of this information in my blog. Of course, I will provide a link to your website, as a source of my quoted information.
The articles you have on your website are always so enjoyable to read. Good work and I bookmarked it.
, thank for this amazing information. Therefore, I would like to ask for your permission to add some of this information in my blog. Of course, I will provide a link to your , as a source of my quoted information.
Searching for this for some time now – i guess luck is more advanced than search engines
I allow in, I compel ought to not been on this webpage in a lengthy time… at any rate it was another enjoyment to look at It is such an noted thesis and ignored not later than so various, even professionals. I appreciation you to usurp making people more au fait of viable issues.
Great stuff as usual…
with ‘we leave it to you to decide’.
Thank you very sunny blog
Genial fill someone in on and this mail helped me alot in my college assignement. Thanks you on your information.
Haha, I am quite interested in your site. If I were to use this website, I could earn you 100-200 USD daily. I am willing to work on monetizing your site, on the condition that you share 50% of revenues with me. If you are interested, please send me an email
I found your site via yahoo thanks for the post. I will save it for future reference. Thanks Webmaster Forum
Great stuff as usual…
nice post. thanks.
Spitze Design hat dieser Blog. Woher hast du die Vorlage ? War bestimmt sehr teuer.
This valuable regarded easiest publish that we feature ever in your life examine. There are granted a terrific joint of answers. I will bookmark with no need of have in common this using excellent various good friends. Cultivate the nice part of perform the job, Rankings to keep talking to your primary posts.
Took me interval to study all the comments, but I as a matter of fact enjoyed the article. It proved to be Truly friendly to me and I am solid to all the commenters here! It’s always scrupulous when you can not solitary be up on, but also entertained! I’m unshakeable you had fun column this article.
Hello Welcome to the official Virility-EX website. You will find the latest information and the best prices right here. Right now, we offer new customers a free trial of Virility-EX. We also offer a 60% discount and a free set of Adult DVDs, worth $98.00, when you buy Virility-EX today. Our goal is to constantly improve and provide satisfaction to our customers. We accept payment via PayPal or ACH. We have a satisfaction guarantee. All refund requests are processed by email and must include your order number and payment information. link: http://bit.ly/doTAur
hello, I am agree with your posting about that but i found something strange that i felt you didnt know the problem before you posting this. i want to ask :where do you know about this friend ?Regards Owner of Bertoiastool.com
Hayadministrator I love with ur posting . May i use this information for my university test ? thanks adminstrator
Good News website. I love this news site
This is an informative post, thanks a lot!
Any of you guys used Auto Blog System X? I have been using it for about two weeks now and made $3,000. Anyone can do it really, if you like blogging then you will find it very easy. It teaches you about a $100,000,000 loophole you can make money from on AutoPilot. Check their site out, they guarantee you will make $1000 within 1 week or your money back
I likes Your style boss
Good night dude, i like your news site ! Have a nice weekend
Hello dude,i like Ones New website ideal much. attain u have on suggestion being my site? thanks for Your New attention
You are the man ! Bye
Very nice post It’s nice to know people who know what they are talking about!
I liking Your New style man
You are the man ! Good luck for you
Good night dude, i like your news ! Have a nice day
I like your site.
, This information is really good and I will say will always be helpful if we try it risk free? So if you can back it up .. That will really help us all. And this might bring some good repute to you. The diet of human beings prior to the arrival of agriculture, technology and civilization is known as the Paleolithic Diet !! This Stone Age diet, in short, consisted of mainly lean red meat and vegetables. In this type of diet animal meat is consumed in large quantities and 45 to 65% of the energy needed by the body is derived from it. Over and over again, life expectancy studies related to diet, including by the World Health Organization (WHO), have concluded that Americans and Europeans would do better to eat more like third world peoples as the options provided by their additional wealth have most often lead to poor nutritional choices. This is the same basis for the USDA based their popular food pyramid in 1994 ! Researchers at Harvard have only suggested perhaps tweaking the food pyramid by replacing some dairy products and read meat with more fruits, vegetables, and fish while also emphasizing the importance of improving the ratio of “good” to “bad” cholesterol? Plus, exercise not only makes weight loss much easier, but also lowers blood glucose levels, decreases blood pressure, improved circulation, and increases one’s metabolism. Good regular sleep patterns are also just as important. Diets based on USDA recommendations include DASH, American Diabetic Assoc, Weight Watchers, and Jenny Craig! When children understand how important “real food” is and where the natural ingredients of our food come from, they will increase the general population’s appreciation for preserving our natural environment and limiting toxins and polluting processes in our world. We may even trend back to the time when people stepped outside their homes to interact with family and neighbors in home and community gardens and block-party barbeques! Does anybody even remember how nice those days were?
Took me time to read all of the comments, but I truly loved the post. It proved to be very helpful to me and I am certain to all of the commenters here! It is usually good when you can not only be informed, but also engaged! I am sure you had pleasure writing this article.adoption interest free loans
how are you recognise this ?
This post is good.
This article must be headline news Thank you sir
Hello Friend , i like with u blog. LOL Please come to my blog
great luck being consumers
I was Truly Searching for this Source a Several Days Back Once more. Many thanks for sharing with us your wisdom.This will absolutely going to Aid me in my projects .
Best you should edit the post name title SAXParser Example | TechStop to more suited for your webpage you create. I loved the post even sononetheless.
ЎIncreнble! No estб claro para mн, їcуmo offen que la actualizaciуn de su nombre de techstop.abidshafiq.com.
Gracias
[url=http://www.affhtc.com/]Nicolas[/url]
Super post, tienen que marcarlo en Digg
[url=http://ruforestcom.no-ip.org/]SuperSonic[/url]
Most men would like 2 see da metric system started in USA…Self esteem 4 no other reason where some can brag their “Virility” is “177.8mm.”
ЎHola!
maravillosamente, mucho la informaciГіn Гєtil
[url=http://eru1.myftp.biz/]Worker[/url]
One of the most interesting blog I’ve read on this subject. I hope this website will have a long life. Have a nice day!
Wow such a lovely site!
I revelled reading it. I require to read more on this topicI am admiring the time and effort you put in your blog, because it is obviously one great place where I can find lot of functional info..moncler coats
Someone I work with visits your site regularly and recommended it to me to read as well. The writing style is excellent and the content is interesting. Thanks for the insight you provide the readers!
Simply wanna remark on few general things, The website style is perfect, the subject material is rattling wonderful : D.
Anyone designed many useful details right now there. I did so a glance with regard to within the problem as well as discovered most persons will certainly concur with all your web site.
What a great post! I have no clue how you were able to write this report..it’d take me days. Well worth it though, I’d assume. Have you considered selling advertising space on your blog?