Print PowerForm - Get all controls list

20/03/2015 11:28

To simplify creating xslt transformation for printing, I created simple xslt to list all controls with values. Then you can create your own custom html layout and simply print control value (e. g. for lbl_Title) using following syntax in xslt file:


<xsl:value-of select="ListItem/Control[@ControlName='lbl_Title']"/>


Input XML:

  <ListItem Caption="">
    <Control ControlName="lbl_Title" ControlType="Label" Visible="True">Company Name</Control>
    <Control ControlName="c_Title" ControlType="TextBox" Visible="True">Alza SK</Control>
    <Control ControlName="lbl_FoundationDate" ControlType="Label" Visible="True">Foundation Date</Control>
    <Control ControlName="c_FoundationDate" ControlType="DatePicker" Visible="True">2015-03-09</Control>
    <Control ControlName="lbl_Product" ControlType="Label" Visible="True">Produkt</Control>
    <Control ControlName="c_Product" ControlType="ComboBox" Visible="True" />
    <Control ControlName="lbl_ProductEN" ControlType="Label" Visible="True">Product</Control>
    <Control ControlName="c_ProductEN" ControlType="ComboBox" Visible="True">Computers</Control>
    <Control ControlName="c_btn_Alert" ControlType="Button" Visible="True">Show information</Control>
    <Control ControlName="lbl_ID" ControlType="Label" Visible="False">ID</Control>
    <Control ControlName="c_ID" ControlType="TextBox" Visible="False">2</Control>
    <Control ControlName="lbl_FileRef" ControlType="Label" Visible="False">URL Path</Control>
    <Control ControlName="c_FileRef" ControlType="TextBox" Visible="False">/sites/powerforms7/Lists/CompaniesLocalization/2_.000</Control>
    <Control ControlName="lbl_FileLeafRef" ControlType="Label" Visible="False">Name</Control>
    <Control ControlName="c_FileLeafRef" ControlType="TextBox" Visible="False">2_.000</Control>
    <Control ControlName="c_hiddenProductSelection" ControlType="TextBox" Visible="False">Computers</Control>
    <Control ControlName="c_hiddenFormHeader0" ControlType="Label" Visible="False">Company information</Control>
  </ListItem>


All controls xslt:

<xsl:stylesheet version="1.0" xmlns:xsl="https://www.w3.org/1999/XSL/Transform">
 <xsl:output method="xml" encoding="utf-8" indent="no"/>
 <xsl:template match="/">
  <table border="1">
   <tr bgcolor="#9acd32">
    <th>Control Name</th>
    <th>Control Type</th>
    <th>Value</th>
   </tr>
   <xsl:for-each select="ListItem/Control">
    <tr>
     <td>
      <xsl:value-of select="@ControlName"/>
     </td>
     <td>
      <xsl:value-of select="@ControlType"/>
     </td>
     <td>
      <xsl:value-of select="."/>
     </td>
    </tr>
   </xsl:for-each>
  </table>
 </xsl:template>
</xsl:stylesheet>


HTML Output:


Seeing this list, we can create simple xslt to display form item, e. g.


<xsl:stylesheet version="1.0" xmlns:xsl="https://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" encoding="utf-8" indent="no"/>
  <xsl:template match="/">
    <style>
      .heading{background-color:#548dd4;font-weight:bold;}
       td {width: 30%;}
    </style>
    <h2>
      <xsl:value-of select="ListItem/Control[@ControlName='c_hiddenFormHeader0']"/>
    </h2>
    <table border="0">
      <tr>
        <td class='heading'>
          <xsl:value-of select="ListItem/Control[@ControlName='lbl_Title']"/>
        </td>
        <td>
          <xsl:value-of select="ListItem/Control[@ControlName='c_Title']"/>
        </td>
      </tr>
      <tr>
        <td class='heading'>
          <xsl:value-of select="ListItem/Control[@ControlName='lbl_FoundationDate']"/>
        </td>
        <td>
          <xsl:value-of select="ListItem/Control[@ControlName='c_FoundationDate']"/>
        </td>
      </tr>
      <tr>
        <td class='heading'>
          <xsl:value-of select="ListItem/Control[@ControlName='lbl_ProductEN']"/>
        </td>
        <td>
          <xsl:value-of select="ListItem/Control[@ControlName='c_ProductEN']"/>
        </td>
      </tr>
    </table>
    <span>
      Item ID: <xsl:value-of select="ListItem/Control[@ControlName='c_ID']"/>
    </span>
  </xsl:template>
</xsl:stylesheet>


with HTML output

Detailed description how to set up xslt file for printing is on link below

www.bpc-components.com/pages/sharepoint/power-forms-silverlight/kb/power-forms-printing/power-forms-xslt-printing