Sun Java System Portal Server 7.1 Developer's Guide

XMLProvider

The XMLProvider can be used to convert and display an XML file according to the specified style sheet.

The XMLProvider first determines if content is available for the requesting client. This is determined by checking on the availability of the XSL stylesheet for the requesting client via the File Lookup API.

The path to the XML content can be specified as HTTP, HTTPs, or file URL. The path to the XML source is stored as a value of the property url. If the path is HTTP or HTTPs, the provider uses the super.getContent() method to fetch the XML content. If the path is a file URL, the provider reads the file into a StringBuffer.

The value for XSL file name to use for transformation is stored as value of the string property xslFileName. The value for the attribute can be either the absolute path (such as /export/home/xsl/abc.xsl) or just the file name. If just the file name has been specified, the provider will use the File Lookup API to locate the XSL file. If the absolute path is specified, it takes precedence and file lookup will not be performed to locate the XSL file.

If both the XML and the XSL files are present, the XMLProvider does the transformation using the XSLT engine. The generated contents are displayed in the channel. In order to transform the XML file, the provider uses JAXP (from JWSDP 1.3).

The XMLProvider:

  1. Takes the fully qualified path name of the XML file and returns the file, specified by the argument, as a StringBuffer.

    It returns null if the file does not exists or cannot be read.

  2. Gets the XSL file. If just an XSL filename has been specified, the getXSL() method locates the XSL file using the File Lookup API.

  3. Takes the XML and XSL files and does the transformation.

  4. Gets the XML contents after converting the XML file according to the specified XSL stylesheet. In order to do this, it takes the HttpServletRequest and returns an HttpServletResponse with the XML file contents as a buffer.

  5. Gets and displays the XML file contents in the channel using the getContent() method.