MS Office Forum / General MS InfoPath Questions / July 2004
After adding a sec. datasource a strange problem occurs
|
|
Thread rating:  |
StefanO-nl - 16 Jul 2004 10:15 GMT After I've added a secondary datasource (which is actually an xslt, but that's beside the point here), I can't open my form anymore, because InfoPath shows me an error about an invalid event handler. That event handler hasn't changed and after removing the secondary datasource, there are no errors, so I'm pretty sure it has something to do with this secondary datasource... But what could be the problem?
StefanO-nl - 16 Jul 2004 11:46 GMT The fact my secondary datasource is an xslt-file, does matter, because of the namespace declaration xmlns:xsl="http://www.w3.org/1999/XSL/Transform"...
Matthew Blain \(Serriform\) - 16 Jul 2004 19:43 GMT That sounds odd. What event handler is InfoPath complaining about? I have a template which has an XSLT and it works fine, though it's pre-SP1. (Yes, it still opens after adding SP-1 features).
Steve, the reason you'd add it as a data connection instead of just a resource is to use GetDOM.
--Matthew Blain http://tips.serriform.com/
> The fact my secondary datasource is an xslt-file, does matter, because of the namespace declaration xmlns:xsl="http://www.w3.org/1999/XSL/Transform"...
Steve van Dongen [MSFT] - 16 Jul 2004 21:34 GMT >Steve, the reason you'd add it as a data connection instead of just a >resource is to use GetDOM. But if all you need is the DOM you don't need all the overhead of a data connection. As the Data Interop SDK sample shows you can load XSLT files added as resources just fine.
objSalesSummaryXSLT = new ActiveXObject("MSXML2.DomDocument.5.0"); objSalesSummaryXSLT.async = false; objSalesSummaryXSLT.load("SalesSummaryByYearTransform.xsl");
Regards, Steve -- Please post questions to the newsgroup; everyone benefits. This posting is provided "AS IS" with no warranties, and confers no rights. Sample code subject to http://www.microsoft.com/info/cpyright.htm
Matthew Blain \(Serriform\) - 16 Jul 2004 22:24 GMT Drifting off topic here, but what's the difference between a data connection to an XML file which is a resource in a template, and creating your own instance of the XML DOM loaded from a resource in the template? Other than the caching being done in a different place? (The data interop example caches the DOM, though I didn't look closely to see at what time.)
> >Steve, the reason you'd add it as a data connection instead of just a > >resource is to use GetDOM. [quoted text clipped - 13 lines] > This posting is provided "AS IS" with no warranties, and confers no rights. > Sample code subject to http://www.microsoft.com/info/cpyright.htm Steve van Dongen [MSFT] - 19 Jul 2004 06:04 GMT >> >Steve, the reason you'd add it as a data connection instead of just a >> >resource is to use GetDOM. [quoted text clipped - 6 lines] >> objSalesSummaryXSLT.async = false; >> objSalesSummaryXSLT.load("SalesSummaryByYearTransform.xsl");
>Drifting off topic here, Ha. You call this off-topic? This is nothing. ;)
>but what's the difference between a data connection >to an XML file which is a resource in a template, and creating your own >instance of the XML DOM loaded from a resource in the template? Other than >the caching being done in a different place? (The data interop example >caches the DOM, though I didn't look closely to see at what time.) I created a new form, saved it, and then tried adding 1 of the 2 XSL files in the Data Interop sample and saved it again. The addition of the XSL caused the addition of 9KB (2KB compressed) worth of XSD files. If I add the second XSL file, I get another 9KB of XSD files. Those 6 additional XSD files will have to be cached.
The manifest.xsf has details on the added XSD files themselves as well as the secondary datasource. Also, because I have SP1, a bunch of junk related to the XSL structure got added to the sampledata.xml file.
Aside from file sizes, there are thing that happen at runtime like the XSL being validated against the schema when it is loaded and (SP1) determining whether to fire change events as the secondary datasource is loaded.
Granted, the performance degradation probably won't amount to much and the increased file size probably won't be noticed by anyone except over a slow link, but it's still more than nothing.
Regards, Steve -- Please post questions to the newsgroup; everyone benefits. This posting is provided "AS IS" with no warranties, and confers no rights. Sample code subject to http://www.microsoft.com/info/cpyright.htm
StefanO-nl - 20 Jul 2004 10:27 GMT "Matthew Blain (Serriform)" <matthewblain@nospam.serriform.com> wrote in message news:eDMDXU2aEHA.1152@TK2MSFTNGP09.phx.gbl...
> That sounds odd. What event handler is InfoPath complaining about? Some OnClick-event of a button...
> I have a > template which has an XSLT and it works fine, though it's pre-SP1. (Yes, it > still opens after adding SP-1 features). Pre-SP1 means script. I also have XSLT working with script code, but I want to use the real stuff and do it in C#...
> Steve, the reason you'd add it as a data connection instead of just a > resource is to use GetDOM. Right. And I thought that was easy, but now I'm getting all kinds of other problems.
I think it has something to do with the fact the namespace(s) of the secondary datasource are copied to the manifest.xsf...
> --Matthew Blain > http://tips.serriform.com/ StefanO-nl stefano AT etx.nl
StefanO-nl - 16 Jul 2004 11:52 GMT http://www.mcse.ms/message510529.html I'm curious how he did it...
> After I've added a secondary datasource (which is actually an xslt, but that's beside the point here), I can't open my form anymore, because InfoPath shows me an error about an invalid event handler. That event handler hasn't changed and after removing the secondary datasource, there are no errors, so I'm pretty sure it has something to do with this secondary datasource... But what could be the problem? Steve van Dongen [MSFT] - 16 Jul 2004 18:05 GMT >> After I've added a secondary datasource (which is actually an xslt, but that's beside the point here), I can't open my form anymore, because InfoPath shows me an error about an invalid event handler. That event handler hasn't changed and after removing the secondary datasource, there are no errors, so I'm pretty sure it has something to do with this secondary datasource... But what could be the problem?
>http://www.mcse.ms/message510529.html >I'm curious how he did it... He added it as a resource, not as a secondary datasource. I don't see any possible reason that an XSLT could/would/should be used as a secondary datasource. Perhaps you could explain what you are trying to accomplish. The Data Interop SDK sample demonstrates transforming data using XSLT resource files.
Regards, Steve -- Please post questions to the newsgroup; everyone benefits. This post is provided "AS IS" with no warranties, and confers no rights Sample code subject to http://www.microsoft.com/info/cpyright.htm
StefanO-nl - 19 Jul 2004 08:36 GMT I'm trying to perform an xslt on my InfoPath-xml, but apparently I have no idea how to access an xslt when it's a resource file... Therefore I tried it by making the xslt a secondary datasource, because then I know I how to retrieve the xslt from the secondary datasource and perform the actual transformation: // First load the InfoPath xml into an XmlDocument XmlDocument infoPathDocument = new XmlDocument(); infoPathDocument.LoadXml(thisXDocument.DOM.xml); // Then load the xslt (in the secondary datasource) into an XmlDocument thisXDocument.DataObjects["myTransformer"].Query(); XmlDocument xsltDocument = new XmlDocument(); xsltDocument.LoadXml(thisXDocument.DataObjects["myTransformer"].DOM.xml); // Load the xslt into the XslTransform-class XslTransform xslt = new XslTransform(); xslt.Load(xsltDocument.CreateNavigator(), new XmlUrlResolver(), this.GetType().Assembly.Evidence); // And finally perform the transformation and write the output to file: using (FileStream fs = new FileStream(@"C:\temp\output.xml", FileMode.Create)) { xslt.Transform(infoPathDocument.CreateNavigator(), null, fs, new XmlUrlResolver()); }
> >> After I've added a secondary datasource (which is actually an xslt, but that's beside the point here), I can't open my form anymore, because InfoPath shows me an error about an invalid event handler. That event handler hasn't changed and after removing the secondary datasource, there are no errors, so I'm pretty sure it has something to do with this secondary datasource... But what could be the problem? > [quoted text clipped - 13 lines] > This post is provided "AS IS" with no warranties, and confers no rights > Sample code subject to http://www.microsoft.com/info/cpyright.htm StefanO-nl - 20 Jul 2004 17:35 GMT Solution for my problem:
// First create a "COM" DOM and load the xslt resource file into that DOM IXMLDOMDocument domDocument = thisXDocument.CreateDOM(); domDocument.load("transform.xslt");
// Create an XmlDocument and load the xml of the DOM. XmlDocument xsltDocument = new XmlDocument(); xsltDocument.LoadXml(domDocument.xml);
// Then load the xml of that DOM into a .Net XmlDocument XmlDocument xsltDocument = new XmlDocument(); xsltDocument.LoadXml(domDocument.xml);
// Load the InfoPath xml into a .Net XmlDocument XmlDocument infoPathDocument = new XmlDocument(); infoPathDocument.LoadXml(thisXDocument.DOM.xml);
// Load the xslt into the XslTransform-class XslTransform xslt = new XslTransform(); xslt.Load(xsltDocument.CreateNavigator(), new XmlUrlResolver(), this.GetType().Assembly.Evidence);
// And finally perform the transformation and write the output to file: using (FileStream fs = new FileStream(@"C:\temp\output.xml", FileMode.Create)) { xslt.Transform(infoPathDocument.CreateNavigator(), null, fs, new XmlUrlResolver()); }
But I still wonder why (in my case) InfoPath can't handle the xslt-file as a secondary datasource and throws strange exceptions... Just for the record: I didn't change anything else in my form or in the xslt-file.
|
|
|