BizTalk Utilities CV ,   Jobs ,   Code library  
 
java.xml.sax.InputSource Class
org.xml.sax.helpers.XMLReaderFactory Class
javax.xml.transform.URIResolver Class
javax.xml.transform.TransformerFactory Class
javax.xml.transform.Transformer Class
javax.xml.transform.Templates Class
javax.xml.transform.stream.StreamSource Class
javax.xml.transform.stream.StreamResult Class
javax.xml.transform.Source Class
javax.xml.transform.sax.SAXSource Class
javax.xml.transform.sax.SAXResult Class
javax.xml.transform.Result Class
javax.xml.transform.ErrorListener Class
javax.xml.transform.dom.DOMSource Class
javax.xml.transform.dom.DOMResult Class
javax.xml.parsers.SAXParserFactory Class
javax.xml.parsers.SAXParser Class
javax.xml.parsers.DocumentBuilderFactory Class
javax.xml.parsers.DocumentBuilder Class
SAX 2.0 Features and Properties
<< XSLT
.NET and XML >>

By :Mark Wilson
I am the creator of TopXML. I am available for international and local (Australia) contracts. I am a Solution Architect/Business Analyst. I have worked in IT in several countries (NZ, Australia, South Africa, UK) building and training teams for government and very large non-governmental organizations. I am ex-Microsoft Consulting Services. I wrote the first book on Microsoft XML published in 2000 called XML Programming with VB and ASP. Most recently I have been building tools for the SEO industry. Ask me for a 37 point SEO health-checkup for your website.
First posted :03/24/2008
Times viewed :178

 

Overview of DTD Handlers

There are four core handler interfaces defined by SAX 2.0: org.xml.sax.ContentHandler, org.xml.sax.ErrorHandler, org.xml.sax.DTDHandler, and org.xml.sax.EntityResolver. In this scenario we discuss DTDHandler. This interface defines methods you will generally never be called upon to use. Used when processing a DTD to recognize and act on declarations for an unparsed entity.

The org.xml.sax.DTDHandler Handler

All Known Subinterfaces: javax.xml.transform.sax.TransformerHandler
All Known Implementing Classes: org.xml.sax.helpers.DefaultHandler, org.xml.sax.HandlerBase, org.xml.sax.helpers.XMLFilterImpl

Members

Signature

Public methods

void

notationDecl(String name, String publicId, String systemId)

void

unparsedEntityDecl(String  name, String publicId, String systemId, String notationName)

Overview

The DTDHandler interface allows you to receive notification when  a reader encounters an unparsed entity or a notation declaration. Remember that both of these events occurs in DTDs, not XML Documents, which is why this is called DTDHandler. You can associate your DTDHandler implementation class by using set setDTDHandler() method of XMLReader.

Method Overviews

You generally create an implementation of DTDHandler and register it with your reader through the XMLReader’s setDTDHandler() method. This is generally useful when writing low-level applications that must either reproduce XML content( such as an XML Editor), or when you want to build up some Java representation of a DTD’s constraints( such as for data bindings). But in most of the cases, it is not something you will need very soon.

Example of a DTD

<?xml version="1.0" encoding="UTF-8"?>

<!NOTATION person  SYSTEM "databas/employees">

<!ENTITY topxml_logo SYSTEM "http://www.topxml.com/jpeg/topxml.jpeg" NDATA jpeg>

<!ELEMENT Person (First, Last, Title, Phone, Email)>

<!ELEMENT Name (#PCDATA)>

<!ELEMENT Client-name (#PCDATA)>

<!ELEMENT First (#PCDATA)>

<!ELEMENT Last (#PCDATA)>

<!ELEMENT Title (#PCDATA)>

<!ELEMENT Phone (#PCDATA)>

<!ELEMENT Email (#PCDATA)>

Example of notationDecl()

  public void             notationDecl(String name, String publicId, String systemId)

  {

    System.out.println("Name:"+name+", Public Id:"+publicId+", SystemId :"+systemId);

  }

On execution of this method you will get the output:

             

  Name:person, Public Id:null, SystemId :databas/employees

Example of unparsedEntityDecl()

  public void             unparsedEntityDecl(String name, String publicId, String systemId, String notationName)

  {

    System.out.println("Name:"+name+", Public Id:"+publicId+", SystemId"+systemId+", Notation Name:"+notationName);

  }

 On execution of above method you will get the output:

Name:topxml_logo, Public Id:null, SystemIdhttp://www.topxml.com/jpeg/topxml.jpeg, Notation Name:jpeg

Example of how to use DTDHandler

DTDHandlerImpl dtdHandler = new DTDHandlerImpl();//This class implements DTDHandler interface

     xmlReader.setDTDHandler(dtdHandler);//association of DTDHandlerImpl with XMLReader  


Rate this article on a scale of 1 to 10

Your vote :  


 

Recent Jobs

Software Developers Needed in Charl
Sr. Software Engineer - Analytics
Immediate Mainframe openings for Ch
Immediate TANDEM-TAL openings for C
Immediate ASP.NET/C# Openings for C

View all Jobs (Add yours)
View all CV (Add yours)



go to meeting
swimming pool contractor
teleconferencing
water softener
Teleconference
Host Department NOLIMIT Web Hosting
MSN
sunglasses


    Email TopXML  

Front Page Daily Stuff TopXML Forum XML blogs XML Newsgroups BizTalk Biztalk Utilities Biztalk Utilities Tutorial B2B SAP XML Microsoft .NET Dotnet System XML Soapformatter SQLXML XMLserializer XQuery PHP PHP SimpleXML PHP XML Dom PHP XML RPC PHP XSLT Java Java Java XML Xalan Microsoft ASP ASP Schemas XML SQL Server XML XMLDom XSL XSL Tutorial XSLT Stylesheets General Javascript CSS XHTML WAP