I am not an infopath developer and this is my first real encounter with XSLT. Lately i've had to work on a project where i need to convert an infopath form uploaded to Sharepoint into html. Once in html we can use any thirdparty library to spit out any desired/supported format we want.
What We Do In Code:
- We create an XslCompiledTransform object. This is done by parsing the Xsn uploaded to sharepoint and then using the Xsl in there. We use View1.xsl. No issues happen here.
- The Xml form is returned as a stream to our conversion method where we create an XmlDocument that the transform needs to be applied to using a stream.
- We then pass the XmlDocument to the transform() method along with an XmlTextWriter object which populates an StringWriter object for us. We can then use the StringWriter to give us the html as a string or stream and pass it to the thirdparty library to change to any format like PDF/MHT etc...
The Problem That Occurs After Transformation:
- I lose DateFormatting. A date originally setup as 1-12-2009 would become 2009-1-12
- I lose Images, Instead of the images we get empty image placeholders with "X" in them.
- I lose Master Detail sections.
- All html controls come through.I currently convert the htmlstream to a string and have a generic method which filters out any unwanted html. There is also part of my code that filters out selected values in dropdownlists. Doing so i ran into a scenario where there was no "Selected" attribute in the html but a value was selected in thr dropdownlist. THIS WHOLE STRING PARSING IS NOT GRACEFULL, ITS A HACK. Is there a better way to do this?
- How can i detect views if there are multiple views in the XSN File.
- Is there a simpler way of conversion where passing the xml document would suffice, somthing like XmlForm.CurrentView.Export() method to handle my particular scenario.
Any suggestions, pointer etc would be much appreciated. I am happy to send in the original Xml and the converted Html and the Html left after my method cleans it up.
Thanks in advance.
Muhammad.