471,075 Members | 706 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,075 software developers and data experts.

XslTransform - Receiving 'System.Xml.Xsl.XsltException: Missing mandatory attribute 'version'

KJS
Hello,
I'm receiving:
'System.Xml.Xsl.XsltException: Missing mandatory attribute 'version'
After I try and run my transformation. I spent a good few days coming
up with the appropriate (I think) methods, and overrides for this task.
I have verified that the source XML and XSL will transform by means of
using the MSXML command line parsing tool (previous version of MSXML
though).

Here is my code:

public XmlDocument xslTransformer(XPathNavigator xNav, XsltArgumentList
xArgs)
{
//get xsl source
XslTransform xslObj = new XslTransform();

//default permission set
Evidence ev = XmlSecureResolver.CreateEvidenceForUrl
(classXSLObjectSource);
PermissionSet ps = SecurityManager.ResolvePolicy(ev);

//modify access for specific domain
// WebPermission myWebPermission = new
WebPermission(NetworkAccess.Connect,
// "http://www.example.com");
// myPermissions.SetPermission(myWebPermission);

//wrap with xmlsecureresolver
XmlUrlResolver urlR = new XmlUrlResolver();
XmlSecureResolver xmlSR = new XmlSecureResolver(urlR,ps);
xslObj.Load(xNav,xmlSR,ev);

StringWriter sWrit = new StringWriter();

//transform the xml
xslObj.Transform(xNav,xArgs,sWrit,xmlSR);
XmlDocument xmlREturn = new XmlDocument();
xmlREturn.Load(sWrit.ToString());

return(xmlREturn);
}

Any ideas?
Thanks,
Karl..
Nov 13 '05 #1
2 3592
KJS wrote:
public XmlDocument xslTransformer(XPathNavigator xNav, XsltArgumentList
xArgs)
{
//get xsl source
XslTransform xslObj = new XslTransform();

xslObj.Load(xNav,xmlSR,ev);

//transform the xml
xslObj.Transform(xNav,xArgs,sWrit,xmlSR);


This is weird. You are loading XSLT stylesheet from xNav and then
transform the same XSLT stylesheet? You seems to be havily MSXML minded,
in .NET many things are simpler. Just show me what do you need to
perform and I'll provide .NET solution.

--
Oleg Tkachenko [XML MVP, MCAD]
http://www.XmlLab.Net | http://www.XLinq.Net | http://blog.tkachenko.com
Nov 13 '05 #2
KJS
In article <e6**************@TK2MSFTNGP10.phx.gbl>, so**@body.com
says...
KJS wrote:
public XmlDocument xslTransformer(XPathNavigator xNav, XsltArgumentList
xArgs)
{
//get xsl source
XslTransform xslObj = new XslTransform();

xslObj.Load(xNav,xmlSR,ev);

//transform the xml
xslObj.Transform(xNav,xArgs,sWrit,xmlSR);


This is weird. You are loading XSLT stylesheet from xNav and then
transform the same XSLT stylesheet? You seems to be havily MSXML minded,
in .NET many things are simpler. Just show me what do you need to
perform and I'll provide .NET solution.


I am (was) heavily MSXML minded : )
I was looking for the *simplest* method for transforming XML in .NET (I
understand how to do this very well in the previous versions of MSXML
with classic ASP, VB, etc..)

In .NET I started with the objects: XslTransform, XmlDocument, and
XsltArgumentList.

My XML is supplied from a dataset after querying the database (MySql -
which has some interesting problems by the way, especially dates, but
another topic of course). So, I am providing the XML source from a
dataset (not from file I/O) The XSLT is located local to my application
and is read in accordingly.

I was sure I had everything lined up correctly for this *simple*
transformation, but found that my method calls were "obsolete" and I
should use the "resolver" (XmlUrlResolver) in the load of the stylesheet
and that I should pass "evidence" and WOW! This turned out to be a
nightmare, but I figured it out!!! (so I thought) Now I'm stuck with
this error:

'System.Xml.Xsl.XsltException: Missing mandatory attribute 'version'

Let me summarize the desired operation:
1. Query Database to XML (I use to Save right from recordset in classic
- which I like better, I like the XML better)
2. Transform XML to HTML or to XML
3. I will either stream the result to the Response object (for web) or I
might transform the XML and return XML for something later. For the
most part, will be streaming the result to the browser.

Thanks for the help!
Karl..
Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Paul | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.