Converting exported MSAccess reports for veiwing on the Web. (.NET 2.0)

S

shazam

Hello,
I have a nice little solution currently implemented on a website I have
built. I learned about the ExportXML command that MSAccess has in it
to export a report - when running this one gets 3 files:

1. ASP page to run the report
2. XML containing the data of the report
3. XSL file to transform the XML so it looks almost exactly like the
report in MSAccess.

I was able to take these files and build a framework around it. A user
would see on a webpage the list of availalbe reports, (listed from a
configuration file) selects one and then behind the scenes the xml data
is re-generated in memory and the original XSL outputted from MSAccess
is used to format the data to the client on a webpage.

This is the work horse of the code:

// call our com object (this essentially is the code in the
ASP page
// that is generated from MS Access)
MSXML2.DOMDocument objData = new MSXML2.DOMDocument();
objData.async = false;

// reportXML is an XML String generated previously - it
contains all the data the report needs
objData.loadXML(reportXML);

MSXML2.DOMDocument objStyle = new MSXML2.DOMDocument();
objStyle.async = false;
// reportXSLFileName is the name of the XSL file on the
server (it is married to to the data by way of
// a configuration file)
objStyle.load(Server.MapPath("../reportsmenu/" +
reportXSLFileName));
Session.CodePage = 65001;

Response.ContentType = "text/html";
Response.Write(objData.transformNode(objStyle));

Now all this code works great - no problem but recently I moved to a
..NET 2.0 solution. The code still works but when I post it to my
hosting service - they have a medium trust level implemented so the use
of the XSXML object (COM object) is forbidden as it is unmanaged code.
I figured - great, now I can make it all .NET managed code and have it
work but alas, I am running into problems. This is the code I have
thus far:

System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
// reportXML is an XML String generated previously - it
contains all the data the report needs
doc.LoadXml(reportXML);

System.Xml.Xsl.XsltArgumentList xslArgs = null;
System.Xml.Xsl.XslCompiledTransform xsl = new
System.Xml.Xsl.XslCompiledTransform();
System.Xml.Xsl.XsltSettings xslSettings = new
System.Xml.Xsl.XsltSettings();
xslSettings.EnableScript = true;

System.Xml.XmlUrlResolver resolver = new
System.Xml.XmlUrlResolver();
// ERROR LINE
xsl.Load(Server.MapPath("../reportsmenu/" +
reportXSLFileName), xslSettings, resolver);
// I know that System.Console.Out is not the right thing to
put here...but because the above statment
// wasn't working I haven't given this much thought.
xsl.Transform(doc.CreateNavigator(), xslArgs,
System.Console.Out);

The problem, as noted above, occurs on the xsl.Load method. The Error I
receive is:

'Option' statements must precede any declarations or 'Imports'
statements

I imagine this is a problem with the XSL that is outputted by MSAccess,
specifically the vbscript that is outputted, but I haven't changed that
at all. The XSL is very long so I won't post it here, but I would be
happy to send it out should that be required.
 
6

'69 Camaro

Hi.
I imagine this is a problem with the XSL that is outputted by MSAccess

Unfortunately, the version of Access you are using was never designed to
work with the .Net Framework 2.0. If the files Access outputs conform to
..Net standards, then great. It'll work with no effort on your part. If
they don't conform, then you'll have to modify these files until they
conform to the standards you are now using.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
Blog: http://DataDevilDog.BlogSpot.com
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top