Click here to Skip to main content
12,446,296 members (53,437 online)
Click here to Skip to main content

Stats

50.8K views
838 downloads
33 bookmarked
Posted

Towards a Declarative SAX Framework : Part 1 - A Simple SAX-to-C#-Mapping

, 20 May 2004
This article demonstrates a simple but flexible way to read XML content without DOM
SaxParserSupport
Attributes
App.ico
Attributes.csproj.user
bin
Release
ChildElements
App.ico
bin
Release
ChildElements.csproj.user
Namespaces
App.ico
bin
Release
Namespaces.csproj.user
ParserSetup
App.ico
bin
Release
ParserSetup.csproj.user
SaxParserSupport
bin
Release
SaxParserSupport.csproj.user
Text1
App.ico
bin
Release
Text1.csproj.user
Text2
App.ico
bin
Release
Text2.csproj.user
#region Copyright
/*********************************************************************************
 * Copyright (c) 2004 by Martin Friedrich										 *
 * Permission to freely distribute, modify and compile these sources and		 *
 * binaries as long as this copyright notice is included.						 *
 * Use of code on your risk!													 *
 * *******************************************************************************/
#endregion

using System;

namespace SaxParserSupport
{
	/// <summary>
	/// <p>Defines the API for the root element of a XML content. The root element is
	/// the first element node in the XML content and is at this time identified
	/// with the whole content. I.e. if the XML content is a complete document,
	/// <tt>XMLDocument</tt> is used to represent the information from XML declaration,
	/// entity declarations, etc. up to the actual root element. Speaking DOM-wise,
	/// it is similar to a <tt>System.Xml.XmlDocumentNode</tt> instance.</p>
	/// <p>As of now, only the encoding and version attributes of the XML
	/// declaration are supported. All other attributes and declarations are ignored.</p>
	/// <seealso cref="SaxParserSupport.Impl.XMLDocumentImpl"/>
	/// </summary>
	/// <remarks>
	/// In contrast to all other <tt>XMLSimpleElement</tt> classes, <tt>XMLDocument</tt>
	/// instances are accessed twice during the parsing process. First when the XML
	/// declaration is encountered, that is when the <tt>XmlReader</tt> instance's
	/// <tt>NodeType</tt> property is equal to <tt>System.Xml.XmlNodeType.XmlDeclaration</tt>.
	/// The second time is when the actual root element of the XML content is encountered.
	/// </remarks>
	public interface XMLDocument : XMLElement
	{
		/// <summary>
		/// Returns the encoding of the XML content
		/// </summary>
		/// <returns>The encoding name of the XML content</returns>
		string getEncoding();

		/// <summary>
		/// Sets the encoding name for the XML content. This name is used when the
		/// <tt>XMLDocument</tt> instance is written to a stream.
		/// <seealso cref="System.Text.Encoding"/>
		/// </summary>
		/// <param name="en">A valid name of the encoding in it's <tt>System.Text.Encoding.HeaderName</tt>
		/// form.</param>
		void setEncoding( string en );

		/// <summary>
		/// Sets the XML version of the <tt>XMLDocument</tt> instance.
		/// </summary>
		/// <remarks>
		/// At the moment, at least MSXML doesn't support XML 1.1, 
		/// so the version should always be 1.0
		/// </remarks>
		/// <param name="v">The XML version in string form, i.e. "1.0"</param>
		void setVersion( string v );
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Martin Friedrich
Web Developer
Germany Germany

Still lacking an university degree in computer science, I have 20 years of experience in software development and implementation. Having expert knowledge in object-oriented programming languages like C++, Java and C# on Windows, LINUX and UNIX platforms, I participated in multiple research projects at the University of Oldenburg. During these assignments, I was trusted with implementation of a graphical editor for specification languages like CSP or Z and a prototypical tool for workflow data distribution and analysis. I gained experiences in a widespread spectrum of CS and software development topics, ranging from compiler construction across data base programming to MDA. My research interests include questions of graphical user interface design and component-based systems.

I consider myself an old-school CS geek. While I admit that simple tasks do not pose much of a problem and can be done in quick and efficient manner, it's the challenging ones that appeal to me. If you are looking for a skillful employee - be it on a permanent, contract or freelance basis - and if you can live with a lacking university degree, why not contacting me?


You may also be interested in...

Pro
Pro
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160811.3 | Last Updated 21 May 2004
Article Copyright 2004 by Martin Friedrich
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid