// Copyright 2005 by Omar Al Zabir. All rights are reserved.
//
// If you like this code then feel free to go ahead and use it.
// The only thing I ask is that you don't remove or alter my copyright notice.
//
// Your use of this software is entirely at your own risk. I make no claims or
// warrantees about the reliability or fitness of this code for any particular purpose.
// If you make changes or additions to this code please mark your code as being yours.
//
// website http://www.oazabir.com, email OmarAlZabir@gmail.com, msn oazabir@hotmail.com
using System;
using System.Xml;
using System.IO;
using System.Collections;
using System.Xml.Xsl;
using System.Xml.XPath;
using GotDotNet.Exslt;
namespace RSSFeeder.Helpers{
using RSSCommon;
/// <summary>
/// Transforms Atom Ferd to Rss Feed
/// </summary>
public class AtomToRssConverter
{
private static ExsltTransform _transformer;
public static void Transform( Stream atomStream, Stream rssStream )
{
if( null == _transformer )
{
_transformer = new ExsltTransform();
_transformer.SupportedFunctions = ExsltFunctionNamespace.All;
_transformer.MultiOutput = false;
_transformer.Load(Configuration.Instance.AtomToRssXsl);
}
XPathDocument doc = new XPathDocument( atomStream );
XPathNavigator nav = doc.CreateNavigator();
XmlTextWriter writer = new XmlTextWriter( rssStream, RSSCommon.Constants.DefaultEncoding );
//writer.Namespaces = false;
_transformer.Transform( nav, null, writer );
}
}
}
|