widget:fetch

Purpose

Requests an XML data from an external source and optionally processes it using specified XSL transformation.

Contained by

Attribute groups

Attributes

Attribute Description Type Default Options Use
service A path to the fetch service. It must be specified if the fetch service location is different than the default one, defined in web.xml. xs:anyURl /services/fetch   optional 
src The URL to the XML data source xs:anyURl     required 
transform-cache Specifies if the XSL transformation should be cached xs:boolean true  true, false  optional 
transform-compile Specifies if the XSL template should be compiled xs:boolean true  true, false  optional 
transformation The URL to the XSL stylesheet xs:anyURl     optional 
when Indicates when the client should load the content xs:string onload  onload, defer  optional 

Action

Action Description
execute Executes AJAX request

Properties

Property Description Type Access
src The URL from which the data can be retrieved xs:anyURl read/write 
transformation Defines the URL address of the XSL stylesheet xs:anyURl read/write 

Events

Event Description
failed The event is sent when an AJAX request fails
succeeded The event is sent when an AJAX request succeeds

Examples

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/2002/06/xhtml2"
  xmlns:widget="http://www.volantis.com/xmlns/2006/05/widget">
  <head>
    <title>widget:fetch</title>
  </head>
  <body>
    <widget:block>
      <widget:fetch src="http://xml.weather.yahoo.com/forecastrss?p=AUXX0025&amp;u=c"
        when="onload" transformation="test.xsl"
        service="/projects/client-app/servicefetch/servicefetch"/>
    </widget:block>
  </body>
</html>

The test.xsl transformation must have the following form.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:template match="/">
    <response:response xmlns="http://www.w3.org/2002/06/xhtml2"
      xmlns:response="http://www.volantis.com/xmlns/2006/05/widget/response"
      xmlns:widget="http://www.volantis.com/xmlns/2006/05/widget">
      <response:head/>
      <response:body>
        <widget:block-content>
          <table>
            <tr>
              <td>City: </td>
              <td>
                <xsl:value-of select="//yweather:location@city"/>
              </td>
            </tr>
            <tr>
              <td>Weather: </td>
              <td>
                <xsl:value-of select="//yweather:condition@text"/>, Temp: 
                <xsl:value-of select="//yweather:condition@temp"/>
                <xsl:value-of select="//yweather:units@temperature"/>
              </td>
            </tr>
          </table>
        </widget:block-content>
      </response:body>
    </response:response>
  </xsl:template>
</xsl:stylesheet>

Related topics