পৃষ্ঠাসমূহ

Search Your Article

CS

 

Welcome to GoogleDG – your one-stop destination for free learning resources, guides, and digital tools.

At GoogleDG, we believe that knowledge should be accessible to everyone. Our mission is to provide readers with valuable ebooks, tutorials, and tech-related content that makes learning easier, faster, and more enjoyable.

What We Offer:

  • 📘 Free & Helpful Ebooks – covering education, technology, self-development, and more.

  • 💻 Step-by-Step Tutorials – practical guides on digital tools, apps, and software.

  • 🌐 Tech Updates & Tips – simplified information to keep you informed in the fast-changing digital world.

  • 🎯 Learning Support – resources designed to support students, professionals, and lifelong learners.

    Latest world News 

     

Our Vision

To create a digital knowledge hub where anyone, from beginners to advanced learners, can find trustworthy resources and grow their skills.

Why Choose Us?

✔ Simple explanations of complex topics
✔ 100% free access to resources
✔ Regularly updated content
✔ A community that values knowledge sharing

We are continuously working to expand our content library and provide readers with the most useful and relevant digital learning materials.

📩 If you’d like to connect, share feedback, or suggest topics, feel free to reach us through the Contact page.

Pageviews

Wednesday, January 25, 2017

Apache Xerces SAX Parser - Overview

SAX (the Simple API for XML) is an event-based parser for xml documents.Unlike a DOM parser, a SAX parser creates no parse tree. SAX is a streaming interface for XML, which means that applications using SAX receive event notifications about the XML document being processed an element,
and attribute, at a time in sequential order starting at the top of the document, and ending with the closing of the ROOT element.
  • Reads an XML document from top to bottom, recognizing the tokens that make up a well-formed XML document
  • Tokens are processed in the same order that they appear in the document
  • Reports the application program the nature of tokens that the parser has encountered as they occur
  • The application program provides an "event" handler that must be registered with the parser
  • As the tokens are identified, callback methods in the handler are invoked with the relevant information

When to use?

You should use a SAX parser when:
  • You can process the XML document in a linear fashion from the top down
  • The document is not deeply nested
  • You are processing a very large XML document whose DOM tree would consume too much memory.Typical DOM implementations use ten bytes of memory to represent one byte of XML
  • The problem to be solved involves only part of the XML document
  • Data is available as soon as it is seen by the parser, so SAX works well for an XML document that arrives over a stream

Disadvantages of SAX

  • We have no random access to an XML document since it is processed in a forward-only manner
  • If you need to keep track of data the parser has seen or change the order of items, you must write the code and store the data on your own

ContentHandler Interface

This interface specifies the callback methods that the SAX parser uses to notify an application program of the components of the XML document that it has seen.
  • void startDocument() - Called at the beginning of a document.
  • void endDocument() - Called at the end of a document.
  • void startElement(String uri, String localName, String qName, Attributes atts) - Called at the beginning of an element.
  • void endElement(String uri, String localName,String qName) - Called at the end of an element.
  • void characters(char[] ch, int start, int length) - Called when character data is encountered.
  • void ignorableWhitespace( char[] ch, int start, int length) - Called when a DTD is present and ignorable whitespace is encountered.
  • void processingInstruction(String target, String data) - Called when a processing instruction is recognized.
  • void setDocumentLocator(Locator locator)) - Provides a Locator that can be used to identify positions in the document.
  • void skippedEntity(String name) - Called when an unresolved entity is encountered.
  • void startPrefixMapping(String prefix, String uri) - Called when a new namespace mapping is defined.
  • void endPrefixMapping(String prefix) - Called when a namespace definition ends its scope.

Attributes Interface

This interface specifies methods for processing the attributes connected to an element.
  • int getLength() - Returns number of attributes.
  • String getQName(int index)
  • String getValue(int index)
  • String getValue(String qname)

No comments:

Post a Comment