[Mono-devel-list] Functional XSLT resolved to uri transformation example?
Joshua Tauberer
tauberer at for.net
Tue Dec 14 10:20:36 EST 2004
Jason Starin | Giant Head wrote:
> Does anyone have a functional example of code for Mono that loads an
> xslt, an xml file and then performs the resolved transformation
The basic idea is:
using System.Xml;
using System.Xml.Xsl;
...
XmlDocument xsl = new XmlDocument();
xsl.Load("path/to/stylesheet.xsl");
XslTransform transform = new XslTransform();
transform.Load(xsl);
...
TextWriter textwriter = new StreamWriter(new
FileStream("path/to/output.html", FileMode.Create));
XmlTextWriter writer = new XmlTextWriter(textwriter);
XmlDocument xmlfile = new XmlDocument();
xmlfile.Load("path/to/document.xml");
transform.Transform(xmlfile, null, writer, null);
(and close the writers and streams)
> and outputs to a URI
Don't know what you mean.
> and then can save to a directory
Got that above.
> that has mono as an owner and apache as a group owner?
You can run on the command line:
chown -R username.apache htmlpath
to recursively set the ownership of everything in the htmlpath directory.
> I’m trying to generate a lot of
> static html pages from xml files using a common xslt.
Monodocs2HTML is a slightly complicated example of a program that does
that (beware of wrapping):
http://svn.myrealbox.com/websvn/filedetails.php?repname=Mono%20SVN&path=%2Ftrunk%2Fmonodoc%2Ftools%2Fmonodocs2html.cs&rev=0&sc=0
If you happen to be doing this because you think running XSLT on-line to
power a website would be too slow, it's actually very fast. (Shameless
plug alert.) See: http://taubz.for.net/code/xpd
Good luck.
--
- Joshua Tauberer
http://taubz.for.net
** Nothing Unreal Exists **
More information about the Mono-devel-list
mailing list