com.sun.portal.providers.xml
Class XMLProvider

java.lang.Object
  extended bycom.sun.portal.providers.ProviderAdapter
      extended bycom.sun.portal.providers.ProfileProviderAdapter
          extended bycom.sun.portal.providers.urlscraper.URLScraperProvider
              extended bycom.sun.portal.providers.xml.XMLProvider
All Implemented Interfaces:
Provider, ProviderEditTypes, ProviderWidths

public class XMLProvider
extends URLScraperProvider

A XML Provider is used to convert and display the XML file according to the specified style sheet.

XMLProvider is an extension of the existing URLScraperProvider. It uses the URLScraperProvider to fetch the XML contents when the url is of type http://url or https://url and if the url is of type file://// , the XMLProvider manually reads the contents of the specified file .

The XMLProvider can transform generic XML content to specific markups using an XSLT engine. It allows creating multiple markup channels from a single XML source (local or over http/https)

XML Provider requires two arguments to do the transformation.

The XMLProvider-based channel has the following configurable attributes:

The path to the XML content can be specified as HTTP,HTTPs or file URL. If the path is HTTP or HTTPs the provider uses URLScraper provider to fetch the contents. If the path is a file URL, the provider reads the file into a StringBuffer.

The value for the XSL filename to use for transformation is stored as a value of the string attribute as indicated above. The user can either specify the complete path (including the file name) or can specify just the file name in which case it will be picked from the default directory. While specifying a value for this property there should not be any use of the protocols like "file://" or "http://" or "https://"

If both the XML file and the XSL file are present, the XMLProvider does the transformation using the XSLT engine. The generated contents are displayed in the channel. In order to do the conversion the XMLProvider uses the JAXP1.1 jar files.

NOTE: getEdit() and  processEdit() methods are not implemented in the XMLProvider.


Field Summary
 
Fields inherited from class com.sun.portal.providers.urlscraper.URLScraperProvider
typeTable
 
Fields inherited from interface com.sun.portal.providers.ProviderWidths
WIDTH_FULL_BOTTOM, WIDTH_FULL_TOP, WIDTH_THICK, WIDTH_THIN
 
Fields inherited from interface com.sun.portal.providers.ProviderEditTypes
EDIT_COMPLETE, EDIT_SUBSET
 
Constructor Summary
XMLProvider()
           
 
Method Summary
 java.lang.StringBuffer getContent(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          
protected  java.lang.String getContentEncodingFromContentBytes(byte[] contentBytes)
          Gets the charset from content This method determines the charset from the XML Header
protected  java.lang.StringBuffer getXML(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          
protected  java.io.File getXSL(java.lang.String xslFileName)
           Gets the XSL file object.
 
Methods inherited from class com.sun.portal.providers.urlscraper.URLScraperProvider
forward, getContentEncoding, getFile, getFileAsBuffer, getHttpContent, getInputEncoding, getRuleSetID, getTimeout, getURL, isPresentable
 
Methods inherited from class com.sun.portal.providers.ProfileProviderAdapter
existsBooleanProperty, existsIntegerProperty, existsListProperty, existsListProperty, existsStringProperty, existsStringProperty, getBooleanProperty, getBooleanProperty, getBooleanProperty, getBooleanProperty, getClientProperty, getIntegerProperty, getIntegerProperty, getIntegerProperty, getIntegerProperty, getListProperty, getListProperty, getMapProperty, getMapProperty, getMapProperty, getMapProperty, getMapProperty, getMapProperty, getStringAttribute, getStringProperty, getStringProperty, getStringProperty, getStringProperty, getStringProperty, getStringProperty, getTemplate, getTemplate, getTemplatePath, isAllowed, setBooleanProperty, setClientProperty, setIntegerProperty, setListProperty, setMapProperty, setStringAttribute, setStringProperty
 
Methods inherited from class com.sun.portal.providers.ProviderAdapter
getContent, getDescription, getEdit, getEdit, getEditType, getHelp, getHelp, getName, getProviderContext, getRefreshTime, getResourceBundle, getResourceBundle, getTitle, getWidth, init, isEditable, isPresentable, processEdit, processEdit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLProvider

public XMLProvider()
Method Detail

getXSL

protected java.io.File getXSL(java.lang.String xslFileName)
                       throws ProviderException

Gets the XSL file object.

Throws:
ProviderException - if the xsl url specified in the storage is not a valid url.

getXML

protected java.lang.StringBuffer getXML(javax.servlet.http.HttpServletRequest req,
                                        javax.servlet.http.HttpServletResponse res)
                                 throws ProviderException

Gets the XML file as a string buffer.

This method calls the getHttpContent in class URLScraperProvider to get the XML file content as a StringBuffer if the XML URL specified is a http or https url.

Parameters:
req - An HttpServletRequest that contains information related to this request for content.
res - An HttpServletResponse that allows the provider to influence the overall response for the desktop page (besides generating the content).
Returns:
the XML file contents as a buffer
Throws:
ProviderException - if the xml URL specified in the storage is not a valid URL.
See Also:
URLScraperProvider.getHttpContent(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String)

getContent

public java.lang.StringBuffer getContent(javax.servlet.http.HttpServletRequest req,
                                         javax.servlet.http.HttpServletResponse res)
                                  throws ProviderException

Gets and displays the XML file contents after converting the xml file according to the specified XSL stylesheet

Specified by:
getContent in interface Provider
Overrides:
getContent in class URLScraperProvider
Parameters:
req - An HttpServletRequest that contains information related to this request for content.
res - An HttpServletResponse that allows the provider to influence the overall response for the desktop page (besides generating the content).
Returns:
Transformed XML contents.
Throws:
ProviderException
See Also:
ProviderException, URLScraperProvider.getHttpContent(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String), URLScraperProvider.getURL()

getContentEncodingFromContentBytes

protected java.lang.String getContentEncodingFromContentBytes(byte[] contentBytes)
Gets the charset from content This method determines the charset from the XML Header

Overrides:
getContentEncodingFromContentBytes in class URLScraperProvider
Parameters:
contentBytes - Bytes from the scraped content
Returns:
String charset or null if charset cannot be determined