Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

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.zip
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>
	/// Defines the base API for XML elements.
	/// </summary>
	public interface XMLSimpleElement
	{
		/// <summary>
		/// Sets the value of the given attribute.
		/// </summary>
		/// <param name="name">The name of the attribute to be set as given in the
		/// XML content</param>
		/// <param name="value">The new value of the attribute as given in the XML
		/// content</param>
		/// <remarks>As of now, property names are matched against possible namespace
		/// alias, not the actual namespaces.</remarks>
		void setAttribute( string name, string value );

		/// <summary>
		/// Returns the <tt>XMLElement</tt> instance repesenting the parent XML element,
		/// if any. It is <tt>null</tt> for instances of <tt>XMLDocument</tt> or if a
		/// <tt>XMLSimpleElement</tt> is removed from it's parent.
		/// </summary>
		/// <returns>The <tt>XMLElement</tt> instance that represents the parent XML element
		/// or <tt>null</tt></returns>
		XMLElement getOwner();

		/// <summary>
		/// Sets the <tt>XMLElement</tt> instance that represents the parent XML element
		/// </summary>
		/// <param name="se">The <tt>XMLElement</tt> instance to set as parent</param>
		void setOwner( XMLElement se );

		/// <summary>
		/// Returns the qualified tag name of the XML element represented by this
		/// <tt>XMLSimpleElement</tt> instance.
		/// </summary>
		/// <returns>The qualified tag name</returns>
		string getName();

		/// <summary>
		/// Sets the tag name of the <tt>XMLSimpleElement</tt> instance
		/// </summary>
		/// <param name="n">The qualified tag name</param>
		void setName( string n );

		/// <summary>
		/// Writes this <tt>XMLSimpleElement</tt> instance to a stream.
		/// </summary>
		/// <remarks>
		/// This method may throw any exception related to stream output
		/// </remarks>
		/// <param name="ostr">The stream to be used for output</param>
		void write( System.IO.StreamWriter ostr );

		/// <summary>
		/// Callback to be executed on encountering the end of the element 
		/// represented by this <i>XMLSimpleElement</i> instance
		/// </summary>
		/// <param name="owner">The <tt>XMLElement</tt> instance being the parent
		/// of this instance. For the root XML element <tt>owner</tt> is 
		/// <tt>null</tt></param>
		void onElementEnd( SaxParserSupport.XMLElement owner );

	}
}

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

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?


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