Section 7.10.Generate HTML Output


7.10. Generate HTML Output

If a user does not have InfoPath and he opens a form data file, that file appears as XML in his browser. The InfoPath SDK provides a down-level tool (XDown) to convert a form file's XML to read-only HTML so others can view InfoPath output.


Note: InfoPath forms can only be viewed by users who have InfoPath installed, unless you are using the XDown tool to create an HTML view of the form.

7.10.1. How to do it

To use XDown:

  1. Download and install the InfoPath SDK. By default, the SDK installs XDown in the folder C:\Program Files\Microsoft Office 2003 Developer Resources\Microsoft Office InfoPath 2003 SDK\Tools\XDown.

  2. Copy the files in the XDown folder to the project folder where you are working, or make them otherwise available for use from the command line.

  3. Create a subfolder within the project folder to receive the output of XDown.

  4. Run XDown from the command line on your InfoPath template (.xsn). XDown decompiles the template and converts the views from the template into XSL files that can be used to view form files in HTML.

  5. Add processing instructions to form files that you want non-InfoPath users to be able to view.

For example, the following command line converts the views from Assets.xsn into XSL that can be used to display asset form data; output files are written to the Down subfolder:

    XDown /d assets.xsn Down

You can then use the XSL files written to the Down folder to transform asset form data files into HTML that can be viewed from a browser. The easiest way to do that is to add a processing instruction to the form data file, as shown in the following XML fragment:

    <?xml version="1.0" encoding="UTF-8"?>    <?xml-stylesheet type="text/xsl" href="view_1.xsl"?>    <?mso-infoPathSolution solutionVersion="1.0.0.4" productVersion="11.0.5531"    PIVersion="1.0.0.0" href="http://wombat1/assets.xsn" ?>    <?mso-application prog?>

If you make the preceding addition to a form, users who don't have InfoPath can view the form in Internet Explorer, but users who do have InfoPath (such as yourself) will still see it in InfoPath. To make sure your transformation worked, remove the mso-application instruction:

    <?xml version="1.0" encoding="UTF-8"?>    <?xml-stylesheet type="text/xsl" href="view_1.xsl"?>    <?mso-infoPathSolution solutionVersion="1.0.0.4" productVersion="11.0.5531"     PIVersion="1.0.0.0" href="http://wombat1/assets.xsn" ?>    <?mso-application prog?> 

Now the file will open in the browser, rather than InfoPath.

7.10.2. How it works

XDown generates an XSL file for each of the views in a template. You can use any of those XSL files to display the form data, but if you want to be able to switch between views you will have to write some code to use the different XSL files. See Chapter 3 for more information on how to perform transformations.

Forms displayed using the XDown-generated XSL files omit buttons and other user-interactive controls. They convert other controls, such as text boxes, into read-only HTML.

7.10.3. What about...

To learn aboutLook here
XDown msdn.microsoft.com/library/en-us/ipsdk/html/ipsdkUsingTheDownLevelTool.asp
The InfoPath SDKSearch www.microsoft.com/downloads for "InfoPath SDK"
Perform XSL transformationsChapter 3, "Work With XML"




    Excel 2003 Programming. A Developer's Notebook
    Excel 2003 Programming: A Developers Notebook (Developers Notebook)
    ISBN: 0596007671
    EAN: 2147483647
    Year: 2004
    Pages: 133
    Authors: Jeff Webb

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net