all groups > sql server notification services > december 2006 >
You're in the

sql server notification services

group:

Custom content formatter which extends the XSLT formatter



Custom content formatter which extends the XSLT formatter BigDave
12/8/2006 2:57:59 PM
sql server notification services: Hi all,

We would like to build a custom content formatter which *extends* the
default XSLT formatter. In other words, we want all of the
XSLTFormatter's XML transformation functionality, but in addition, we
want it to make a web service call to generate a report and return its
file path. I'm thinking that it should add the report path as a
name/value to each of its "rawContent" hashtables ... so that the
report paths can be XML-transformed just like any other notification
field.

Has anyone tried to build a custom content formatted by deriving
(subclassing) from the default XSLT formatter? Is this possible, and
did you run into any gotchas? If it's not possible, any alternative
design suggestions?

Thanks very much,
Dave
Re: Custom content formatter which extends the XSLT formatter Joe Webb
12/9/2006 8:57:35 AM
I haven't tried exactly what you're describing, but I've been
considering do exactly that for one of my clients.

In the past, rather than subclassing I've called the XSLT
programmatically. Not sure if this will help you or not, but FWIW here
is the code I used:

{
TextReader textReader = new StringReader(this.GetXmlString(uid, pwd));
XmlTextReader xmlTextReader = new XmlTextReader(textReader);
XPathDocument xPathDocument = new XPathDocument(xmlTextReader);

string fileName = ConfigurationSettings.AppSettings["XsltPath"];
XslTransform xslt = new XslTransform();
xslt.Load(fileName);

StringBuilder sb = new StringBuilder();
TextWriter tw = new StringWriter(sb);

xslt.Transform(xPathDocument,null,tw);

return sb.ToString();
}

HTH...

Joe


--
Joe Webb
SQL Server MVP
http://www.sqlns.com


~~~
Get up to speed quickly with SQLNS
http://www.amazon.com/exec/obidos/tg/detail/-/0972688811

I support PASS, the Professional Association for SQL Server.
(www.sqlpass.org)


[quoted text, click to view]
Re: Custom content formatter which extends the XSLT formatter BigDave
12/11/2006 9:41:47 AM
Much appreciated Joe.

Just to do some playing, I cracked open VS 2005, referenced
microsoft.sqlserver.notificatgionservices; but couldn't find
XsltFormatter in order to derive from it.

So, using your code to do the transformation "ourself" will probably
come in very useful.

Dave
AddThis Social Bookmark Button