Unicorn XML Toolkit
Version 1.50.00

Namespace Sax
Class CInputSource

class CInputSource: public CInterface {
public:
    CInputSource();
    CInputSource(const WCHAR *pszSystemId);
    CInputSource(IStream *pByteStream);
    CInputSource(IUnicodeStream *pCharacterStream);
    ~CInputSource();
public:
    void SetPublicId(const WCHAR *pszPublicId);
    const WCHAR *GetPublicId();
    void SetSystemId(const WCHAR *pszSystemId);
    const WCHAR *GetSystemId();
    void SetByteStream(IStream *pByteStream);
    IStream *GetByteStream();
    void SetEncoding(const WCHAR *pszEncoding);
    const WCHAR *GetEncoding();
    void SetCharacterStream(IUnicodeStream *pCharacterStream);
    IUnicodeStream *GetCharacterStream();
    };
typedef XInterface<CInputSource> XInputSource;

The input source for XML entity.

This class allows a SAX application to encapsulate information about an input source in a single object, which may include a public identifier, a system identifier, a byte stream (possibly with a specified encoding), and/or a character stream.

There are two places that the application will deliver this input source to the reader: as the argument to the CXmlReader::Parse method, or as the return value of the CEntityResolver::ResolveEntity method.

The SAX reader will use the input source object to determine how to read XML input. If there is a character stream available, the reader will read that stream directly; if not, the reader will use a byte stream, if available; if neither a character stream nor a byte stream is available, the reader will attempt to open a URI connection to the resource identified by the system identifier.

Input source object belongs to the application: the SAX reader shall never modify it in any way (it may modify a copy if necessary).

Since:
1.00.00
Version:
1.50.00
Author:
C++ interfaces by Alexey Gokhberg; based on the original SAX2 specification by David Megginson
Constructor/Destructor Summary
CInputSource ();
����������Constructs the input source.
CInputSource (const WCHAR *pszSystemId);
����������Constructs the input source with a system identifier.
CInputSource (IStream *pByteStream);
����������Constructs the input source with a byte stream.
CInputSource (IUnicodeStream *pCharacterStream);
����������Constructs the input source with a character stream.
~CInputSource ();
����������Destroys the input source.

Function Summary
void SetPublicId (const WCHAR *pszPublicId);
����������Sets the public identifier for this input source.
const�WCHAR�* GetPublicId ();
����������Gets the public identifier for this input source.
void SetSystemId (const WCHAR *pszSystemId);
����������Sets the system identifier for this input source.
const�WCHAR�* GetSystemId ();
����������Gets the system identifier for this input source.
void SetByteStream (IStream *pByteStream);
����������Sets the byte stream for this input source.
IStream�* GetByteStream ();
����������Gets the byte stream for this input source.
void SetEncoding (const WCHAR *pszEncoding);
����������Sets the character encoding, if known.
const�WCHAR�* GetEncoding ();
����������Gets the character encoding for a byte stream or URI.
void SetCharacterStream (IUnicodeStream *pCharacterStream);
����������Sets the character stream for this input source.
IUnicodeStream�* GetCharacterStream ();
����������Gets the character stream for this input source.

Constructor/Destructor Detail

CInputSource

CInputSource();

Constructs the input source.

This is the zero-argument default constructor.

CInputSource

CInputSource(const WCHAR *pszSystemId);

Constructs the input source with a system identifier.

Applications may use SetPublicId to include a public identifier as well, or SetEncoding to specify the character encoding, if known.

If the system identifier is a URL, it must be fully resolved.

Parameters:
pszSystemId - the system identifier (URI)

CInputSource

CInputSource(IStream *pByteStream);

Constructs the input source with a byte stream.

Application writers may use SetSystemId to provide a base for resolving relative URIs, SetPublicId to include a public identifier, and/or SetEncoding to specify the object's character encoding.

Parameters:
pByteStream - the raw byte stream containing the document

CInputSource

CInputSource(IUnicodeStream *pCharacterStream);

Constructs the input source with a character stream.

Application writers may use SetSystemId to provide a base for resolving relative URIs, and SetPublicId to include a public identifier.

The character stream shall not include a byte order mark.

Parameters:
pCharacterStream - the character stream containing the document

~CInputSource

~CInputSource();

Destroys the input source.

Function Detail

SetPublicId

void SetPublicId(const WCHAR *pszPublicId);

Sets the public identifier for this input source.

The public identifier is always optional: if the application writer includes one, it will be provided as part of the location information.

Parameters:
pszPublicId - the public identifier as a string

GetPublicId

const WCHAR *GetPublicId();

Gets the public identifier for this input source.

Returns:
the public identifier, or the empty string if none was supplied

SetSystemId

void SetSystemId(const WCHAR *pszSystemId);

Sets the system identifier for this input source.

The system identifier is optional if there is a byte stream or a character stream, but it is still useful to provide one, since the application can use it to resolve relative URIs and can include it in error messages and warnings (the reader will attempt to open a connection to the URI only if there is no byte stream or character stream specified).

If the application knows the character encoding of the object pointed to by the system identifier, it can register the encoding using the SetEncoding method.

If the system ID is a URL, it must be fully resolved.

Parameters:
pszSystemId - the system identifier as a string

GetSystemId

const WCHAR *GetSystemId();

Gets the system identifier for this input source.

The GetEncoding method will return the character encoding of the object pointed to, or the empty string if unknown.

If the system ID is a URL, it will be fully resolved.

Returns:
the system identifier

SetByteStream

void SetByteStream(IStream *pByteStream);

Sets the byte stream for this input source.

The SAX reader will ignore this if there is also a character stream specified, but it will use a byte stream in preference to opening a URI connection itself.

If the application knows the character encoding of the byte stream, it should set it with the SetEncoding method.

Parameters:
pByteStream - the byte stream containing the XML document or other entity

GetByteStream

IStream *GetByteStream();

Gets the byte stream for this input source.

The GetEncoding method will return the character encoding for this byte stream, or the empty string if unknown.

Returns:
the byte stream, or NULL if none was supplied

SetEncoding

void SetEncoding(const WCHAR *pszEncoding);

Sets the character encoding, if known.

The encoding must be a string acceptable for an XML encoding declaration (see section 4.3.3 of the XML 1.0 recommendation).

This method has no effect when the application provides a character stream.

Parameters:
pszEncoding - a string describing the character encodin

GetEncoding

const WCHAR *GetEncoding();

Gets the character encoding for a byte stream or URI.

Returns:
the encoding, or the empty string if none was supplied

SetCharacterStream

void SetCharacterStream(IUnicodeStream *pCharacterStream);

Sets the character stream for this input source.

If there is a character stream specified, the SAX reader will ignore any byte stream and will not attempt to open a URI connection to the system identifier.

Parameters:
pCharacterStream - the character stream containing the XML document or other entity

GetCharacterStream

IUnicodeStream *GetCharacterStream();

Gets the character stream for this input source.

Returns:
the character stream, or NULL if none was supplied

Unicorn XML Toolkit
Version 1.50.00


This document was created using Unicorn DOC++.

Copyright 1999-2001 Unicorn Enterprises SA.
All Rights Reserved.