Using XMLTextReader to improve XSLT processing
One of the things that I spend a little too much time working on was how to setup a more streamlined version of resolving entities and ignoring entities. The key has to do with avoiding a call to the XMLValidateNavigator object, and using the XMLTextReader gives you more granularity over the process. Here’s an example:
/*=====================================================
* Function/sub: TransformXSLT
* Description: Does the XSLT translation
* ====================================================*/public int TransformXSLT(string sSource,
string sDest,
string sXSLT,
bool bRemote)
{System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(sSource);
if (bRemote==false) {
reader.XmlResolver = null;
} System.Text.UTF8Encoding Encoding = new System.Text.UTF8Encoding(false);
System.IO.StreamWriter writer = new System.IO.StreamWriter(sDest, false, Encoding);
try
{ System.Xml.XPath.XPathDocument doc = new System.Xml.XPath.XPathDocument(reader);
System.Xml.Xsl.XslTransform xslt = new System.Xml.Xsl.XslTransform();
xslt.Load(sXSLT);
xslt.Transform(doc, null, writer, null);
writer.Close();
reader.Close();
} catch (System.Exception eee) {
this.sXSLTError = eee.ToString();
writer.Close();
reader.Close();
return mengine60.ERR_XSLT_ERROR;
}
return 0;
}
–TR
No comments yet.
Leave a comment
Categories
- Access 2006
- ALA Midwinter 2007
- ALA Summer 2007
- Book
- C#
- Code4Lib 2007
- Code4Lib2008
- Conferences
- CONTENTdm
- Cycling
- Digital Libraries
- Dspace
- Education
- Family
- General Computing
- Innovative Interfaces
- Java
- LibraryFind
- MarcEdit
- Microsoft
- NWIUG 2006
- OAI
- OCLC
- Open Library
- OSCON 2006
- Patent Stupidity
- Programming
- rails
- Readex 2006
- ruby
- Running
- Simpsons
- Travel
- Uncategorized
- Wii
- Wikipedia
Archive
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
- August 2006
- July 2006
- June 2006
- May 2006
- April 2006
- March 2006
- February 2006
- January 2006
- December 2005
- November 2005
- October 2005
- September 2005
- August 2005
- July 2005