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 :
419
The java.xml.sax.InputSource Class
Super Class :
java.lang.Object
Members
Signature
Public methods
InputStream
getByteStream()
Reader
getCharacterStream()
String
getEncoding()
String
getPublicId()
String
getSystemId()
void
setByteStream(InputStream byteStream)
void
setCharacterStream(Reader characterStream)
void
setEncoding(String encoding)
void
setPublicId(String publicId)
void
setSystemId(String systemId)
Overview
An inputsource encapsulate information about a single object, the
document to parse. In situations where a system identifier, public identifier,
or stream may all be tied to one URI, using an InputSource for encapsulation
can become very handy. The class has accessor and mutator methods for its
system id and public id, a character encoding, a byte
stream(java.io.InputStream), and a character stream(java.io.Reader).
There are two places that the application will deliver this input source
to the parser: as the argument to the Parser.parse method, or as the return
value of the EntityResolver.resolveEntity method.
The SAX parser will use the InputSource object to determine how to read
XML input. If there is a character stream available, the parser will read that
stream directly; if not, the parser will use a byte stream, if available; if neither
a character stream nor a byte stream is available, the parser will attempt to
open a URI connection to the resource identified by the system identifier.
An InputSource object belongs to the application: the SAX parser shall
never modify it in any way (it may modify a copy if necessary).
Example of how to create InputSource from a file
InputSource inputSource = new
InputSource(new java.io.FileInputStream(new java.io.File(xmlURI)));
Example of how to create InputSource from java.io.Reader
String text = "{your xml string}";
java.io.Reader reader = new
java.io.StringReader(text);
InputSource inputSource =
new InputSource(reader);