Creating an XSL Style Sheet for XSQL Files

In JDeveloper, you can create an XSL style sheet that you can apply to your XSQL files in order to format the data for HTML, WML or another output. When you create an XSL style sheet, it is added to the selected XSQL project.

To create an XSL style sheet:

  1. In the Navigator, select the project in which you want to create the new XSL file.
  2. Choose File | New to open the New Gallery.
  3. In the Categories tree, expand General and select XML.
  4. In the Items list, double-click XSL Style Sheet to open the New XSL File dialog.
  5. Leave the Directory Name field unchanged to save your work in the directory where JDeveloper expects to find web application files. In the File Name field, enter the name of the file you want to generate.

    A skeleton XSL file is generated and appears in your active project.

You can edit it in the XML Editor to create your own custom style sheet. An example of an XSL style sheet that transforms XML data into wireless markup language (WML) is provided below. When you are finished, you can specify the style sheet name in your XSQL file to format the raw XML data.

XSL Style Sheet Example

This style sheet demonstrates the conversion of XML to WML. It uses the default DeptView in a BC4J application.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<!-- Root template -->
<xsl:output type="wml" media-type="text/x-wap.wml"
doctype-public="-//WAPFORUM//DTD WML 1.1//EN"
doctype-system="http://www.wapforum.org/DTD/wml_1.1.xml" indent="yes" />

<xsl:template match="*|/"><xsl:apply-templates/></xsl:template>
<xsl:template match="text()|@*"><xsl:value-of select="."/></xsl:template>
<xsl:template match="/">

<wml>
  <card id="C1">
  <p mode="nowrap">
  <big>DEPTLIST</big>
  </p>
  <xsl:for-each select="page/DeptView/DeptViewRow">
  <p>
  <strong><xsl:value-of select="Deptno"/>&nbsp;</strong>
  <xsl:value-of select="Dname"/>&nbsp;
  <xsl:value-of select="Loc"/>
  </p>
  </xsl:for-each>
  </card>
</wml>

</xsl:template>
</xsl:stylesheet>

To see the result of using this style sheet, you can create a new BC4J project based on the DEPT table, create an XSQL page in which you reference this style sheet, and use the (BC4J) ViewObject Action Handler.


Formatting XML Data with a Style Sheet
Creating XSQL Servlet Clients for Business Components
Creating an Action Handler for XSQL