Custom XSL Web capture option

The Custom XSL Web capture option allows developers to create an XSL file that can be used to transform HTML from the target Web site to XML using jTidy.

When selecting Custom XSL as a strategy, a View button appears that allows users to view the “tidied” HTML that will be presented to the XSL. This HTML (which is actually XML, after jTidy has processed it) is then shown in a pop-up window, using IE's standard XML browser. Using this window it is possible to expand/collapse XML nodes and traverse the complete XML (HTML) tree returned. This will make creating the XSL required to map this to an appropriate output easier.

Plenty of resources exist on the Web for writing XSL. Keep in mind the following guidelines:

The following Custom XSL sample returns fixed HTML content regardless of the input HTML.

1:<?xml version="1.0"?> 
2:<!— 
3:     This XSL shows an example that outputs fixed HTML content regardless of 
4:     input HTML 
5:     It also tells the CCL to enable grid rules 
6:  --> 
7:<xsl:stylesheet  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> 
8:  <xsl:template match="/"> 
9:    <xsl:comment> enable_grid_rules=true </xsl:comment>
10:    <table class="ONEPAGE_FEGRID_CAPTURE_TABLE">
11:      <tr>
12:        <td>col1</td><td>Col2</td>
13:      </tr>
14:      <tr>
15:        <td>A</td><td>B</td>
16:      </tr>
17:    </table>
18:  </xsl:template>19:</xsl:stylesheet>

The following Custom XSL sample returns a grid layout.

1:<?xml version="1.0"?> 
2:<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> 
3:  <xsl:template match="/"> 
4:    <data> 
5:      <xsl:comment> enable_grid_rules=true </xsl:comment> 
6:      <xsl:comment> onepage_xml=true </xsl:comment> 
7:      <Record> 
8:        <Field>F1</Field> 
9:        <Field>F2</Field>
10:        <Field>F3</Field>
11:        <Field>F4</Field>
12:      </Record>
13:      <Record>
14:        <Field>R1</Field>
15:        <Field>R2</Field>
16:        <Field>R3</Field>
17:        <Field>R4</Field>
18:      </Record>
19:    </data>
20:  </xsl:template>21:</xsl:stylesheet>

In both examples, notice the use of <xsl:comment> tags to indicate to UA how the output should be treated:

<xsl:comment> enable_grid_rules=true </xsl:comment> <xsl:comment> onepage_xml=true </xsl:comment>

StepsUsing Custom XSL Web capture

  1. In Mobile Web Studio, open the Application Builder, and click Add. The New Web Element window displays.

  2. In Address, enter the Web address, such as http://localhost:4040/index.jsp.

  3. Select Custom XSL from the drop-down list. The “XSL file” field displays.

  4. In “XSL file”, enter the XSL file name.

  5. In the Select window, choose the grid, and click Next.

  6. On the Define and Filter windows, make changes, and click Next.

  7. On the Parameters window, you will see the parameters that were used to reach the report you selected. You can click the select box next to them, and customize as needed.

    Click Next.

  8. On Window Preview, enter a name for the element. Click Finish to save the element.

  9. In Application Builder, follow the normal Save procedure to name your application, specify List/Detail fields, and mark the application for offline use, and so on.