<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type='text/xsl' href='./OpenSocial.xslt' ?>
<?rfc toc="yes"?>
<!DOCTYPE rfc PUBLIC "-//IETF//DTD RFC 2629//EN"
"http://xml.resource.org/authoring/rfc2629.dtd">
<rfc ipr="full3978"
     docName="opensocial-core-gadget-specification-2-5-1"
     xmlns:x="http://purl.org/net/xml2rfc/ext">
 <front>
  <title abbrev="Core-Gadget">OpenSocial Core Gadget Specification 2.5.1</title>
  <author fullname='OpenSocial and Gadgets Specification Group'>
   <address>
    <email>opensocial-and-gadgets-spec@googlegroups.com</email>
   </address>
  </author>
<date month="August" year="2013" />
  <area>General</area>
  <keyword>OpenSocial</keyword>
  <keyword>social networking</keyword>
  <keyword>REST</keyword>
  <keyword>XML</keyword>
  <keyword>Extensible Markup Language</keyword>
  <keyword>JSON</keyword>
  <keyword>JavaScript Object Notation</keyword>
  <keyword>Atom</keyword>
 </front>
 <middle>
  <section title="Notation and Conventions">
   <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
   "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
   document are to be interpreted as described in
   <xref target="RFC2119">RFC2119</xref>.</t>
   <t>Domain name examples use <xref target="RFC2606">RFC2606</xref>.</t>
  </section>
  <section title="Overview">
   <t>Gadgets are web-based software components based on HTML, CSS, and
   JavaScript. They allow developers to easily write useful web applications
   that work anywhere on the web without modification. They are defined using a
   declarative XML syntax that is processed by a gadget server into a format
   that allows them to be embedded into various contexts: standalone web pages,
   web applications, even other gadgets. A context into which a gadget is
   embedded is called a gadget container. The container is responsible for
   managing the gadgets' layout and controls, as well as for supporting various
   functionality on behalf of the gadget. A gadget may be a simple widget, a
   reusable component, or a full-blown application, possibly utilizing or
   communicating with other gadgets.</t>
   <t>This document describes the gadget XML syntax and how it is processed by
   a compliant gadget server. In addition, the document describes the core
   JavaScript APIs that must be made available to every gadget as it is
   rendered. In addition to the core JavaScript APIs, gadget servers SHOULD
   support the recommended features listed at the end of this document.</t>
  </section>
  <section title="Compliance">
   <t>To be a compliant Core Gadget Container, a server MUST be able to satisfy
   the requests defined in this section.</t>
   <section title="Retrieve Content Request" anchor="Retrieval">
    <t>Gadget Containers MUST be able to fetch remote files, such as
    gadget specs, message bundles, CSS files, or images.</t>
     <t>Files SHOULD be retrieved from the source URL that the Developer
     has provided to the Container. Containers MAY fetch equivalent documents
     from alternate sources (such as caches or rewriting services) as long as
     those services are responsible for retrieving the document themselves.</t>
     <t>Containers SHOULD cache the file after fetching it. If the Container caches
     a document, it MUST implement the caching policy as defined by RFC2616.
     Additionally, containers that cache documents SHOULD provide a mechanism to
     bypass the caching policy entirely to facilitate development, such as a
     "nocache" query string parameter passed to the page that the gadget is
     rendered on.  Containers MAY use expired cache entries for files to
     ensure that temporary network problems do not affect end users.</t>
   </section>
   <section title="Parse XML Request" anchor="Parsing">
    <t>XML documents MUST be well-formed, and Containers MUST display an error
    to Users if they are asked to process a malformed document. Containers
    SHOULD provide meaningful error messages to Developers when the
    specification is malformed.</t>
    <t>Containers MUST check for a @specificationVersion attribute in the root
    Module element of all XML documents they parse, and if the attribute is
    present in a document MUST parse and process the document in accordance with
    a version of this specification that matches the attribute's value, as
    described in <xref target="Versioning">Versioning</xref>. Containers SHOULD
    support as many historical specification versions as is practical, for
    backward compatibility with existing Gadgets. If a Container is unable to
    support a specification version that matches the value of a Gadget's
    @specificationVersion attribute, the Container MUST display an error
    message to Users, and SHOULD provide the specification versions that it
    does support to Developers.</t>

    <t>
    <xref target="GadgetXmlSchema">Gadget XML Schema</xref> and the
    <xref target="MessageBundleSchema">Message Bundle Schema</xref> are provided as reference.
    These XSD schemas represent the standard elements and attributes defined in the
    specification body.  Containers are allowed to support additional elements and attributes.
    <xref target="Issue-1142">Discussion</xref>
    </t>
    <t>Containers MAY support non-standard tags and attributes, but they MUST
    be enclosed in a separate XML namespace. This namespace SHOULD reflect the
    name of the organization responsible for the Container to avoid conflicts
    with other Containers. Containers are encouraged to try to find a way to
    work within the base schema whenever possible. Whenever an equivalent
    syntax is introduced into the standard, the Container MUST deprecate the
    proprietary extension and encourage their users to migrate to the
    standardized solution.</t>
    <t>Containers MUST ignore any attributes or tags that they can not
    interpret. This requirement is included to facilitate extensions to the
    schema for Container-specific uses. Containers MAY reject XML documents
    that do not provide all tags and attribute values required by the
    Container, but if they do so they MUST provide feedback to the Developer
    explaining the requirement.</t>
    <t>Containers MUST perform variable substitution according to the rules
    defined in
    <xref target="VariableSubstitution">Variable Substitution</xref>.</t>
    <t>Containers MUST interpret any relative URLs found in XML attributes or
    values as relative to the gadget spec's URL. Containers MAY refuse to use
    or display the content referenced by these URLs at their discretion.</t>
   </section>
   <section title="Gadget Rendering Request" anchor="Rendering">
    <t>A Gadget Container's main function is to translate a Gadget XML file into content to deliver to the end user. A Gadget Rendering Request uses the following inputs:
      <list style="symbols">
       <t>Gadget XML, typically specified as a URL pointing to a file on the web.</t>
       <t>Any User Preferences stored for a User, used in <xref target="VariableSubstitution">Variable Substitution</xref>.</t>
       <t>The View to render, for identifying the correct &lt;Content&gt; element(s) to display.</t>
       <t>The Locale of the User, for <xref target="Localization">Localization</xref>.</t>
       <t>The Module ID of the gadget instance, used in <xref target="VariableSubstitution">Variable Substitution</xref> (Optional).</t>
      </list>
     </t>
     <t>For type="url" gadgets, these inputs are used to generate a URL of content to display to the user as described in <xref target="Type">/Content/@type</xref>.</t>
     <t>For type="html" gadgets, these inputs are used to generate HTML, CSS, and JavaScript as follows:
      <list style="numbers">
       <t>Fetch the gadget XML using a <xref target="Retrieval">Retrieve Content Request</xref>.</t>
       <t>Parse the gadget XML using a <xref target="Parsing">Parse XML Request</xref>, following the behavior defined in <xref target="ElementsAndAttributes">Elements and Attributes</xref>.</t>
       <t>Output gadget content as HTML:</t>
        <list style="numbers">
         <t>Gadget MUST be rendered in HTML5 by default. See section on <xref target="Doctype">Gadget Doctype</xref>. <xref target="Issue-1139">Discussion</xref></t>
         <t>Standard HTML header, opening &lt;html&gt; tag and &lt;body&gt;
         tag. &lt;head&gt; information is optional.</t>
         <t><xref target="CoreFeatures">Core gadgets JavaScript libraries</xref> and any additional libraries specified in the gadget. The server SHOULD consolidate all librariess into a single request to minimize the number of HTTP requests made by the client browser. This MAY be followed by JavaScripte required to initialize the included libraries.</t>
         <t>Results from parsing the Gadget XML file and processing the &lt;Content&gt; sections that match the specified View name.</t>
         <t>A single call to gadgets.util.runOnLoadHandlers().</t>
         <t>Standard HTML closing tags.</t>
        </list>
      </list>
     </t>
     <t>Containers must also be able to process <xref target="DataPipelining">Data Pipelining</xref> and <xref target="OpenSocial-Templating">Templating</xref> elements in the gadget XML spec.</t>
     <section title="Gadget Doctype" anchor="Doctype">
       <t>For Gadgets using an OpenSocial specification version 2.0 or greater, Containers MUST render those Gadgets in HTML5 by default.  If a
       Container supports rendering Gadgets with a specification version less than 2.0, those Gadgets
       SHOULD continue to be rendered in browser quirks mode. Refer to the
       <xref target="Versioning">Versioning</xref> rules for determining Gadget specification version.  Containers MAY support ModulePrefs/@doctype as
       a method for allowing Gadgets to override the default behavior.  Containers that implement this SHOULD override the default doctype when
       encountering ModulePrefs/@doctype.  Developers should recognize it may not be possible to honor this attribute in all cases such as when
       multiple Gadgets are inlined on a single page.  <xref target="Issue-1139">Discussion</xref></t>
     </section>
   </section>
   <section title="JavaScript Request">
    <t>In order for type="url" gadgets to access JavaScript libraries, the server MUST provide an HTTP service for retrieving core and feature-linked JavaScript. This HTTP service MUST handle requests to URLs provided in the 'libs' parameter described in <xref target="Type">/Content/@type</xref>.  The response to these requests MUST contain JavaScript code corresponding to the API(s) required by the type URL gadget.</t>
   </section>
  </section>
   <section title="Elements and Attributes"
            anchor="ElementsAndAttributes">
    <t>The following XML elements and attributes MUST be supported by the
    Container.
    Additional elements and attributes MAY be supported, but these elements are
    beyond the scope of this document. <xref target="Issue-1179">Discussion</xref></t>

<t>A Container MAY support a simplified XML schema.  This format changes some core elements to optional
and uses the canonical format for templates and data pipeline blocks. <xref target="Issue-1162">Discussion</xref>  </t>

   <section title="Module"
            anchor="Module">
    <t>The root node of a gadget XML specification is the Module element.</t>
    <list style="hanging">
     <t hangText="@specificationVersion">The version of the OpenSocial
     specification that container MUST use to interpret the gadget, as described
     in <xref target="Versioning">Versioning</xref>. If absent, the default
     value is "1.0".</t>

     <t hangText="text()">This tag has child elements. Containers SHOULD NOT
     interpret child text nodes.</t>
    </list>
    <section title="/ModulePrefs"
             anchor="ModulePrefs">
     <t>Serves as a container element for all Metadata, Features, and
     processing rules. For nested element descriptions, see their individual
     sections of this document.</t>
     <list style="hanging">
      <t hangText="@title">The gadget's title. Containers SHOULD use this value
      in any situation where a title bar or other identifying name for the
      gadget is required.</t>
      <t hangText="@title_url">Containers SHOULD use this value to provide a
      link target wherever @title is displayed.</t>
      <t hangText="@description">A verbose description of the gadget.
      Containers SHOULD use this value to provide a description of the gadget
      in any Directory.</t>
      <t hangText="@author">The name of the author of this gadget. Containers
      SHOULD display this value in any Directory.</t>
      <t hangText="@author_email">An email address to use as a point of contact
      for the author of the gadget. Containers MAY display this value on any
      Directory.</t>
      
	<t hangText="@screenshot"> <x:deprecated href="#Previews" use='/ModulePrefs/Link/@rel="preview"'> Optional. A string that gives the URL of a gadget
		screenshot. This must be an image on a public web site that is not
		blocked by robots.txt. PNG is the preferred format, though GIF and JPG
		are also acceptable. Gadget screenshots should be 280 pixels wide. The
		height of the screenshot should be the "natural" height of the gadget
		when it's in use. Containers SHOULD display this image on Directory
		pages to provide a preview of the gadget to Users. </x:deprecated></t>
    
	<t hangText="@thumbnail">
		Optional. A string that gives the URL of a gadget thumbnail. This must
		be an image on a public web site that is not blocked by robots.txt.
		PNG is the preferred format, though GIF and JPG are also acceptable.
		Gadget thumbnails should be 120x60 pixels. This
		SHOULD be smaller than @screenshot and larger than any
      <xref target="Icons">/ModulePrefs/Link/@rel="icon"</xref>elements.</t>
      <t hangText="@height">The preferred default height of the gadget, in
      pixels. Containers SHOULD use this value to set an appropriate height for
      the gadget when it is first rendered.</t>
      <t hangText="@width">The preferred default width of the gadget, in pixels.
      Containers SHOULD use this value to set an appropriate width for the
      gadget when it is first rendered.</t>
      <t hangText="@doctype">Optional.
      A string that identifies the preferred rendering method.  When set to "quirksmode", the Gadget SHOULD be rendered in browser quirks mode.
      This attribute can later be extended to support other DOCTYPEs. <xref target="Issue-1139">Discussion</xref></t>
      <t hangText="text()">This tag has child elements. Containers SHOULD NOT
      interpret child text nodes.</t>
     </list>
     <section title="/ModulePrefs/Require and /ModulePrefs/Optional"
              anchor="RequireAndOptional">
      <t>Declares Feature dependencies of the gadget.</t>
      <list style="hanging">
       <t hangText="@feature">The name of the Feature.</t>
       <t hangText="@version">The version of the Feature to provide. Containers
       MUST interpret this value as described in
       <xref target="Versioning">Versioning</xref>. If absent, the default value is
       "1.0".</t>
       <t hangText="@views">A comma-separated list of Views to load this feature
       for.  This parameter is optional. Containers SHOULD only load the feature
       when an appropriate view is being rendered. <xref target="Issue-1133">Discussion</xref></t>
       <t hangText="text()">This tag has child elements. Containers SHOULD NOT
       interpret child text nodes.</t>
      </list>
   <t>A Feature is a set of processing instructions and JavaScript libraries
   that provides some specific functionality for a Gadget.</t>
   <t>Containers MUST honor the feature-specific rules for any Feature that
   they claim to support. Any Feature not specified in this document SHOULD
   provide an external specification for processing so that implementations
   will be correct.</t>
   <t>Containers MUST provide an implementation of each Feature that matches
   the version specified by the Gadget in the /ModulePrefs/Required/@version or
   /ModulePrefs/Optional/@version attribute, applying the matching process
   described in <xref target="Versioning">Versioning</xref>. Containers MUST NOT
   substitute versions of Features that do not match the versions requested by
   the Gadget. Containers SHOULD support as many versions of each Feature as is
   practical, for backward compatibility with existing Gadgets. Containers MAY
   use the same implementation to satisfy several different versions of a
   Feature, if by doing so they fully comply with the Feature's
   specification.</t>


   <list style="hanging">
    <t hangText="Feature Version Conflicts" anchor="FeatureVersionConflicts">
      <t>Containers MAY refuse to support Features or specific versions of Features
		   that are known or assumed to be incompatible with the specification version
		   required by the Gadget, or that are known to be incompatible with other
		   Features or versions of Features required by the Gadget. For example, a
		   Container MAY not support the combination of @specificationVersion="1.0"
		   and &lt;Require feature="opensocial" version="2.0"&gt;, or the combination
		   of &lt;Require feature="opensocial" version="1.0"&gt; and
		   &lt;Require feature="opensocial-data" version="1.1"&gt;. In cases where such
		   combinations are requested, the Features are said to be conflicting.
		   Conflicting Features SHOULD be treated by Containers as if they were
		   unsupported. Containers SHOULD provide an error message describing conflicts
		   to Developers when a conflict is detected.  If one or more of the conflicting
		   Features is specified as Optional by a Gadget, and the set of Required
		   features and specification version do not conflict, Containers SHOULD attempt
		   to render the Gadget by removing the conflicting optional Features, returning
		   false from
		   <xref target="gadgets.util.hasFeature">gadgets.util.hasFeature</xref>
		   for the features that have been removed.  Containers SHOULD include the
		   largest set of Optional Features that does not produce conflicts.</t>
    </t>
    <t>It is possible for there to be Feature version conflicts when two valid
       Feature dependencies exist for the same Feature.  This situation can occur
       when the same Feature is declared at a global scope (no @views specified)
       and at a view scope (@views specified) but with differing @version values.
       For example, if we are rendering a Gadget's "default" view and with
       &lt;Require feature="myfeature" version="1"&gt; and
       &lt;Require feature="myfeature" version="2" views="default"&gt; declared.
       In these cases, Containers SHOULD use the Feature version from the Feature
       declaration that explicitly matches the current View (See
       /ModulePrefs/Required/@views and /ModulePrefs/Optional/@views) over other
       Feature declarations. Developers can easily correct this conflict by always
       using the @views attribute for Features in Gadgets that use mixed Feature
       versions. <xref target="Issue-1133">Discussion</xref></t>
   </list>


   <t>Containers MUST display an error message for any feature that is
   requested by the Gadget as "required" but is not supported by the container.</t>
   <t>Containers MUST only return true for
   <xref target="gadgets.util.hasFeature">gadgets.util.hasFeature</xref> if they
   actually support the given feature name at the version specified in the
   Gadget XML. Containers MAY only return true for this function if the feature
   was also requested in the Gadget spec.</t>
   <list style="hanging">
     <t hangText="Core Features" anchor="CoreFeatures">
      <t>In addition to explicitly requested features, there is one implicit
      feature (referred to as "core") that is always present in every Gadget.
      This "core" feature MUST make the following JavaScript libraries available
      to Gadgets at runtime without any additional requirements:</t>
      <list style="symbols">
       <t>
        <xref target="gadgets.io">gadgets.io</xref>
       </t>
       <t>
        <xref target="gadgets.util">gadgets.util</xref>
       </t>
       <t>
        <xref target="gadgets.Prefs">gadgets.Prefs</xref>
       </t>
       <t>
        <xref target="gadgets.json">gadgets.json</xref>
       </t>
      </list>
      <t>Gadgets may specify a particular version of the core Feature by including
      a /ModulePrefs/Require element with @feature="core" and the @version
      attribute specifying the required version. If an explicit version of the
      core Feature is not specified, Containers MUST provide a version matching
      the /@specificationVersion attribute of the Gadget, if present, or matching
      "1.0" if /@specificationVersion is absent.</t>
      </t>
     <t hangText="Optional Features" anchor="OptionalFeatures">
      <t>Containers claiming support for the following Features MUST provide the
      Gadget with the JavaScript library from the table below. See the JavaScript
      documentation for each feature for any additional requirements. Containers
        SHOULD support as many of these features as possible.</t>
        <texttable align="left">
         <ttcol>Feature name</ttcol>
        <ttcol>Feature version</ttcol>
         <ttcol>JavaScript library</ttcol>
         <c>rpc</c>
        <c>1.0.0</c>
         <c>
          <xref target="gadgets.rpc">gadgets.rpc</xref>
         </c>
         <c>flash</c>
        <c>1.0.0</c>
         <c>
          <xref target="gadgets.flash">gadgets.flash</xref>
         </c>
         <c>skins</c>
        <c>1.0.0</c>
         <c>
          <xref target="gadgets.skins">gadgets.skins</xref>
         </c>
         <c>dynamic-height</c>
        <c>1.0.0</c>
         <c>
         <xref target="gadgets.window.adjustHeight">
         gadgets.window.adjustHeight</xref>and
         <xref target="gadgets.window.getViewportDimensions">
         gadgets.window.getViewportDimensions</xref></c>
         <c>settitle</c>
        <c>1.0.0</c>
         <c>
          <xref target="gadgets.window.setTitle">gadgets.window.setTitle</xref>
         </c>
         <c>minimessage</c>
        <c>1.0.0</c>
         <c>
          <xref target="gadgets.MiniMessage">gadgets.MiniMessage</xref>
         </c>
         <c>tabs</c>
        <c>1.0.0</c>
         <c>
          <xref target="gadgets.Tab">gadgets.Tab</xref>
         </c>
      </texttable>
     </t>
   </list>
      <section title="/ModulePrefs/Require/Param and /ModulePrefs/Optional/Param">
       <t>Provides configuration parameters for a Feature. Containers MUST
       populate these values in
       <xref target="gadgets.util.getFeatureParameters">
       gadgets.util.getFeatureParameters</xref>, with @name representing the
       key, and the child text node representing the value. Containers SHOULD
       select configuration parameters from the Feature that explicitly matches
       the current View (See /ModulePrefs/Required/@views and
       /ModulePrefs/Optional/@views) over other Feature declarations. <xref target="Issue-1133">Discussion</xref></t>
       <list style="hanging">
        <t hangText="@name">The name of the parameter. Containers MUST use this
        as the key for inputs to
        <xref target="gadgets.util.getFeatureParameters">
        gadgets.util.getFeatureParameters</xref>.</t>
        <t hangText="text()">The value for the parameter. Containers MUST use
        this as the value returned when a matching key is found in
        <xref target="gadgets.util.getFeatureParameters">
        gadgets.util.getFeatureParameters</xref>.</t>
       </list>
      </section>
     </section>
     <section title="/ModulePrefs/Preload" anchor="Preload">
      <t>An HTTP request to pre-fetch. Containers SHOULD pre-fetch all HTTP resources specified by
   /ModulePrefs/Preload elements.</t>
      <list style="hanging">
       <t hangText="@href">The URL of the request to prefetch.</t>
       <t hangText="@authz">The authentication type to use for making this
       request. Valid values are the same as for
       <xref target="gadgets.io.AuthorizationType">
       gadgets.io.AuthorizationType</xref>, though the names are converted to
       lower case to appear more natural in XML.</t>
       <t hangText="@sign_owner">Indicates that the Owner should be passed to
       endpoints when using an authentication type that requires it. Containers
       MUST pass the owner id when this value is "true" (default).</t>
       <t hangText="@sign_viewer">Indicates that the Viewer should be passed to
       endpoints when using an authentication type that requires it. Containers
       MUST pass the viewer id when this value is "true" (default).</t>
       <t hangText="@views">A comma-separated list of Views to pre-fetch this
       request for.  This parameter is optional. <xref target="Issue-1133">Discussion</xref> Containers SHOULD only perform
       preloading when an appropriate view is being rendered.</t>
       <t hangText="text()">Not used at this time.</t>
      </list>
   <t>When honoring the preloading mechanism,
   Containers MUST convert the results of the prefetching operation into a
   temporary object that is stored and accessed at runtime via
   <xref target="gadgets.io.makeRequest">gadgets.io.makeRequest</xref>.
   Containers MUST only consider a makeRequest call to map to a Preload when
   all of the following conditions are met:
   <t>/ModulePrefs/Preload/@href matches the "url" parameter of
   <xref target="gadgets.io.makeRequest">gadgets.io.makeRequest</xref>.</t>
   <t>/ModulePrefs/Preload/@authz matches one of the valid parameters for
   <xref target="gadgets.io.AuthorizationType">
   gadgets.io.AuthorizationType</xref>, converted to lower case.</t>
   <t>/ModulePrefs/Preload/@sign_owner matches the value passed for
   <xref target="gadgets.io.RequestParameters.SIGN_OWNER">
   gadgets.io.RequestParameters.SIGN_OWNER</xref></t>
   <t>/ModulePrefs/Preload/@sign_viewer matches the value passed for
   <xref target="gadgets.io.RequestParameters.SIGN_VIEWER">
   gadgets.io.RequestParameters.SIGN_VIEWER</xref></t>
   <t>/ModulePrefs/Preload/@views matches the current view (the views attribute
   is a comma-separated list of matching views).</t></t>
     </section>
     <section title="/ModulePrefs/Icon"
              anchor="Icon">
      <x:deprecated href="#Icons" use='/ModulePrefs/Link/@rel="icon"'>
        <t>A link or embedded image that serves as an icon for the gadget.</t>
        <list style="hanging">
         <t hangText="@mode">The encoding used for the icon when embedding an
         image in the Icon element's child text node. Currently, only 'base64' is
         the only supported value. Containers SHOULD treat child text nodes as a
         base64 encoded image when this attribute is provided. Otherwise, child
         text nodes should be interpreted as an image URL.</t>
         <t hangText="@type">The MIME type of the embedded icon text. Containers
         SHOULD interpret the encoded child text node using this MIME type.</t>
         <t hangText="text()">Developers MUST provide a value for the child text
         node appropriate to the @mode value. If @mode is "base64", the child
         text node MUST be a base64-encoded image in the format specified by
         @type. If @mode is missing, the child text node MUST be a valid URL
         pointing to an image file.</t>
        </list>
      </x:deprecated>
     </section>
     <section title="/ModulePrefs/Locale" anchor="Locale">
      <t>Provides localization information. Containers MUST honor localization
      rules as specified in
      <xref target="Localization">Localization</xref>. Each Locale tag
      represents localization information for a single locale.</t>
      <list style="hanging">
       <t hangText="@lang">The language for this locale. Containers MUST
       interpret this as an ISO-639-1 language code, or the special (default)
       value "all", which Containers MUST interpret as applying to all
       languages, unless a more specific match is found.</t>
       <t hangText="@country">The language for this locale. Containers MUST
       interpret this as an ISO-3166-1 country code, or the special (default)
       value "all", which Containers MUST interpret as applying to all
       countries unless a more specific match is found.</t>
       <t hangText="@messages">A URL pointing to an XML document that contains
       nested
       <xref target="msg">/ModulePrefs/Locale/msg</xref>elements.
	   The XML document should follow the format shown in
	   <xref target="MessageBundles">MessageBundles</xref>.
	   Containers MUST honor
       <xref target="Retrieval">Retrieval</xref>and
       <xref target="Parsing">Parsing</xref>rules for these files. Containers
       MUST treat all child elements of the root XML element in the document as
       though they are child nodes of /ModulePrefs/Locale</t>
       <t hangText="@language_direction">Specifies the direction to render the
       gadget in. Valid values are "rtl" (right to left) and "ltr" (left to
       right). Containers SHOULD use this value for determining the appropriate
       rendering direction for gadget content in this locale. This value
       controls language direction variables in <xref target="Localization">Localization</xref>.</t>
       <t hangText="@views">A comma-separated list of Views for this
       locale.  This parameter is optional.  Containers SHOULD only select
       this locale when an appropriate view is being rendered. <xref target="Issue-1133">Discussion</xref></t>
       <t hangText="text()">This tag has child elements. Containers SHOULD NOT
       interpret child text nodes.</t>
      </list>
      <section title="/ModulePrefs/Locale/msg"
               anchor="msg">
       <t>A single localized value, keyed by @name, with the value coming from
       text().</t>
       <list style="hanging">
        <t hangText="@name">The name of the localized message. The Container
        MUST use this as the key for the JavaScript API method
        <xref target="gadgets.Prefs.getMsg">gadgets.Prefs.getMsg</xref>and for
        MSG substitutions (see
        <xref target="Localization">Localization</xref>).</t>
        <t hangText="text()">The value of the message. Containers MUST
        substitute this value for @name according to
        <xref target="Localization">Localization</xref>rules, and provide this
        value for any key matching @name in
        <xref target="gadgets.Prefs.getMsg">gadgets.Prefs.getMsg</xref>.</t>
       </list>
      </section>
     </section>
     <section title="/ModulePrefs/Link"
              anchor="Link">
   <t>Gadgets MAY specify any number of
   <xref target="Link">/ModulePrefs/Link</xref>elements, which the Container
   SHOULD process according to rules specific to the value of
   /ModulePrefs/Link/@rel. Containers MAY support additional links, but they
   should pick an appropriate namespace for the rel attribute so as to not
   conflict with the standard. Containers MUST NOT support non-standard rel
   attributes with any of the following prefixes: "opensocial", "gadgets", or
   "events".</t>
      <list style="hanging">
       <t hangText="@rel">The relationship between this link and the document.
       Valid values are specified in
       <xref target="LifeCycleEvents">Life Cycle Events</xref>,
       <xref target="Icons">Icons</xref>,  
       <x:incubating href="http://code.google.com/p/opensocial-resources/issues/detail?id=1283" 
                note="Issue 1283:  Add additional fields to the module section to support use in market places">
       <xref target="License">License</xref>,
       <xref target="TermsOfService">Terms of Service</xref>,  
       <xref target="PrivacyPolicy">Privacy Policy</xref> and <xref target="Previews">Previews</xref>. 
       </x:incubating>
       Containers MAY support additional
       values, but they MUST be namespaced to avoid collisions.</t>
       <t hangText="@href">The URL of the link.</t>
       <t hangText="text()">Not used at this time.</t>
      </list>
   <section title="Icons"
            anchor="Icons">
    <t>
	OpenSocial defines three icon sizes. The reason for keeping them
	distinct is so that the container may choose to optimize downloading
	only one. For example a mobile device may only need "icon", where an
	application market listing may need all three. </t>
    <t>When the value for /ModulePrefs/Link/@rel is "icon", "mediumIcon", or "largeIcon", Containers
    SHOULD treat the link as a reference to an image that represents an
    application icon for the Gadget. This is preferred over using
    <xref target="Icon">/ModulePrefs/Icon</xref>, which is deprecated.</t>
   </section>
   <section title="Gadget Lifecycle Events"
            anchor="LifeCycleEvents">
<xref target="Issue-1154">Discussion</xref>
       <t>There are multiple parties interested in gadget lifecycle events.  Gadget lifecycle event notifications
        could be contained within the browser or transmitted over the web. The gadget specification
        provides a mechanism for generating web notifications about important lifecycle events.
        Such events include installs, uninstalls, rate limiting, directory listing changes, and
        blacklist/whitelist notifications. The <xref target='Link'>Link</xref> element allows
        developers to specify URLs that the container will send data to when certain events are triggered.
       </t>
       <t>Whenever an "event" (such as installing or removing an application)
    occurs on a Container, and the Gadget has specified a value for a matching
    event name (either as the catch-all "events", or a specific event, named
    "event.eventtype", the Container MUST make an HTTP request to the specified
    URL.</t>
    <t>If the rel attribute matches
     "opensocialevent.TYPE", then events of TYPE are sent to that endpoint. An
     optional method attribute can be set to POST or GET to specify how the
     request should be sent. The default is GET.
     <figure>
      <preamble>Here are some examples:</preamble>
      <artwork xml:space="preserve">
&lt;Link rel="event" href="http://www.example.com/pingme" method="POST/&gt;
&lt;Link rel="event.addapp" href="http://www.example.com/add" /&gt;
&lt;Link rel="event.removeapp" href="http://www.example.com/remove" /&gt;
</artwork>
     </figure></t>


    <t>The request sent to the specified endpoint MUST be signed according to
    the rules in
    <xref target="SignedFetch">Signed Fetch</xref>. Additionally, one extra
    parameter named "eventtype" MUST be passed. This value MUST be the same as
    the event name part of the 'rel' attribute.</t>

     <t>The following event types are defined. Container custom events should
     be designated with a domainname prefix to avoid namespace collisions.
     <texttable>
      <ttcol align="left">Event</ttcol>
      <ttcol align="left">Description</ttcol>
      <c>addapp</c>
      <c>Event used to indicate the user has added the application. </c>
      <c>removeapp</c>
      <c>Event used to indicate the user has removed the application. </c>
      <c>app</c>
      <c>This event indicates that an action has been performed on the app. Note that this action may not have been caused by an action performed by the end user of an application.
      For example, it is permissible for an application directory or market place to send these events. In the case of an app event an action attribute MUST be included and valid values
      are "enabled", "disabled", "approved", "submitted", "rejected", "new" and "banned". </c>
     </texttable></t>
   </section>
<x:incubating href="http://code.google.com/p/opensocial-resources/issues/detail?id=1283" 
        note="Issue 1283:  Add additional fields to the module section to support use in market places">
	<section title="License" anchor="License">
		<t>When the value for /ModulePrefs/Link/@rel is "license", Containers
			SHOULD treat the link as a reference to a document that represents
		  the license for the service that is provided by the application.
      <xref target="Issue-1283">Discussion</xref>
		</t>
	</section>
	<section title="Privacy Policy" anchor="PrivacyPolicy">
		<t>When the value for /ModulePrefs/Link/@rel is "privacy-policy",
			Containers
			SHOULD treat the link as a reference to a document that represents the
			privacy policy for the service that is provided by the application.
      <xref target="Issue-1283">Discussion</xref>
		</t>
	</section>
  <section title="Terms of Service" anchor="TermsOfService">
    <t>When the value for /ModulePrefs/Link/@rel is "terms-of-service",
      Containers
      SHOULD treat the link as a reference to a document that represents is the
      terms of service for the service that is provided by the application.
      <xref target="Issue-1283">Discussion</xref>
    </t>
  </section>
   <section title="Previews"
            anchor="Previews">
       <t>
	It is RECOMMENDED that previews be available on a public Web site.  However,
	considering OpenSocial's growing use behing firewalls it is not
	necessary for this to be publicly addressible. PNG is the preferred
	format, though GIF and JPG
	are also acceptable. Gadget previews SHOULD be 280 pixels wide. The
	height of the preview can vary so that a screenshot can be scaled appropriately. Containers SHOULD display this image on Directory
	pages to provide a preview of the gadget to Users.</t>
	<t>
	When the value for /ModulePrefs/Link/@rel is "preview", Containers
	SHOULD treat the link as a reference to an image that represents a
	screenshot for the Gadget. Additional values of "preview1",
	"preview2", "preview3","preview4", and "preview5" are also
	valid. <xref target="Issue-1283">Discussion</xref></t>
	</section> 
</x:incubating>
 </section>


     <section title="/ModulePrefs/OAuth"
              anchor="OAuthElement">
      <t>Supplies the Container with OAuth service configuration for the
      gadget. For details, see
      <xref target="OAuth">OAuth</xref>. This tag has no attributes and has
      child elements. Containers SHOULD NOT interpret child text nodes.</t>
      <section title="/ModulePrefs/OAuth/Service">
       <t>A single OAuth service configuration.</t>
       <list style="hanging">
        <t hangText="@name">The name of the service, used for referencing OAuth
        services at runtime. This parameter is optional, and if unspecified
        defaults to an empty string. Gadget developers specify which OAuth
        service they wish to use by passing the service name as a parameter to
        <xref target="gadgets.io.makeRequest">
        gadgets.io.makeRequest</xref>.</t>
        <t hangText="text()">Not used at this time.</t>
       </list>
       <section title="/ModulePrefs/OAuth/Service/Request">
        <t>Represents the OAuth request token URL. See
        <xref target="OAuth">OAuth</xref>for details.</t>
        <list style="hanging">
         <t hangText="@url">The URL for the endpoint.</t>
         <t hangText="@method">The HTTP verb to use for making the request.
         Containers MUST use this HTTP method when sending the request to the
         service URL. This parameter is optional. If unspecified, it defaults
         to POST.</t>
         <t hangText="@param_location">One of 3 possible locations in the
         request to the service where the OAuth parameters may be passed.
         Developers MAY use this value to specify the location of OAuth-related
         parameters. The possible values are "uri-query", "auth-header", and
         "post-body", corresponding to the options described in
         <xref target="OAuth-Core">Section 5.2 of the OAuth
         specification</xref>. The default value is "auth-header".</t>
         <t hangText="text()">Not used at this time.</t>
        </list>
       </section>
       <section title="/ModulePrefs/OAuth/Service/Access">
        <t>Represents the OAuth access token URLs. See
        <xref target="OAuth">OAuth</xref>for details.</t>
        <list style="hanging">
         <t hangText="@url">The URL for the endpoint.</t>
         <t hangText="@method">The HTTP verb to use for making the request.
         Containers MUST use this HTTP method when sending the request to the
         service URL. This parameter is OPTIONAL. If unspecified, it defaults
         to POST.</t>
         <t hangText="@param_location">One of 3 possible locations in the
         request to the service where the OAuth parameters may be passed.
         Developers MAY use this value to specify the location of OAuth-related
         parameters. The possible values are "uri-query", "auth-header", and
         "post-body", corresponding to the options described in
         <xref target="OAuth-Core">Section 5.2 of the OAuth
         specification</xref>. The default value is "auth-header".</t>
         <t hangText="text()">Not used at this time.</t>
        </list>
       </section>
       <section title="/ModulePrefs/OAuth/Service/Authorization"
                anchor="Authorization">
        <t>The OAuth authorization URL. For details, see
        <xref target="OAuth-Core">Section 6.2 of OAuth
        specification</xref>.</t>
       </section>
      </section>
     </section>
    
       
     <section title="/ModulePrefs/OAuth2"
              anchor="OAuth2Element">
      <xref target='Issue-1209'>Discussion</xref>
      <t>Supplies the Container with OAuth 2.0 service configuration for the
      gadget. For details, see
      <xref target="OAuth">OAuth</xref>. This tag has no attributes and has
      child elements. Containers SHOULD NOT interpret child text nodes.</t>
      <section title="/ModulePrefs/OAuth2/Service">
       <t>A single OAuth 2.0 service configuration.</t>
       <list style="hanging">
        <t hangText="@name">The name of the service, used for referencing OAuth 2.0
        services at runtime. This parameter is optional, and if unspecified
        defaults to an empty string. Gadget developers specify which OAuth 2.0
        service they wish to use by passing the service name as a parameter to
        <xref target="gadgets.io.makeRequest">
        gadgets.io.makeRequest</xref>.</t>
        <t hangText="@scope">The value of the OAuth 2.0 scope parameter to be used by default
        in requests.  This value is superseded when
        <xref target="gadgets.io.RequestParameters.OAUTH2_SCOPE">
        gadgets.io.RequestParameters.OAUTH2_SCOPE</xref> is used.
        Access Token Scope is defined in Section 3.3 of the
        <xref target='draft-ietf-oauth-v2-22'>OAuth 2.0</xref> specification.
        This parameter is OPTIONAL.</t>
        <t hangText="text()">Not used at this time.</t>
       </list>
       <section title="/ModulePrefs/OAuth/Service/Authorization"
                anchor="Authorization">
        <t>Represents the OAuth 2.0 authorization endpoint. For details, see
        Section 3.1 of <xref target='draft-ietf-oauth-v2-22'>OAuth 2.0</xref> specification.
        Containers MAY provide a default value if this element is not included.</t>
         <t hangText="@url">The URL for the endpoint.</t>
         <t hangText="@method">The HTTP verb to use for making the request.
         Containers MUST use this HTTP method when sending the request to the
         service URL. This parameter is OPTIONAL. If unspecified, it defaults
         to GET.</t>
         <t hangText="text()">Not used at this time.</t>        
       </section>       
       <section title="/ModulePrefs/OAuth/Service/Token">
        <t>Represents the OAuth 2.0 token endpoint. For details, see
        Section 3.2 of <xref target='draft-ietf-oauth-v2-22'>OAuth 2.0</xref> specification.
        Containers MAY provide a default value if this element is not included.</t>
        <list style="hanging">
         <t hangText="@url">The URL for the endpoint.</t>
         <t hangText="text()">Not used at this time.</t>
        </list>
       </section>
      </section>
     </section>
    </section>
    
    <section title="Security Policy" anchor='SecurityPolicy'>
    <xref target='Issue-1143'>Discussion</xref>
      <t>
      The Security Policy feature is used by an application to request permissions under 
      which to run.  Specific permissions are requested with &lt;Param&gt; elements.
      The Security Policy feature is specified with the feature name "security-policy".
      A container MAY support the Security Policy feature.
       <figure>
        <artwork xml:space="preserve">
    &lt;ModulePrefs &gt;
      &lt;Optional feature="security-policy" &gt;
        &lt;Param name="el_escaping"&gt;html&lt;/Param&gt;
      &lt;/Optional &gt;
    &lt;/ModulePrefs &gt;
    </artwork>
       </figure>  
      </t>
      <section title="Permissions">
      <t>
      Permissions are specified by using &lt;Param&gt; elements to identify
      the permission name and requested value for the permission.
      A container may override any application-requested permission with its own security policy.
      </t>
      <t>
      The "el_escaping" permission requests escaping behavior for Expression Language (EL)
      statements within templates.  Valid values are:
        <list style="symbols">
      <t>html - Automatically HTML encode all EL statements.  A container MUST HTML escape all elements and attributes.  A container SHOULD prevent any JavaScript code from executing in an EL statement.</t>
      <t>none - Disables automatic escaping. EL expression results will be
    emitted raw, any markup will be rendered.</t>
      </list>
      </t>
      <t>
      If an application requests a security policy that is not supported, the container MUST log an error to the gadgets.log.  A container MAY render that gadget using a supported security policy, or display an appropriate error message.  
      </t>
      
      <t>
    Escaping rules specified with the "el_escaping" parameter are applied to all views.  An application 
    may request a different escaping policy for a specific view by specifying the view name as 
    a suffix with a preceeding colon to the el_escaping name.  For example, to specify html escaping on the 'profile' view and no escaping for all other views, the following is used:
       <figure>
        <artwork xml:space="preserve">
    &lt;ModulePrefs &gt;
      &lt;Optional feature="security-policy"&gt;
        &lt;Param name="el_escaping:profile" &gt;html&lt;/Param&gt;
        &lt;Param name="el_escaping" &gt;none&lt;/Param&gt;
      &lt;/Optional &gt;
    &lt;/ModulePrefs &gt;
    </artwork>
       </figure>  
      </t>
      <t>
    Containers SHOULD apply HTML escaping by default to all views that are not otherwise constrained or protected by a security mechanism (ex: jail domained IFrame, trusted partner, pre-filtered content).
      </t>
    
      <t>
      In addition to the above permission, a container may extend the Security Policy 
      feature to add any container-specific security permission or experiment.
      </t>
      </section>

  </section>
    
    <section title="/UserPref"
             anchor="UserPref">
     <t>A User Preference specification.</t>
     <list style="hanging">
      <t hangText="@name">The name of the preference. Containers MUST provide
      the current value of the preference when this key is passed to the getters found in
      <xref target="gadgets.Prefs">gadgets.Prefs</xref>. This is also the key used when performing ${Prefs}
	  variable substitutions (see
      <xref target="VariableSubstitution">Variable Substitution</xref>).</t>
      <t hangText="@datatype">The data type for this preference. Valid values
      are "string", "hidden", "bool", "list", and "number". The default value
      is "string".</t>
      <t hangText="@display_name">The name of the preference for use when
      rendering an editing interface for prefs. Developers SHOULD use this
      value to provide a localized name for the preference as described in
      <xref target="Localization">Localization</xref>. Containers SHOULD use
      this value to render any editing interfaces for Users.</t>
      <t hangText="@default_value">A default value for this preference.
      Containers MUST provide this value for any calls to the getters in
      <xref target="gadgets.Prefs">gadgets.Prefs</xref> whenever the key matches @name.</t>
      <t hangText="@required">Whether or not a valid value needs to be set for
      this preference in order for the gadget to function correctly. Valid
      values are "true" and "false" (default). If the value is "true",
      Containers SHOULD display an error message or a prompt if there is no
      valid value stored.</t>
      <t hangText="text()">This tag has child elements. Containers SHOULD NOT
      interpret child text nodes.</t>
     </list>
   <t>Containers MUST interpret /UserPref elements by making each preference
   available to the Gadget through the <xref target="gadgets.Prefs">gadgets.Prefs</xref> library.
   Containers MUST treat /UserPref/@name as the keys for indexing into
   stored preference values when invoking the getters of
   <xref target="gadgets.Prefs">gadgets.Prefs</xref>.</t>
   <t>Containers MUST perform
   <xref target="VariableSubstitution">Variable Substitution</xref> for user
   preferences by treating /UserPref/@name as the key in the token and the
   stored value for the preference as the replacement value.</t>
   <t>Containers MUST provide /UserPref/@default_value as the value for the
   preference when the User or Gadget has not set a value explicitly.</t>
   <t>Containers SHOULD support the following datatypes:
   <list>
    <list style="hanging">
     <t hangText="string">A string accessed by gadgets.Prefs.getString. Default
     data type.</t>
     <t hangText="bool">Evaluates to true or false when accessed by
     gadgets.Prefs.getBool()</t>
     <t hangText="enum">a list of values specified by /UserPref/EnumValue
     elements. Current value is accessed by gadgets.Prefs.getString()</t>
     <t hangText="hidden">a non-visible string that is not user editable but
     can be accessed by gadgets.Prefs.getString()</t>
     <t hangText="list">a pipe-delimited (|) string of values, returned as a
     JavaScript array when accessed by gadgets.Prefs.getArray().</t>
    </list>
   </list></t>
   <t>Containers SHOULD provide a user interface so that all visible User
   Preferences (any type other than "hidden") may be modified by the User of
   the Gadget.</t>
     <section title="/UserPref/EnumValue">
      <t>A single value that serves as a constraint on User Preferences when
      /UserPref/@datatype is "enum". Containers SHOULD use EnumValue elements
      to present Users with a menu when rendering a preferences interface. For
      details on handling enum preferences, see
      <xref target="UserPref">User Preferences</xref>.</t>
      <list style="hanging">
       <t hangText="@value">The value for this enumeration element.</t>
       <t hangText="@display_value">A textual representation of @value.
       Defaults to the value of @value. Containers SHOULD display this value in
       place of @value when rendering a user interface for editing
       preferences.</t>
       <t hangText="text()">Not used at this time.</t>
      </list>
     </section>
    </section>

    <section title="/Data"
             anchor="DataElement">

   <t>Contains data pipeline tags defined for the gadget.
   Data Pipeline results defined in this block are registered globally for all views by default.
   Individual Data pipeline tags may be scoped to a particular view(s) by adding the
   @view attribute to the tag.  Adding the @view attribute to a data pipeline tag has the same
   effect as if the data pipeline tags were defined within a data script nested in a Content block.
   </t>
   <t>
   See <xref target="DataPipelining">Data Pipelining</xref> for more information on data pipeline tags. <xref target="Issue-1162">Discussion</xref>
   </t>

    </section>

    <section title="/ExternalServices" anchor="ExternalServices">
            <xref target='Issue-1178'>Discussion</xref>
            <t>Currently, when making a remote request, either through the OSAPI or makeRequest, the full URL of the remote
            service that is being invoked must be specified. However, often, there are multiple service endpoints that
            use the same API. Consider the following examples. A large enterprise may have a backend system, e.g.
            SharePoint, or a cloud system, e.g. Salesforce, whose information they would like to make available to
            application developers. These developers may be internal to the enterprise, or third party application
            providers.</t>

            <t>In addition, it's not uncommon to have multiple instances of the backend service that can be used, e.g.
            development, QA, Production. Internal developers should not have to change the gadget definition when moving
            between these environments. Further, third party vendors need a way to identify a particular service in the
            gadget XML and then allow for a "late binding" to the actual endpoint that realizes that service. The
            "Alias" request parameter may be used to satisfy these requirements.</t>

            <t>Configuring an "Alias" works in a manner similar to configuring an OAuth service. That is, in OAuth, there
            is configuration within the gadget XML to identify which request set of endpoints to use to get the access
            tokens etc, but the registration of the consumer secret is provided to the container outside of the gadget
            XML. In the case of "Alias", there is configuration within the gadget XML to name the service and specify
            which "service tag" the container should use. </t>

            <t>It is possible for the same service tag to be registered for multiple external service endpoints within
                the same container. For example, there could be multiple SharePoint instances even though the
                application has one alias. Determination of the proper external service endpoint is at the discretion of
                the container and various schemes may be used. For example, the container may prompt the user at the
                time of gadget installation to select which external service endpoint to use.
            </t>

            <t>One of the primary motivations for Alias is to make it easy for OpenSocial containers to expose legacy
            systems endpoints to application providers. Therefore, its expected that a common set of service tags will
            be defined and maintained publicly. One such example is maintained by the OpenSocial community and is
            available on the wiki at http://docs.opensocial.org/display/OSD/OpenSocial+External+Services+Tag+Registry.</t>

             <section title="/ExternalServices/ServiceTag">
                 <t>The unique identifier of the API to the external service, e.g. opensocial:service://microsoft.com/sharepoint/api?version=1.</t>
                 <list style="hanging">
                    <t hangText="@alias">The name to be used in the "alias" request parameters. The container will use the name to look up the proper service tag.</t>
                    <t hangText="text()">The tag that identifies the API to the external service.</t>
                 </list>
             </section>
    </section>


    <section title="/Content"
             anchor="ContentElement">
     <t>Contains the run time portion of the gadget.</t>
     <list style="hanging">
      <t hangText="@type" anchor="Type">REQUIRED. The type of content included in the body of this
      element. Valid values are "html" and "url". Containers MUST interpret the
      body of this element according to the specific processing rules for each
      type.
      <t>When /Content/@type is "html", Containers MUST perform
   <xref target="VariableSubstitution">Variable Substitution</xref> on the final
   assembled content section.</t>

      <t>When /Content/@type is "url", Containers MUST display a direct view of
         the value for /Content/@href as specified in the
      <xref target="ContentRedirect">Content Redirect</xref> section. <xref target="Issue-1173">Discussion</xref>
      </t>
      </t>
      <t hangText="@href">A URL pointing to an external file containing the
      body of this element.
      <t>If @type is "url", this value is REQUIRED. If @type
      is "url", this value represents an external document that SHOULD be
      presented directly to Users without filtering as specified in the
      <xref target="ContentRedirect">Content Redirect</xref> section.</t>
      <t>If @type is "html", the Container MUST
      <xref target="ProxiedContent">proxy</xref> the current content section. <xref target="Issue-1173">Discussion</xref></t>

      </t>
         <t hangText="@preferred_height">The suggested default height, in pixels,
             to use when rendering this gadget. Containers SHOULD use this value as
             the default height for a gadget in any environment that allows gadgets to
             have variable heights. If both the @height and @preferred_height are specified, the container SHOULD
             respect the value of @preferred_height.
         </t>
         <t hangText="@preferred_width">The suggested default width, in pixels, to
             use when rendering this gadget. Containers SHOULD use this value as the
             default width for a gadget in any environment that allows gadgets to have
             variable widths. If both the @width and @preferred_width are specified, the container SHOULD respect the
             value of @preferred_width.
         </t>
      <t hangText="@view">A comma delimited list of Views in which to include the content in this section. Example: &lt;Content view="Profile, Home, Home.About"/&gt;
        contains Content for three named views: Profile, Home, and Home.About.
      <t>To assemble a View, all Content sections where @view contains the required view name are concatenated.  Concatenation does not happen when the @href is set on a
        &lt;Content&gt; block. In this case, the set of view names on
        &lt;Content&gt; blocks with @href set to a non-null, non-empty string
        MUST be unique within the Gadget XML. If this is not true, the markup
        is invalid. A container may process gadget markup ahead of acceptance
        into a container's application gallery, checking for the href
        conditions when importing gadget XML. This validity check need not be
        performed at render time.</t>
      </t>
      <t hangText="@authz">The request issued to the URL in /Content/@href MUST be signed
        according to the rules specified because of the current /Content/@type.
       <xref target="Issue-1173">Discussion</xref></t>
      <t hangText="text()">Contains data in an appropriate format to satisfy
      the requirements for @type. When @type is "html", if no @href is
      specified, this value MUST be a block of html. The text within this element SHOULD be wrapped in CDATA to avoid having to escape HTML tags and to prevent them from being interpreted by the XML parser.</t>
     </list>
    </section>
   </section>
  </section>
   <section title="Content Rewriting">
    <t>Containers MAY support content rewriting. The feature supports rewriting
    the content of a generated gadget and allow developers to control how the
    behavior of the rewriter through an optional gadget feature named
    content-rewrite. The content-rewrite feature defines a set of rewriting
    operations that a container can perform on rendered and proxied content and
    defines rules to allow developers to control which content the rewriter can
    operate on.</t>
    <section title="Definition">
     <t>
     <figure>
      <preamble>The rewriter feature has the general form :</preamble>
      <artwork xml:space="preserve">
&lt;Optional feature="content-rewrite"&gt;
    &lt;Param name="expires"&gt;86400&lt;/Param&gt;
    &lt;Param name="include-url"&gt;&lt;/Param&gt;
    &lt;Param name="exclude-url"&gt;excluded&lt;/Param&gt;
    &lt;Param name="exclude-url"&gt;moreexcluded&lt;/Param&gt;
    &lt;Param name="minify-css"&gt;true&lt;/Param&gt;
    &lt;Param name="minify-js"&gt;true&lt;/Param&gt;
    &lt;Param name="minify-html"&gt;true&lt;/Param&gt;
&lt;/Optional&gt;
</artwork>
     </figure>The parameters are defined as follows:
     <list type="symbols">
      <t>expires - The duration in seconds to force as minimum HTTP cache time
      for content fetched through the proxy via a rewritten URL. Default
      86400.</t>
      <t>include-url - Any URL which contains this parameters value as a
      case-insensitive substring is considered rewriteable. The literal string
      "*" is a special case and implies all URLs. If not specified an entry
      with the value "*" is assumed. This parameter can be repeated.</t>
      <t>exclude-url - Any URL which contains this parameters value as a
      case-insensitive substring is excluded from rewriting. The literal string
      "*" implies all URLs and effectively disables all rewriting. This
      parameter can be repeated.</t>
      <t>minify-css - Controls whether the container will attempt to minify css
      in style tags and referenced css files. Valid values are "true"|"false".
      Default is "true".</t>
      <t>minify-js - Controls whether the container will attempt to minify JS
      in script tags and referenced JS files. Valid values are true|false.
      Valid values are "true"|"false". Default is "true".</t>
      <t>minify-html - Controls whether the container will attempt to minify
      HTML content. Valid values are true|false. Valid values are
      "true"|"false". Default is "true".</t>
     </list>Matches for "exclude-url" take precedence over matches for
     "include-url"</t>
     <t>Note that the special use of "*" to denote all URLs should not be
     interpreted as support for GLOB or RegEx matching on strings.</t>
     <t>Containers are free to perform additional optimizations when rewriting
     links including but not limited to:
     <list type="symbols">
      <t>Extract @import directives from style tags and convert them into link
      tags in the head tag of the containing HTML content.</t>
      <t>Merge multiple CSS fetches from successive link tags into one link tag
      that causes the proxy to concatenate the content fetched from the
      individual URLs.</t>
      <t>Merge contiguous &lt;script src=xxx&gt; tags into one concatenating
      proxy fetch.</t>
     </list></t>
    </section>
    <section title="Examples">
     <t>
      <figure>
       <preamble>Rewrite only gif images</preamble>
       <artwork xml:space="preserve">
&lt;Optional feature="content-rewrite"&gt;
    &lt;Param name="include-url"&gt;.gif&lt;/Param&gt;
&lt;/Optional&gt;
</artwork>
      </figure>
      <figure>
       <preamble>Rewrite only gif images that do not contain "animated" or
       "cdn"</preamble>
       <artwork xml:space="preserve">
&lt;Optional feature="content-rewrite"&gt;
    &lt;Param name="include-url"&gt;.gif&lt;/Param&gt;
    &lt;Param name="exclude-url"&gt;animated&lt;/Param&gt;
    &lt;Param name="exclude-url"&gt;cdn&lt;/Param&gt;
&lt;/Optional&gt;
</artwork>
      </figure>
      <figure>
       <preamble>Disable all rewriting</preamble>
       <artwork xml:space="preserve">
&lt;Optional feature="content-rewrite"&gt;
    &lt;Param name="exclude-url"&gt;*&lt;/Param&gt;
&lt;/Optional&gt;
</artwork>
      </figure>
     </t>
    </section>
   </section>
  <section title="Proxied Content"
           anchor="ProxiedContent">
   <t>When rendering an OpenSocial Gadget, the container MUST determine if the
   content for the active view is to be proxied. This is done by checking for
   the presence of a /Content/@href attribute.</t>
   <t>If the attribute is present, the container MUST issue an HTTP request to
   the URI specified by the href attribute following the rules defined in
   <xref target="gadgets.io.makeRequest">gadgets.io.makeRequest</xref>.</t>
   <t>Attributes on the Content element map to makeRequest as follows:
   <list style="symbols">
    <t>authz: gadgets.io.AuthorizationType (values are canonicalized by
    converting to lower case. Default value is 'none')</t>
    <t>oauth_received_callback: gadgets.io.RequestParameters.OAUTH_RECEIVED_CALLBACK</t>
    <t>oauth_request_token: gadgets.io.RequestParameters.OAUTH_REQUEST_TOKEN</t>
    <t>oauth_request_token_secret: gadgets.io.RequestParameters.OAUTH_REQUEST_TOKEN_SECRET</t>
    <t>oauth_service_name: gadgets.io.RequestParameters.OAUTH_SERVICE_NAME</t>
    <t>oauth2_scope: gadgets.io.RequestParameters.OAUTH2_SCOPE <xref target="Issue-1209">Discussion</xref></t>
    <t>oauth_token_name: gadgets.io.RequestParameters.OAUTH_TOKEN_NAME</t>
    <t>oauth_use_token: gadgets.io.RequestParameters.OAUTH_USE_TOKEN</t>
    <t>refresh_interval: gadgets.io.RequestParameters.REFRESH_INTERVAL</t>
    <t>sign_owner: gadgets.io.RequestParameters.SIGN_OWNER (default 'true')</t>
    <t>sign_viewer: gadgets.io.RequestParameters.SIGN_VIEWER (default 'true')</t>
   </list></t>
   <t>Note that these attributes also apply to Preload elements.</t>
   <t>The container MUST also add the following parameters to the URI query
   string:
   <list style="symbols">
    <t>lang: The language of the user viewing the page as specified in Section
    3 i under Process in this document.</t>
    <t>country: The country of the user viewing the page as specified in
    Section 3 i under Process in this document.</t>
    <t>opensocial_proxied_content: MUST be present and set to 1. Servers can
    use this to distinguish proxied content renders from
    gadgets.io.makeRequest() calls. Remote sites that expect proxied content
    requests SHOULD reject requests that do not have opensocial_proxied_content
    set to 1. If a remote site fails to implement this check, any content in
    the POST body may be spoofed by a malicious user or application.</t>
   </list></t>
   <t>By default, the request is sent to the remote site MUST be sent to the
   remote site as an HTTP GET. When the Content section includes Data
   Pipelining elements, the container MUST send the data to the request URI
   using an HTTP POST. The structure of this data will match the
   <eref target="./Core-API-Server.xml#RPC">JSON-RPC format</eref>. For more information on Data Pipelining and Proxied Content, see <xref target="DataPipelining-ProxiedContent"/></t>
   <section title="Processing Results">
    <t>If the response to the proxied request returns a successful HTTP status
    code, the container MUST interpret the resulting response body according to
    the rules for content declared inline.</t>
    <t>If the response to the proxied request returns an unsuccessful HTTP
    status code, the container SHOULD present a meaningful error message to the
    end user. Containers SHOULD obtain a suitable error message for display by
    displaying the content specified for a view named as view-name.error, where
    view-name matches the name of the view that the proxied request was being
    processed for. If an exact match can not be found, the special value
    default.error should be used. If default.error is not present, the
    container SHOULD display a generic message indicating that a problem
    occurred.</t>
   </section>
   <section title="Caching">
    <t>Containers SHOULD cache the results of the HTTP request following the
    recommendations of section 13 of
    <xref target="RFC2616">RFC 2616</xref>. If a container does support caching
    of data, it MUST also support overriding HTTP caching by using the value
    specified for refresh_interval.</t>
    <t>Caches SHOULD be keyed using the following:
    <list style="symbols">
     <t>The URI of the proxied request.</t>
     <t>The opensocial owner id, if sign_owner is set to true and requests are
     authenticated.</t>
     <t>The opensocial viewer id, if sign_viewer is set to true and requests
     are authenticated.</t>
     <t>The language and country passed in to the proxied URI.</t>
    </list></t>
    <t>Containers MAY cache unsuccessful HTTP responses ("negative caching"),
    but SHOULD NOT cache unsuccessful responses for a period longer than 5
    minutes.</t>
    <section title="Processing Content">
     <t>The container MUST normalize content bodies in a way that preserves
     semantic meaning in the resulting HTML output. Specifically, containers
     MUST preserve the structure of the document for the context the gadget
     will be rendered in as follows:
     <list style="symbols">
      <t>If the document is a complete HTML document, including opening and
      closing html tags, the container MUST retain the semantic meaning of
      document type definition declarations as well as the relative position of
      elements in the document.
      <list style="symbols">
       <t>A container MAY choose to move elements from the head of a document
       and into the body (or vice versa), but the end result MUST behave the
       same as the original input .</t>
      </list></t>
      <t>Containers MAY modify the document in other ways for optimization and
      security purposes as long as semantics are preserved</t>
     </list></t>
    </section>
    <section title="Processing XML">
     <t>The container MUST resolve all URI attributes and values relative to
     the location of the gadget spec xml document. This DOES NOT include links
     inside of the body of the Content element at this point in time.</t>
    </section>
   </section>
  </section>
  <section title="Content Redirect"
           anchor="ContentRedirect">

   <t>When /Content/@type is "url", Containers MUST display a direct view of
   the value for /Content/@href (for a web context, this SHOULD be an HTML
   iframe). The Container MUST append the following query string parameters to the URL:
    <list style="hanging">
     <t hangText="up_&lt;name&gt;"> A query parameter for each User Preference as a name/value pair.</t>
     <t hangText="lang">The language of the User viewing the gadget (valid
     values are the same as for <xref target="Locale">/ModulePrefs/Locale/@lang</xref>).</t>
     <t hangText="country">The country of the User viewing the gadget. (valid
     values are the same as for <xref target="Locale">/ModulePrefs/Locale/@country</xref>).</t>
     <t hangText="libs">A relative URL that points to any JavaScript files
     necessary to satisfy the features specified in
     <xref target="RequireAndOptional">/ModulePrefs/Require and /ModulePrefs/Optional</xref> elements in the Gadget.</t>
    </list>
   </t>
   <t>If the /Content/@authz attribute is present and it equals "signed", the container MUST vouch
      for the user's identity to the destination server. This follows the steps outlined in the
      <xref target="SignedFetch">Signed Fetch</xref>
      section of this specification. <xref target="Issue-1173">Discussion</xref>
   </t>

  </section>
  <section title="Versioning"
           anchor="Versioning">
   <t>Both the overall OpenSocial specification and individual Gadget Features
   are versioned. Gadgets SHOULD specify the version of the specification that
   Containers should use to interpret them by including the @specificationVersion
   attribute on the root Module element, and the versions of any Features
   they use by including the @version attribute on
   /ModulePrefs/Require and /ModulePrefs/Optional elements.</t>
   <t>The versions of standard
   Features defined by this specification are detailed in
   <xref target="RequireAndOptional">ModulePrefs</xref>. Extensions to the OpenSocial
   specification MUST define the version of any Features specified by the
   extension. Containers SHOULD document the version of any custom Features
   they provide. <xref target="Issue-1207">Discussion</xref></t>
   <t>Versions are specified as a string of up to three non-negative integers,
   separated by the dot (.) character, for example "1.0.0", "1.2.1", or
   "1.3.12". The three components of a version each signify a guarantee about
   the compatibility of that version with other versions of the same
   specification or Feature.</t>
   <list style="hanging">
    <t hangText="Major Versions">are represented by the first number in the
    sequence, for example "1" in "1.0.0", "1.0.2", "1.3.0", etc. Changes in the
    major version signify backward-incompatible changes from previous versions
    of the specification or Feature. For example, when Feature APIs or Gadget
    XML elements and attributes are removed or renamed, or significant changes
    to the Gadget rendering process are made that would result in malfunctions
    for existing Gadgets, the major version MUST be incremented.</t>
    <t hangText="Minor Versions">are represented by the second number in the
    sequence, for example "2" in "1.2.0", "1.2.1", "3.2.0", etc. Minor versions
    are interpreted relative to the preceding major version number. Changes in
    the minor version signify backward-compatible but forward-incompatible
    changes from previous versions of the specification or Feature. For example,
    when new Feature APIs or Gadget XML elements and attributes are added, the
    minor version MUST be incremented, but the major version SHOULD NOT change,
    because the new version is backward-compatible with Gadgets that were
    written to use previous minor versions of the same major version, but
    containers that do not implement the new minor version will not be
    forward-compatible with Gadgets written to use the new minor version.</t>
    <t hangText="Patch Versions">are represented by the third number in the
    sequence, for example "3" in "1.0.3", "1.1.3", "2.2.3", etc. Patch versions
    are interpreted relative to the preceding major and minor version numbers.
    Changes in the patch version signify changes that are both
    backward-compatible and forward-compatible with previous versions of the
    specification or Feature. For example, when making minor clarifications,
    fixing typos and bugs, or making other small changes that neither affect the
    functionality of existing Gadgets, nor introduce functionality that would be
    incompatible with containers that only implement older patch versions of the
    same minor version, the patch version MUST be incremented, but the minor
    and major versions SHOULD NOT change.</t>
   </list>
   <t>The value of the /@specificationVersion, /ModulePrefs/Require/@version,
   and /ModulePrefs/Optional/@version attributes may fully specify all three of
   the major version, minor version, and patch version numbers. For example,
   "1.0.0" or "1.2.3". When all three version components are specified,
   containers MUST conform to the exact version of the specification or
   Feature that is requested. Alternately, these attributes may specify the
   major and minor versions only, without the patch version, or the major
   version only, without the minor and patch versions. For example, "1.0",
   "2.3", and "3" are all valid. When these attributes specify partial versions,
   the container MUST conform to a version of the specification or Feature that
   matches the version components specified, but MAY use any version of the
   unspecified components.</t>
   <t>For example, a Container that is processing a Gadget with
   /@specificationVersion="2.3" may process it according to specification
   version 2.3.0, 2.3.1, 2.3.22, etc., but not 2.2.0, 2.4.0, 2.30.0, 3.0.0, etc.
   A Container that is processing a Gadget with
   /ModulePrefs/Require/@version="3" MAY provide the specified Feature at
   version 3.0.0, 3.0.1, 3.1.0, 3.1.11, etc., but not 2.0.0, 4.0.0, 33.0.0,
   etc.</t>
   <t>It is RECOMMENDED that Gadget Developers specify the most general version
   that will satisfy the requirements of a Gadget. Usually, major and minor
   versions will suffice, and the patch version MAY be omitted from
   /@specificationVersion, /ModulePrefs/Require/@version, and
   /ModulePrefs/Optional/@version attributes.</t>
   <t>If the /@specificationVersion attribute or any
   /ModulePrefs/Require/@version or /ModulePrefs/Optional/@version attributes
   are absent, they are assumed to have the value "1.0". As described above,
   this value will match any version beginning with "1.0", including 1.0.0,
   1.0.1, 1.0.22, etc., but not 1.1.0, 2.0.0, etc. This default value will
   not change in future versions of the specification, ensuring that Gadgets
   that omit these values will not have sudden, unexpected changes in behavior
   when containers adopt new versions of the OpenSocial specification or
   Features.</t>
  </section>
  <section title="Variable Substitution"
           anchor="VariableSubstitution">


   <t>Variables may be substituted into a gadget by evaluating Expression Language (EL)
   statements.  EL statements consist of a dollar sign and curly braces
   surrounding a statement.
	  <figure>
     <preamble>Example: EL statement</preamble>
     <artwork xml:space="preserve">
One plus one is equal to ${1+1}
	 </artwork>
    </figure>
   </t>

   <t>
   EL statements may be used to access values stored in reserved variable keys,
   variables defined with data pipeline tags, or literal values.
   Containers MUST support resolving variables using this syntax.
   </t>

	<section title="Expression Language" anchor="EL">
	<t>
	The Expression Language (EL) is based on <xref target="JSPEL">JSPEL</xref>.
	The EL version in OpenSocial supports all basic operations, such as string
	concatenation and match functions, but does not currently support defining
	custom functions.  <xref target="Issue-1164">Discussion</xref>
	</t>
	</section>

	<section title="Variables">
	<t>
	All variables are stored in the <xref target="DataContext">DataContext</xref>.
	</t>
	</section>

    <section title="Reserved Variable Keys" anchor="ReservedVariableKeys">
	<t>
	There are a number of reserved variable keys.  These are reserved for use
	by the container.  If a gadget attempts to redefine any of these variables,
	the container MUST generate an error.
	</t>
        <texttable align="left">
         <ttcol>Variable Key</ttcol>
         <ttcol>Description</ttcol>
		 <ttcol>Scope</ttcol>
         <c>Msg</c>
        <c>Contains all message bundle variables for the current locale.</c>
		<c>Available anywhere within gadget, including ModulePrefs and root Module element.
		Message bundle values may reference other message bundle variables by
		making use of the ${Msg.NAME} syntax within the value.
		</c>
         <c>ViewParams</c>
         <c>Contains all values passed as viewParams with a call to
		 <xref target="gadgets.views.requestNavigateTo">gadgets.views.requestNavigateTo</xref>.
		 EL statements against this key will resolve to the same values as calls
		 against the result of <xref target="gadgets.views.getParams">gadgets.views.getParams</xref>
		 in the Javascript API.
		 </c>
		 <c>Available within Content blocks, <xref target="DataPipelining">Data Pipeline</xref>
		 tags, and OpenSocial Markup Language (OSML) tags.</c>
         <c>Prefs</c>
         <c>Contains all named values defined in the
		 <xref target="UserPref">UserPref</xref> section of the gadget and module
		 dimensions and messages.
		 EL statements against this key will resolve to the same values as calls
		 against the result of <xref target="gadgets.Prefs">gadgets.Prefs</xref>
		 in the Javascript API.  Values are exposed as fields to the EL.
		 Ex: Current language is accessed as ${Prefs.Lang}.
		 </c>
		 <c>Available anywhere within gadget.</c>
		 <c>Top</c>
		 <c>Reserved variable used by
		 <xref target="OpenSocial-Templating">OpenSocial Templating</xref> to represent
		 the top level variables registered with the <xref target="DataContext">DataContext</xref></c>
		 <c>Within content and templates</c>
		 <c>My</c>
		 <c>Reserved variable used by
		 <xref target="OpenSocial-Templating">OpenSocial Templating</xref> to
		 hold local variables passed to the template instance.</c>
		 <c>Within a template instance</c>
		 <c>Cur</c>
		 <c>Reserved variable used by OSML repeaters as defined in the
		 <xref target="OpenSocial-Templating">OpenSocial Templating specification</xref>.
		 Represents the current value or object as a for-each loop would.
		 </c>
		 <c>Within a repeater loop</c>
		 <c>Context</c>
		 <c>Variable used by OSML and templates to hold additional variables
		 generated while processing templates and loops as defined in the
		 <xref target="OpenSocial-Templating">OpenSocial Templating specification</xref>.
		 Additional variables are unique ID, current index in repeat, and count of repeat.
		 </c>
		 <c>Within a template or repeater loop</c>
		 <c>Viewer</c>
		 <c>Reserved for future use.</c>
		 <c>N/A</c>
		 <c>Owner</c>
		 <c>Reserved for future use.</c>
		 <c>N/A</c>
		 <c>Gadget</c>
		 <c>Reserved for future use.</c>
		 <c>N/A</c>
      </texttable>
	</section>


	<section title="Deprecated variable format">
   <t>The older variable tokens format has been deprecated in favor of
   the EL syntax.  The legacy variables take
   the form __&lt;TYPE&gt;_&lt;key&gt;__. For all substitutions, the full token
   is to be replaced by a value for the following values of &lt;TYPE&gt;:</t>
   <list style="hanging">
    <t hangText="MSG">See
    <xref target="Localization">Localization</xref></t>
    <t hangText="BIDI">See <xref target="Localization">Localization</xref></t>
    <t hangText="MODULE">Currently, "ID" is the only &lt;key&gt; value supported. Containers SHOULD provide a unique value
    for ID for each instance of a gadget displayed simultaneously.</t>
    <t hangText="UP">See
    <xref target="UserPref">User Preferences</xref>. Whenever there is no
    value for a token declared in the gadget, Containers SHOULD still replace
    the token with an empty string. Containers MUST NOT replace tokens with an
    unknown TYPE with an empty string. Instead, the token should be left in the
    gadget in it's original form.</t>
   </list>
   <t>Containers MUST perform substitution on all elements and attributes
   defined in
   <xref target="ElementsAndAttributes">Elements and Attributes</xref>, with
   the exceptions of /ModulePrefs/Locale (and children), or any element with an
   explicit enumeration. Containers SHOULD perform substitution on any custom
   elements or fields that they support.</t>
   <t>Containers MUST perform MSG substitutions in the order listed above.
   Containers MUST substitute BIDI, MODULE, and UP tokens after substituting
   MSG values, but they MUST NOT recursively substitute any other tokens.</t>
   </section>


  </section>
  <section title="Localization"
           anchor="Localization">
   <t>Localization of a gadget is achieved primarily through
   <xref target="VariableSubstitution">Variable Substitution</xref>, using the
   ${Msg} variable and message bundles.</t>
   <t>To determine appropriate keys and values for substitution, Containers
   MUST select an appropriate /ModulePrefs/Locale based on the following
   rules:</t>
   <list style="numbers">
    <t>An exact match for the language and country of the User viewing the
    gadget.</t>
    <t>An exact match for language, country = "all".</t>
    <t>Language = "all", country = "all'.</t>
   </list>
   <t>
   Containers SHOULD select a Locale that supports the current view over any
   other Locale.  The Views supported by a Locale are specified at
   /ModulePrefs/Locale/@views. <xref target="Issue-1133">Discussion</xref></t>

   <t>Containers MAY provide their own translations or use a third-party
   translation service if there is no appropriate Locale defined in the
   gadget.</t>
   <t>After selecting a Locale, Containers MUST replace all ${Msg} tokens by using
   /ModulePrefs/Locale/msg/@name for keys and /ModulePrefs/Locale/msg/text()
   for values.</t>
   <t>Containers MUST perform BIDI token substitution with the following values
   if /ModulePrefs/Locale/@language_direction is "rtl":</t>
   <artwork type="example"
         xml:space="preserve">START_EDGE: "right"
END_EDGE: "left"
DIR: "rtl"
REVERSE_DIR: "ltr"
</artwork>
   <t>Otherwise:</t>
   <artwork type="example"
         xml:space="preserve">START_EDGE: "left"
END_EDGE: "right"
DIR: "ltr"
REVERSE_DIR: "rtl"
</artwork>

<section title="Message Bundles" anchor="MessageBundles">
<xref target="Issue-1171">Discussion</xref>
<!-- copied from http://code.google.com/apis/gadgets/docs/i18n.html#Bundles -->
<t>
The gadgets i18n strategy centers around message bundles.
Message bundles are XML files that contain the translated strings
for a given locale. Each string is identified by a unique name
that is the same across bundles.
</t>

<t>
Message bundles can be hosted at any URL, and can be shared between applications.
Message bundles contain only one locale.
</t>
<t>
Message bundles have the following format:
</t>
   <artwork type="example"
         xml:space="preserve">
&lt;messagebundle&gt;
  &lt;msg name="hello_world"&gt;
    Hello World.
  &lt;/msg&gt;
  &lt;msg name="color"&gt;Color&lt;/msg&gt;
  &lt;msg name="red"&gt;Red&lt;/msg&gt;
  &lt;msg name="green"&gt;Green&lt;/msg&gt;
  &lt;msg name="blue"&gt;Blue&lt;/msg&gt;
  &lt;msg name="gray"&gt;Gray&lt;/msg&gt;
  &lt;msg name="purple"&gt;Purple&lt;/msg&gt;
  &lt;msg name="black"&gt;Black&lt;/msg&gt;
&lt;/messagebundle&gt;
</artwork>

<t>
By convention, external message bundles are named as &lt;language&gt;_&lt;country&gt;.xml
Where there is no language- or country-specific value, the convention is to use “ALL.” For example, the file de_ALL.xml applies to all German speakers, regardless of their country.
The message bundle ALL_ALL.xml is the file that is used by default.
</t>
<t>
Message bundles may be specified inline or as externally referenced XML files
in the <xref target="Locale">/ModulePrefs/Locale</xref> section.
</t>

</section>

  </section>



  <section title="Signed Fetch"
           anchor="SignedFetch">
   <t>Containers MUST support signing of HTTP requests for
   <xref target="gadgets.io.makeRequest">gadgets.io.makeRequest</xref>,

   <xref target="ProxiedContent">Proxied Content</xref>,
   <xref target="ContentRedirect">Content Redirect</xref>,
   <xref target="LifeCycleEvents">Life Cycle Events</xref>, and
   <xref target="Preload">Preloading</xref> (<xref target="Issue-1173">Discussion</xref>). The container does this by
   doing the following:
   <list style="numbers">
    <t>Removing any request parameters with names that begin with oauth,
    xoauth, or opensocial (case insensitive).</t>
    <t>Adding the following parameters to the request query string:</t>
    <list style="hanging">
     <t hangText="opensocial_viewer_id">Optional. The ID of the current viewer,
     which matches the getId() value on the viewer person object.</t>
     <t hangText="opensocial_owner_id">Required. The ID of the current owner,
     which matches the getId() value on the owner person object.</t>
     <t hangText="opensocial_app_url">Required. The URL of the application
     making the request. Containers may alias multiple application URLs to a
     single canonical application URL in the case where an application changes
     URLs.</t>
     <t hangText="opensocial_instance_id">Optional. An opaque identifier used
     to distinguish between multiple instances of the same application in a
     single container. If a container does not allow multiple instances of the
     same application to coexist, this parameter may be omitted. The
     combination of opensocial_app_url and opensocial_instance_id uniquely
     identify an instance of an application in a container.</t>
     <t hangText="opensocial_app_id">Optional. An opaque identifier for the
     application, unique to a particular container. Containers that wish to
     maintain backwards compatibility with the opensocial-0.7 specification may
     include this parameter.</t>
     <t hangText="xoauth_public_key">Optional. An opaque identifier for the
     public key used to sign the request. This parameter may be omitted by
     containers that do not use public keys to sign requests, or if the
     container arranges other means of key distribution with the target of the
     request.</t>
    </list>
    <t>Signing the resulting request according to section 9 of the
    <eref target="http://oauth.net/core/1.0/#signing_process">OAuth
    specification</eref>.</t>
   </list></t>
   <section title="Key management" anchor="KeyManagement">
   <t>If a container uses public keys to sign requests, the container may
   choose to use either self-signed certificates or certificates signed by a
   well-known certificate authority. If a container does not distribute its
   OAuth signing key over HTTPS, it should use a certificate signed by a
   well-known certificate authority.</t>
   <t>The commonName attribute of the certificate should match the hostname of
   the container server, and should also match the value of the
   oauth_consumer_key parameter specified in the request.</t>
   <t>The container should make its public key available for download at a
   well-known location. The location
   https://[container-hostname]/opensocial/certificates/xoauth_public_keyvalue
   is recommended.</t>
   <t>Recipients of signed requests must verify that the signature on the
   request is correct, and that the timestamp on the request is within a
   reasonable time window. A time window of 5 minutes before and after the
   current time is recommended.</t>
   <t>Recipients of signed requests may use the oauth_consumer_key and
   xoauth_public_key parameters to automatically detect when a container
   deploys new certificates. If the container deploys certificates at a
   well-known location, the recipient may automatically download the new
   certificate. Recipients that automatically download new certificates should
   cache the resulting certificates.</t>
   <t>If a container's certificate is not downloaded from
   https://[container-hostname], the recipient should verify that the
   certificate is signed by a well-known certificate authority before trusting
   the certificate.</t>
   </section>
  </section>
  <section title="OAuth"
           anchor="OAuth">
  <t>Note that the OAuth 2.0 specification is not currently approved by the IETF and references
  to OAuth 2 capabilities are based on version 22 of the OAuth 2.0 specification.
  </t>
  <xref target='Issue-1138'>Discussion</xref>
   <t>As mentioned previously in this specification and other OpenSocial
     2.0 specifications, OpenSocial containers MUST be able to proxy
    OAuth requests for gadgets.  The main mechanism used to accomplish proxy
    requests is the <xref target="gadgets.io.makeRequest">gadgets.io.makeRequest</xref>
    method.  This method MUST be implemented to handle gadget OAuth proxy
    requests. When
   proxying a gadget's request, Core Gadget Servers SHOULD use an OAuth token specific
   to the gadget making the request, and specific to either the Viewer or the
   Owner of the container page. This implies that OAuth information, such as access
   tokens are stored so they may be retrieved by service name,
   gadget id and user id, although this is implementation specific.</t>
    <t> When proxying a gadget's request,
   OpenSocial containers MAY use an OAuth client key and secret specific to the gadget
   making the request (xoauth_requestor_id request context parameter),
   or MAY use the container's OAuth client key and secret. For more details, see the
   <xref target="OAuth-Core">OAuth 1.0A specification</xref> or the 
   <xref target='draft-ietf-oauth-v2-22'>OAuth 2.0</xref> specification.</t>
   <section title="Consumer Secrets">
    <t>OAuth client keys and secrets are typically obtained by registering a
    gadget, application or server with a service provider at a web page provided
    by the service provider.  Once the keys/secrets
    are obtained, they are typically placed in a key store on the Core Gadget Server.
    However, the exact method of accomplishing registration is
    implementation specific. If a Core Gadget Server uses its own client key
    and secret when making OAuth requests, it must be registered with each
    service provider it will communicate with.  In this case, the
    Core Gadget Server will use the same client key and client secret for every
    OAuth request to a particular service provider.</t>
   </section>
   <section title="OAuth Tokens">
    <t>When proxying a
    <xref target="gadgets.io.makeRequest">gadgets.io.makeRequest</xref>of
    <xref target="gadgets.io.AuthorizationType">
    gadgets.io.AuthorizationType</xref> 'OAUTH' for OAuth 1.0A, the container SHOULD do the
    following:</t>
    <list style="numbers">
     <t>If the Core Gadget Server finds an appropriate OAuth access token and secret for
     the request, the Container signs the outgoing request according to the
     OAuth specification.</t>
     <t>If the container finds no appropriate OAuth access token, but an
     appropriate OAuth request token for the request, the container accesses
     the access token endpoint of the target service provider, and attempts to
     exchange the request token for an access token. If successful, the
     container then immediately uses the access token to sign the request made
     by the gadget.</t>
     <t>If the container finds neither an appropriate OAuth access token or
     request token, it accesses the request token endpoint of the target
     service provider to obtain a request token. It then returns an error
     message to the Gadget that contains, among other things, the user
     authorization URL at the target service provider. The Gadget is expected
     to redirect the User Agent to that authorization URL and re-attempt the
     <xref target="gadgets.io.makeRequest">gadgets.io.makeRequest</xref>once
     the user has approved the OAuth access.</t>
    </list>
    
    <t>Proxying a request for an OAuth 2 service provider is different based
      on the grant type being used.  This description is for an authorization
      grant.
    <xref target="gadgets.io.makeRequest">gadgets.io.makeRequest</xref>of
    <xref target="gadgets.io.AuthorizationType">
    gadgets.io.AuthorizationType</xref> 'OAUTH2' for OAuth 2.0, the container SHOULD do the
    following:</t>
    <list style="numbers">
       <t>It is assumed the Core Gadget Server can find a client key and secret
          for the service provider to be contacted.  If these cannot be found,
          a "permanent" failure is returned to the gadget.</t>
       <t>If the Core Gadget Server finds an appropriate OAuth access token
          it contacts the service provider resource endpoint using OAuth 2.0 client
          code that is compatible with the specific OAuth 2.0 implementation of
          the service provider, passes the token (among other data), and requests
          the data. </t>
       <t>If the Core Gadget Server finds no appropriate OAuth access token, it returns
          an error to the gadget along with a redirection URL based on
          the gadget XMLs /ModulePrefs/OAuth/Service/Authorization setting.
          The gadget is expected to redirect the User Agent
          (browser) to the authorization URL for the service provider.  Once
          the user authenticates and authorizes the gadget, the gadget will
          receive a redirection URL from the serivce provider that includes
          an authorization code.
          The gadget redirects the User Agent (browser) back to the
          Core Gadget Server, which receives the authorization code from
          the service provider.  The Core Gadget Server contacts the token
          endpoint of the service provider, passing the client key/secrets
          along with the authorization code to obtain an access token.
          The Core Gadget Server returns an error to the gadget to indicate
          a need to retry the makeRequest.  The gadget retries the makeRequest.
          </t>
    </list>
    <xref target='Issue-1138'>Discussion</xref>
   </section>
  </section>
  <section title="JavaScript API Reference" anchor="JavaScript-API-Reference">
    <t>OpenSocial's JavaScript API uses the following patterns:</t>
    <list style="hanging">
    <t hangText="Virtual Typing">
     <t>JavaScript is not strongly typed, but in order to make the developer
     experience consistent, the APIs are defined as if JavaScript supported
     strongly typed data. Cases where a parameter or return value are defined
     as a certain type in the documentation indicate that this is the only type
     that can be provided or accepted for OpenSocial compatibility. Any
     exceptions to this rule will be directly documented in the reference.</t>
     <t>As an example, the getErrorCode method is defined in the JavaScript API
     reference as returning a value of the type opensocial.ResponseItem.Error,
     although in practice this value will be a normal JavaScript string.
     However, developers can be assured that in a compliant container, the
     string returned is one of the opensocial.ResponseItem.Error fields.</t>
     <t>Enumerations figure heavily into the OpenSocial API. Developers are
     permitted to reference an enum or use the enum's value directly. To avoid
     collisions related to extensibility, containers must ensure that the names
     and values for an enum match the ones defined in the spec and that custom
     values are namespaced appropriately. For example, an Orkut custom field
     named MY_PERSON_FIELD could have a name of
     Orkut.PersonField.MY_PERSON_FIELD and a value of "Orkut.myPersonField".</t>
    </t>
    <t hangText="Parameter Maps">
     <t>Many of the OpenSocial methods have a large number of optional
     parameters. JavaScript's lack of strong typing makes overloading difficult
     at best, and having functions with a large amount of parameters can be
     difficult to manage (especially for developers not using a nice IDE).
     OpenSocial uses the "object bag" approach to optional parameters: many
     methods take an additional opt_params parameter that takes the form of a
     map of parameter names to their corresponding values.</t>
     <t>For each method which uses an opt_params map the spec defines all of
     the valid fields that will be read out of the map by the container. These
     fields have defined types as discussed in the Virtual typing section. If a
     developer adds an invalid value for a field in the map the container
     SHOULD return the BAD_REQUEST error code.</t>
    </t>
   </list>
   <section title="gadgets"
            anchor="gadgets">
    <!-- ============================== class summary ========================== -->
    <t>Namespace for top-level gadget functions.</t>
    <section title="Method Details">
     <section title="log"
              anchor="gadgets.log">
      <t>&lt;static&gt; gadgets.log(message)</t>
      <t>Description: Log an informational message.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>message</c>
       <c>Object</c>
       <c>The message to log</c>
      </texttable></t>
     </section>
     <section title="warn"
              anchor="gadgets.warn">
      <t>&lt;static&gt; gadgets.warn(message)</t>
      <t>Description: Log a warning message.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>message</c>
       <c>Object</c>
       <c>The message to log</c>
      </texttable></t>
     </section>
     <section title="error"
              anchor="gadgets.error">
      <t>&lt;static&gt; gadgets.error(message)</t>
      <t>Description: Log an error message.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>message</c>
       <c>Object</c>
       <c>The message to log</c>
      </texttable></t>
     </section>
     <section title="setLogLevel"
              anchor="gadgets.setLogLevel">
      <t>&lt;static&gt; gadgets.setLogLevel(logLevel)</t>
      <t>Description: Sets the log level threshold.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>logLevel</c>
       <c>Number</c>
       <c>New log level threshold.</c>
      </texttable></t>
     </section>
    </section>
    <section title="gadgets.log"
             anchor="gadgets.log">
     <t>Used by
     <xref target="gadgets.setLogLevel">gadgets.setLogLevel</xref>.</t>
     <list style="hanging">
     <t hangText="INFO"
              anchor="gadgets.log.INFO">
      Log level for informational logging.</t>
     <t hangText="WARN"
              anchor="gadgets.log.WARN">
      Log level for warning logging.</t>
     <t hangText="ERROR"
              anchor="gadgets.log.ERROR">
      Log level for error logging.</t>
     <t hangText="NONE"
              anchor="gadgets.log.NONE">
      Log level for no logging.</t>
    </list>
    </section>
   </section>

   <section title="gadgets.io"
            anchor="gadgets.io">
    <!-- ============================== class summary ========================== -->
    <t>Provides remote content retrieval functions.</t>
    <section title="Method Details">
     <section title="encodeValues"
              anchor="gadgets.io.encodeValues">
      <t>&lt;static&gt; Type: {String} gadgets.io.encodeValues(fields)</t>
      <t>Description: Converts an input object into a URL-encoded data string.
      (key=value&amp;...)</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>fields</c>
       <c>Object</c>
       <c>The post fields you wish to encode</c>
      </texttable></t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>String</c>
       <c>The processed post data; this includes a trailing ampersand
       (&amp;)</c>
      </texttable></t>
     </section>
     <section title="getProxyUrl"
              anchor="gadgets.io.getProxyUrl">
      <t>&lt;static&gt; Type: {String} gadgets.io.getProxyUrl(url,
      opt_params)</t>
      <t>Description: Gets the proxy version of the passed-in URL.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>url</c>
       <c>String</c>
       <c>The URL to get the proxy URL for</c>
       <c>opt_params</c>
       <c>Map&lt;String|String&gt;</c>
       <c>Additional optional
       <xref target="gadgets.io.ProxyUrlRequestParameters">parameters</xref> to
       pass to the request</c>
      </texttable></t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>String</c>
       <c>The proxied version of the URL</c>
      </texttable></t>
     </section>
     <section title="makeRequest"
              anchor="gadgets.io.makeRequest">
      <t>&lt;static&gt; gadgets.io.makeRequest(url, callback, opt_params)</t>
      <t>Description: Fetches content from the provided URL and feeds that
      content into the callback function.
      <figure>
       <preamble>Example:</preamble>
       <artwork xml:space="preserve">
var params = {};
params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.TEXT;
gadgets.io.makeRequest(url, callback, params);
</artwork>
      </figure></t>
      <section title="Signed authorization">
        <t>If opt_params[gadgets.io.RequestParameters.AUTHORIZATION] is set to
            gadgets.io.AuthorizationType.SIGNED, the container needs to vouch
            for the
            user's identity to the destination server. This follows the steps outlined in
            the
            <xref target="SignedFetch">Signed Fetch</xref>
            section of this specification.</t>
      </section>
      <section title="Key management">
       <t>Note: This text was moved to section <xref target="KeyManagement">OAuth Key Management</xref>
       </t>
      </section>
      <section title="OAuth authorization">
       <t>If opt_params[gadgets.io.RequestParameters.AUTHORIZATION] is set to
       gadgets.io.AuthorizationType.OAUTH, the container needs to use OAuth to
       gain access to the resource specified in the request. This may require
       that the gadget obtain the user's content by directing the user to the
       service provider to gain access.</t>
      </section>
      <section title="Additional parameters">
       <t>The following additional parameters may be specified in opt_params:

       <list style="hanging">
        <t hangText="gadgets.io.RequestParameters.ALIAS">Specifies the 'Alias' request parameter as defined by <eref target="Core-Data.xml#HTTP-Request-Params">Core-Data Request Parameters.</eref> <xref target='Issue-1178'>Discussion</xref></t>
        <t hangText="gadgets.io.RequestParameters.GET_FULL_HEADERS">Returns the full headers from the response.</t>
        <t hangText="gadgets.io.RequestParameters.OAUTH_RECEIVED_CALLBACK">The URL to return after authorization.</t>
        <t hangText="gadgets.io.RequestParameters.OAUTH_REQUEST_TOKEN">A
        service provider may be able to automatically provision a gadget with a
        request token that is preapproved for access to a resource. The gadget
        can use that token with the OAUTH_REQUEST_TOKEN parameter. This
        parameter is optional.</t>
        <t hangText="gadgets.io.RequestParameters.OAUTH_REQUEST_TOKEN_SECRET">
        The secret corresponding to a preapproved request token. This parameter
        is optional.</t>
        <t hangText="gadgets.io.RequestParameters.OAUTH_SERVICE_NAME">The
        nickname the gadget uses to refer to the OAuth &lt;Service&gt; element
        from its XML spec. If unspecified, defaults to "".</t>
        <t hangText="gadgets.io.RequestParameters.OAUTH2_SCOPE" 
        anchor="gadgets.io.RequestParameters.OAUTH2_SCOPE">
        The value of the OAuth 2.0 scope parameter to be used with this request.  Access Token Scope is
        defined in Section 3.3 of the <xref target='draft-ietf-oauth-v2-22'>
        OAuth 2.0</xref> specification.  <xref target="Issue-1209">Discussion</xref>
        </t>
        <t hangText="gadgets.io.RequestParameters.OAUTH_TOKEN_NAME">The
        nickname the gadget uses to refer to an OAuth token granting access to
        a particular resources. If unspecified, defaults to "". Gadgets can use
        multiple token names if they have access to multiple resources from the
        same service provider. For example, a gadget with access to a contact
        list and a calendar might use a token name of "contacts" to use the
        contact list token, and a contact list of "calendar" to use the
        calendar token.</t>
        <t hangText="gadgets.io.RequestParameters.OAUTH_USE_TOKEN">
   This parameter can be either "never", "if_available", or "always". Some
    service provider APIs to do not require an OAuth access token. Such
    APIs authenticate the calling application via the OAuth consumer
    key, and then allow the request to proceed. You can set
    OAUTH_USE_TOKEN to "never" to avoid unnecessarily requesting the
    user's approval to access such an API.
    <t>Some OAuth APIs provide limited data if a user has not granted approval,
    but can offer additional functionality if a user has granted the
    calling application an access token. If you are using an API that
    can accept an OAuth access token, but does not require the token,
    you can set OAUTH_USE_TOKEN to "if_available". If the user has
    already approved access, the access token will be sent. If the user
    has not approved access, the request will proceed without an access
    token.</t>
    <t>Many OAuth APIs only function if an access token is sent. You must ask for
    the user's approval before using such an API. Set OAUTH_USE_TOKEN to
    "always" to require that an access token be available. If no access
    token is available, the approval URL will be returned to your
    gadget.</t>
    <t>If you set AUTHORIZATION to SIGNED, the default value for OAUTH_USE_TOKEN
    is "never". If you set AUTHORIZATION to OAUTH, the default value for
    OAUTH_USE_TOKEN is "always".</t></t>
       </list></t>
        <t>If OAuth is used, the container should execute the OAuth protocol on
       behalf of the gadget. If the gadget has not registered a consumer key
       for use with this service provider, the container may choose to use a
       default RSA signing key corresponding to a well-known certificate to
       sign requests. If the container uses a default consumer key, it will
       include an additional OAuth parameter opensocial_app_url that identifies the
       gadget making the request.</t>
       <section title="Deprecated xoauth_app_url parameter">
       <t>
        When using Signed Fetch, the param used to indicate the URL of the
        application making the request is "opensocial_app_url". This has the
        same semantic as " xoauth_app_url". In order to
        be consistent, the same identifier will be used for OAuth. Containers
        SHOULD use "opensocial_app_url" and treat "xoauth_app_url" as
        deprecated. However, for backward compatibility, and to avoid
        breaking a container on a point release,
        MUST support either parameter. </t>
       </section>
      </section>
      <section title="The callback parameter">
       <t>The function specified as the callback parameter is passed a JavaScript object with the following fields:
       <list style="hanging">
         <t hangText="data">Parsed data of the response, if applicable. This will contain a different type of data depending on the type of request that was made. See the ContentType parameters for information about what to expect in this field. The raw response text is returned if the response could not be parsed.</t>
         <t hangText="errors">This will contain an array of any errors that occurred when making this request. For example, if a 500 error occurred in the request: [ "500 error" ]</t>
         <t hangText="headers">An object containing the response headers. Header names are used as the keys for this object.</t>
         <t hangText="rc">This is a numeric value representing the HTTP status code of the response.</t>
         <t hangText="text">This will return the unparsed text of the response.</t>
        <t hangText="oauthApprovalUrl">If this value is specified, the user
        needs to visit an external page to approve the gadget's request to
        access data. Use of a pop-up window to direct the user to the external
        page is recommended. Once the user has approved access, the gadget can
        repeat the makeRequest call to retrieve the data.</t>
        <t hangText="oauthError">
        If this value is specified, it indicates an
        OAuth-related error occurred. The value will be one of a set of string
        constants that can be used for programmatically detecting errors.
        </t>
        <t hangText="oauthErrorText">If this value is specified, it indicates
        an OAuth-related error occurred. The value is free-form text that can
        be used to provide debugging information for gadget developers.</t>
       </list></t>
      </section>
      <section title="Parameters">
       <t>
        <texttable align="left">
         <ttcol>Name</ttcol>
         <ttcol>Type</ttcol>
         <ttcol>Description</ttcol>
         <c>url</c>
         <c>String</c>
         <c>The URL where the content is located</c>
         <c>callback</c>
         <c>Function</c>
         <c>The function to call with the data from the URL once it is fetched.
         The callback function will not be called until after the existing
         callstack has completed execution.</c>
         <c>opt_params</c>
         <c>Map.&lt;gadgets.io.RequestParameters|Object&gt;</c>
         <c>Additional
         <xref target="gadgets.io.RequestParameters">request
         parameters</xref> or
         <xref target="gadgets.io.ProxyUrlRequestParameters">proxy request
         parameters</xref> </c>
        </texttable>
       </t>
      </section>
     </section>
    </section>
   </section>
   <section title="gadgets.io.AuthorizationType"
            anchor="gadgets.io.AuthorizationType">
    <!-- ============================== class summary ========================== -->
    <t>Used by
    <xref target="gadgets.io.RequestParameters">RequestParameters</xref>.</t>

    <list style="hanging">
     <t hangText="NONE"
              anchor="gadgets.io.AuthorizationType.NONE">
      No authorization. This field may be used interchangeably
      with the string 'NONE'.</t>
     <t hangText="OAUTH"
              anchor="gadgets.io.AuthorizationType.OAUTH">
     The container will use OAuth 1.0A for authentication. This
      field may be used interchangeably with the string 'OAUTH'.</t>
      <t hangText="OAUTH2"
              anchor="gadgets.io.AuthorizationType.OAUTH2">
     The container will use OAuth 2.0 for authentication. This
      field may be used interchangeably with the string 'OAUTH2'. <xref target='Issue-1138'>Discussion</xref>
     </t>
     <t hangText="SIGNED"
              anchor="gadgets.io.AuthorizationType.SIGNED">
     The request will be signed by the container. This field
      may be used interchangeably with the string 'SIGNED'.</t>
    </list>
   </section>
   <section title="gadgets.io.ContentType"
            anchor="gadgets.io.ContentType">
    <!-- ============================== class summary ========================== -->
    <t>Used by
    <xref target="gadgets.io.RequestParameters">RequestParameters</xref>.</t>
    <list style="hanging">
     <t hangText="DOM"
              anchor="gadgets.io.ContentType.DOM">
      Returns a DOM object; used for fetching XML. This field
      may be used interchangeably with the string 'DOM'.</t>
     <t hangText="FEED"
              anchor="gadgets.io.ContentType.FEED">
      Returns a JSON representation of an RSS or Atom feed.
      This field may be used interchangeably with the string 'FEED'.</t>
     <t hangText="JSON"
              anchor="gadgets.io.ContentType.JSON">
      Returns a JSON object. This field may be used
      interchangeably with the string 'JSON'.</t>
     <t hangText="TEXT"
              anchor="gadgets.io.ContentType.TEXT">
      Returns text; used for fetching HTML. This field may be
      used interchangeably with the string 'TEXT'.</t>
    </list>
   </section>
   <section title="gadgets.io.MethodType"
            anchor="gadgets.io.MethodType">
    <!-- ============================== class summary ========================== -->
    <t>Defines values for
    <xref target="gadgets.io.RequestParameters.METHOD">
    RequestParameters.METHOD</xref>.</t>
    <list style="hanging">
     <t hangText="DELETE"
              anchor="gadgets.io.MethodType.DELETE">
      Container support for this method type is OPTIONAL. This
      field may be used interchangeably with the string 'DELETE'.</t>
     <t hangText="GET"
              anchor="gadgets.io.MethodType.GET">
      The default type. This field may be used interchangeably
      with the string 'GET'.</t>
     <t hangText="HEAD"
              anchor="gadgets.io.MethodType.HEAD">
      Container support for this method type is OPTIONAL. This
      field may be used interchangeably with the string 'HEAD'.</t>
     <t hangText="POST"
              anchor="gadgets.io.MethodType.POST">
      Container support for this method type is OPTIONAL. This
      field may be used interchangeably with the string 'POST'.</t>
     <t hangText="PATCH"
              anchor="gadgets.io.MethodType.PATCH">
      <x:incubating href="http://code.google.com/p/opensocial-resources/issues/detail?id=1200" note="Add support for HTTP PATCH">
      Container support for this method type is OPTIONAL. This
      field may be used interchangeably with the string 'PATCH'.</x:incubating></t>
     <t hangText="PUT"
              anchor="gadgets.io.MethodType.PUT">
      Container support for this method type is OPTIONAL. This
      field may be used interchangeably with the string 'PUT'.</t>
    </list>
   </section>
   <section title="gadgets.io.ProxyUrlRequestParameters"
            anchor="gadgets.io.ProxyUrlRequestParameters">
    <!-- ============================== class summary ========================== -->
    <t>Used by
    <xref target="gadgets.io.getProxyUrl">
    gadgets.io.getProxyUrl()</xref> method.</t>
    <list style="hanging">
     <t hangText="REFRESH_INTERVAL"
              anchor="gadgets.io.ProxyUrlRequestParameters.REFRESH_INTERVAL">
      Explicitly sets the lifespan of cached content. The
      Refresh Interval is the number of seconds the container should cache the
      given response. By default, the HTTP caching headers will be respected
      for fetched content. If the refresh interval is set, this value will take
      precedence over any HTTP cache headers. If this value is not set and
      there are no HTTP caching headers specified, this value will default to
      3600 (one hour). Note that Signed requests and objects with POST_DATA
      present will generally not be cached. This field may be used
      interchangeably with the string 'REFRESH_INTERVAL'.</t>
    </list>
   </section>
   <section title="gadgets.io.RequestParameters"
            anchor="gadgets.io.RequestParameters">
    <!-- ============================== class summary ========================== -->
    <t>Used by the
    <xref target="gadgets.io.makeRequest">
    gadgets.io.makeRequest()</xref> method.</t>
    <list style="hanging">
     <t hangText="AUTHORIZATION"
              anchor="gadgets.io.RequestParameters.AUTHORIZATION">
      The type of authentication to use when fetching the
      content; defaults to AuthorizationType.NONE. Specified as an
      <xref target="gadgets.io.AuthorizationType">AuthorizationType</xref>.
      This field may be used interchangeably with the string
      'AUTHORIZATION'.</t>
     <t hangText="CONTENT_TYPE"
              anchor="gadgets.io.RequestParameters.CONTENT_TYPE">
      The type of content that lives at the URL; defaults to
      ContentType.TEXT. Specified as a
      <xref target="gadgets.io.ContentType">ContentType</xref>. This field may
      be used interchangeably with the string 'CONTENT_TYPE'.</t>
     <t hangText="GET_SUMMARIES"
              anchor="gadgets.io.RequestParameters.GET_SUMMARIES">
      If the content is a feed, whether to fetch summaries for
      that feed; defaults to false. Specified as a Boolean. This field may be
      used interchangeably with the string 'GET_SUMMARIES'.</t>
     <t hangText="HEADERS"
              anchor="gadgets.io.RequestParameters.HEADERS">
      The HTTP headers to send to the URL; defaults to null.
      Specified as a Map.&lt;String,String&gt;. This field may be used
      interchangeably with the string 'HEADERS'.</t>
     <t hangText="METHOD"
              anchor="gadgets.io.RequestParameters.METHOD">
      The method to use when fetching content from the URL;
      defaults to
      <xref target="gadgets.io.MethodType.GET">MethodType.GET</xref>. Valid
      values are specified by
      <xref target="gadgets.io.MethodType">MethodType</xref>. This field may be
      used interchangeably with the string 'METHOD'.</t>
     <t hangText="NUM_ENTRIES"
              anchor="gadgets.io.RequestParameters.NUM_ENTRIES">
      If the content is a feed, the number of entries to fetch;
      defaults to 3. Specified as a Number. This field may be used
      interchangeably with the string 'NUM_ENTRIES'.</t>
     <t hangText="POST_DATA"
              anchor="gadgets.io.RequestParameters.POST_DATA">
      The data to send to the URL using the POST method;
      defaults to null. Specified as a String. This field may be used
      interchangeably with the string 'POST_DATA'.</t>
     <t hangText="REFRESH_INTERVAL"
              anchor="gadgets.io.RequestParameters.REFRESH_INTERVAL">
      Explicitly sets the lifespan of cached content. The
      Refresh Interval is the number of seconds the container should cache the
      given response. By default, the HTTP caching headers will be respected
      for fetched content. If the refresh interval is set, this value will take
      precedence over any HTTP cache headers. If this value is not set and
      there are no HTTP caching headers specified, this value will default to
      3600 (one hour). Note that Signed requests and objects with POST_DATA
      present will generally not be cached. This field may be used
      interchangeably with the string 'REFRESH_INTERVAL'.</t>
     <t hangText="SIGN_OWNER"
              anchor="gadgets.io.RequestParameters.SIGN_OWNER">
      Indicates that the container should include the owner ID when signing the request. Specified as a Boolean. This field may be used interchangeably with the string 'SIGN_OWNER'.</t>
     <t hangText="SIGN_VIEWER"
              anchor="gadgets.io.RequestParameters.SIGN_VIEWER">
      Indicates that the container should include the viewer ID when signing the request. Specified as a Boolean. This field may be used interchangeably with the string 'SIGN_VIEWER'.</t>
    </list>
   </section>
   <section title="gadgets.json"
            anchor="gadgets.json">
    <!-- ============================== class summary ========================== -->
    <t>Provides operations for translating objects to and from JSON.</t>
    <section title="Method Details">
     <section title="parse"
              anchor="gadgets.json.parse">
      <t>&lt;static&gt; Type: {Object} gadgets.json.parse(text)</t>
      <t>Description: Parses a JSON string, producing a JavaScript value.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>text</c>
       <c>String</c>
       <c>The string to transform into an object; usually the result of a
       previous stringify call</c>
      </texttable></t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>Object</c>
       <c>The object parsed from the passed in text; false if an error
       occurred</c>
      </texttable></t>
     </section>
     <section title="stringify"
              anchor="gadgets.json.stringify">
      <t>&lt;static&gt; Type: {String} gadgets.json.stringify(v)</t>
      <t>Description: Converts a JavaScript value to a JSON string.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>v</c>
       <c>Object</c>
       <c>The object to convert</c>
      </texttable></t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>String</c>
       <c>The JSON equivalent</c>
      </texttable></t>
     </section>
    </section>
   </section>
   <section title="gadgets.Prefs"
            anchor="gadgets.Prefs">
    <!-- ============================== class summary ========================== -->
    <t>Provides access to user preferences, module dimensions, and messages.
    Clients can access their preferences by constructing an instance of
    gadgets.Prefs and passing in their module ID. Example:
    <figure>
     <artwork xml:space="preserve">
var prefs = new gadgets.Prefs();
var name = prefs.getString("name");
var lang = prefs.getLang();
</artwork>
    </figure></t>
    <!-- ============================== constructor details ==================== -->
    <section title="Constructor"
             anchor="gadgets.Prefs.ctor">
     <t>gadgets.Prefs(opt_moduleId)</t>
     <t>Creates a new Prefs object.</t>
     <t>Parameters:
     <texttable align="left">
      <ttcol>Name</ttcol>
      <ttcol>Type</ttcol>
      <ttcol>Description</ttcol>
      <c>opt_moduleId</c>
      <c>String | Number</c>
      <c>An optional parameter specifying the module ID to create prefs for; if
      not provided, the default module ID is used</c>
     </texttable></t>
    </section>
    <section title="Method Details">
     <section title="getArray"
              anchor="gadgets.Prefs.getArray">
      <t>Type: {Array.&lt;String&gt;} getArray(key)</t>
      <t>Description: Retrieves a preference as an array. UserPref values that
      were not declared as lists are treated as one-element arrays.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>key</c>
       <c>String</c>
       <c>The preference to fetch</c>
      </texttable></t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>Array.&lt;String&gt;</c>
       <c>The preference; if not set, an empty array</c>
      </texttable></t>
     </section>
     <section title="getBool"
              anchor="gadgets.Prefs.getBool">
      <t>Type: {Boolean} getBool(key)</t>
      <t>Description: Retrieves a preference as a boolean.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>key</c>
       <c>String</c>
       <c>The preference to fetch</c>
      </texttable></t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>Boolean</c>
       <c>The preference; if not set, false</c>
      </texttable></t>
     </section>
     <section title="getCountry"
              anchor="gadgets.Prefs.getCountry">
      <t>Type: {String} getCountry()</t>
      <t>Description: Gets the current country, returned as ISO 3166-1 alpha-2
      code.</t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>String</c>
       <c>The country for this module instance</c>
      </texttable></t>
     </section>
     <section title="getFloat"
              anchor="gadgets.Prefs.getFloat">
      <t>Type: {Number} getFloat(key)</t>
      <t>Description: Retrieves a preference as a floating-point value.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>key</c>
       <c>String</c>
       <c>The preference to fetch</c>
      </texttable></t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>Number</c>
       <c>The preference; if not set, 0</c>
      </texttable></t>
     </section>
     <section title="getInt"
              anchor="gadgets.Prefs.getInt">
      <t>Type: {Number} getInt(key)</t>
      <t>Description: Retrieves a preference as an integer.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>key</c>
       <c>String</c>
       <c>The preference to fetch</c>
      </texttable></t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>Number</c>
       <c>The preference; if not set, 0</c>
      </texttable></t>
     </section>
     <section title="getLang"
              anchor="gadgets.Prefs.getLang">
      <t>Type: {String} getLang()</t>
      <t>Description: Gets the current language the gadget should use when
      rendering, returned as a ISO 639-1 language code.</t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>String</c>
       <c>The language for this module instance</c>
      </texttable></t>
     </section>
     <section title="getModuleId"
              anchor="gadgets.Prefs.getModuleId">
      <t>Type: {String | Number} getModuleId()</t>
      <t>Description: Gets the module ID for the current instance.</t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>String | Number</c>
       <c>The module ID for this module instance</c>
      </texttable></t>
     </section>
     <section title="getMsg"
              anchor="gadgets.Prefs.getMsg">
      <t>Type: {String} getMsg(key)</t>
      <t>Description: Fetches an unformatted message.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>key</c>
       <c>String</c>
       <c>The message to fetch</c>
      </texttable></t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>String</c>
       <c>The message</c>
      </texttable></t>
     </section>
     <section title="getString"
              anchor="gadgets.Prefs.getString">
      <t>Type: {String} getString(key)</t>
      <t>Description: Retrieves a preference as a string.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>key</c>
       <c>String</c>
       <c>The preference to fetch</c>
      </texttable></t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>String</c>
       <c>The preference; if not set, an empty string</c>
      </texttable></t>
     </section>
     <section title="set"
              anchor="gadgets.Prefs.set">
      <t>set(key, val)</t>
      <t>Description: Stores a preference. To use this call, the gadget must
      require the feature setprefs.
      <t>Note: If the gadget needs to store an Array it should use setArray
      instead of this call.</t></t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>key</c>
       <c>String</c>
       <c>The pref to store</c>
       <c>val</c>
       <c>Object</c>
       <c>The values to store</c>
      </texttable></t>
     </section>
     <section title="setArray"
              anchor="gadgets.Prefs.setArray">
      <t>setArray(key, val)</t>
      <t>Description: Stores an array preference. To use this call, the gadget
      must require the feature setprefs.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>key</c>
       <c>String</c>
       <c>The pref to store</c>
       <c>val</c>
       <c>Array</c>
       <c>The values to store</c>
      </texttable></t>
     </section>
    </section>
   </section>
   <section title="gadgets.util"
            anchor="gadgets.util">
    <!-- ============================== class summary ========================== -->
    <t>Provides general-purpose utility functions.</t>
    <section title="Method Details">
     <section title="escapeString"
              anchor="gadgets.util.escapeString">
      <t>&lt;static&gt; Type: {String} gadgets.util.escapeString(str)</t>
      <t>Description: Escapes the input using HTML entities to make it safer.
      The following characters are affected:
      <list style="symbols">
       <t>newline (\n, Unicode code point 10)</t>
       <t>carriage return (\r, Unicode 13)</t>
       <t>double quote (", Unicode 34)</t>
       <t>ampersand (&amp;, Unicode 38)</t>
       <t>single quote (', Unicode 39)</t>
       <t>left angle bracket (&lt;, Unicode 60)</t>
       <t>right angle bracket (&gt;, Unicode 62)</t>
       <t>backslash (\, Unicode 92)</t>
       <t>line separator (Unicode 8232)</t>
       <t>paragraph separator (Unicode 8233)</t>
      </list></t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>str</c>
       <c>String</c>
       <c>The string to escape</c>
      </texttable></t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>String</c>
       <c>The escaped string</c>
      </texttable></t>
     </section>
     <section title="getFeatureParameters"
              anchor="gadgets.util.getFeatureParameters">
      <t>&lt;static&gt; Type: {Object}
      gadgets.util.getFeatureParameters(feature)</t>
      <t>Description: Returns the value of parameters for this feature. A
      gadget specifies parameters using the &lt;Param&gt; subelement of the
      &lt;Requires&gt; or &lt;Optional&gt; element.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>feature</c>
       <c>String</c>
       <c>The feature to get parameters for</c>
      </texttable></t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>Object</c>
       <c>The parameters for the given feature, or null</c>
      </texttable></t>
     </section>
     <section title="hasFeature"
              anchor="gadgets.util.hasFeature">
      <t>&lt;static&gt; Type: {Boolean} gadgets.util.hasFeature(feature)</t>
      <t>Description: Returns whether the specified feature is supported.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>feature</c>
       <c>String</c>
       <c>The feature to test for</c>
      </texttable></t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>Boolean</c>
       <c>True if the feature is supported</c>
      </texttable></t>
     </section>
     <section title="registerOnLoadHandler"
              anchor="gadgets.util.registerOnLoadHandler">
      <t>&lt;static&gt; gadgets.util.registerOnLoadHandler(callback)</t>
      <t>Description: Registers an onload handler; a function that's executed
      when the gadget loads. Multiple handlers can be registered, and all will
      be invoked in the same order that they were registered.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>callback</c>
       <c>Function</c>
       <c>The handler to run. The callback function will not be called until
       after the existing callstack has completed execution.</c>
      </texttable></t>
     </section>
     <section title="sanitizeHtml"
              anchor="gadgets.util.sanitizeHtml">
      <t>&lt;static&gt; Type: {String} gadgets.util.sanitizeHtml(text)</t>
      <t>Description: Sanitizes a text string. The returned value is safe to
      assign to innerHTML. The returned value may include HTML tags. If plain
      text is desired, use gadgets.util.escapeString instead.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>text</c>
       <c>String</c>
       <c>arbitrary text string</c>
      </texttable></t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>String</c>
       <c>a sanitized version that may include HTML tags, but will not execute
       script.</c>
      </texttable></t>
     </section>
     <section title="unescapeString"
              anchor="gadgets.util.unescapeString">
      <t>&lt;static&gt; Type: {String} gadgets.util.unescapeString(str)</t>
      <t>Description: Reverses escapeString</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>str</c>
       <c>String</c>
       <c>The string to unescape.</c>
      </texttable></t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>String</c>
       <c>The unescaped string</c>
      </texttable></t>
     </section>
    </section>
   </section>
   <section title="gadgets.views"
            anchor="gadgets.views">
    <!-- ============================== class summary ========================== -->
    <t>Provides operations for dealing with views.
    <t>See also:
    <xref target="gadgets.views.View">gadgets.views.View</xref> </t></t>
    <section title="Method Details">
    <x:deprecated note="Deprecated in OpenSocial 2.5" href="http://code.google.com/p/opensocial-resources/issues/detail?id=1309">
     <section title="bind"
              anchor="gadgets.views.bind">
      <t>&lt;static&gt; Type: {String} gadgets.views.bind(urlTemplate,
      environment)</t>
      <t>Description: Binds a URL template with variables in the passed
      environment to produce a URL string.
      <t>See also:
      <xref target="gadgets.views.View.getUrlTemplate">
      View.getUrlTemplate()</xref> </t></t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>urlTemplate</c>
       <c></c>
       <c>A url template for a container view</c>
       <c>environment</c>
       <c></c>
       <c>A set of named variables (for example, [OWNER | PATH | PARAMS |
       NAME]) of type string.</c>
      </texttable></t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>String</c>
       <c>A URL string</c>
      </texttable></t>
     </section>
    </x:deprecated>
     <section title="getCurrentView"
              anchor="gadgets.views.getCurrentView">
      <t>&lt;static&gt; Type: {
      <xref target="gadgets.views.View">gadgets.views.View</xref> }
      gadgets.views.getCurrentView()</t>
      <t>Description: Returns the current view.</t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>
        <xref target="gadgets.views.View">gadgets.views.View</xref>
       </c>
       <c>The current view</c>
      </texttable></t>
     </section>
     <section title="getParams"
              anchor="gadgets.views.getParams">
      <t>&lt;static&gt; Type: {Map.&lt;String|String&gt;}
      gadgets.views.getParams()</t>
      <t>Description: Returns the parameters passed into this gadget for this
      view. Does not include all URL parameters, only the ones passed into
      gadgets.views.requestNavigateTo.</t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>Map.&lt;String|String&gt;</c>
       <c>The parameter map</c>
      </texttable></t>
     </section>
     <section title="getSupportedViews"
              anchor="gadgets.views.getSupportedViews">
      <t>&lt;static&gt; Type: {Map&lt;gadgets.views.ViewType |
      String|gadgets.views.View&gt;} gadgets.views.getSupportedViews()</t>
      <t>Description: Returns a map of all the supported views. Keys each
      gadgets.view.View by its name. This function only returns the primary
      views and does not return any secondary views. Example: if the markup
      indicates a set of views named Canvas.About, Profile.About, Home.About,
      Canvas.Help the returned views will only be Canvas, Profile, Home.</t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>Map&lt;gadgets.views.ViewType | String|gadgets.views.View&gt;</c>
       <c>All supported views, keyed by their name attribute.</c>
      </texttable></t>
     </section>
     <section title="requestNavigateTo"
              anchor="gadgets.views.requestNavigateTo">
      <t>&lt;static&gt; gadgets.views.requestNavigateTo(view, opt_params, opt_ownerId)</t>
      <t>Description: Attempts to navigate to this gadget in a different view.
      If the container supports parameter passing it will pass the optional
      parameters along to the gadget in the new view. This also allows for
      navigation to named views on the current surface. Views are composed of
      names that are [Surface](.[Secondary])?. The canonical Surface names are
      defined by the <xref target="gadgets.views.ViewType">View Type</xref>. The Secondary names are user defined. When
      navigating from [Surface].valueX to [Surface].valueY, the container can
      stay on the same Surface but will show the appropriate &lt;Content&gt;
      sections whose View is [Surface].valueY. When navigating from
      SurfaceA.[Secondary] to SurfaceB.[Secondary], the container will switch
      to the SurfaceB surface and show the appropriate &lt;Content&gt; sections
      whose View is SurfaceB.[Secondary].  In no case must the .[Secondary] item be declared. <xref target="Issue-1169">Discussion</xref></t>
      <t>Parameters:
      
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>view</c>
       <c>gadgets.views.View</c>
       <c>If set to a string, the name of the view to navigate
       to. If set to a View, the View object to navigate to. Passing a View has
       been deprecated.</c>
       <c>opt_params</c>
       <c>Map&lt;String|String&gt;</c>
       <c>If the value is an object, it represents
       parameters to pass to the gadget after it has been navigated to on the
       surface. If the view navigated to contains an href and opt_params is a
       string, the value in opt_params is treated as a relative path that must
       be resolved relative to the href of the referenced view according to RFC
       3986. If opt_params is a string all query parameters including query
       parameters encoded in a fragment are available in the receiving view
       using gadgets.views.getParams()</c>
       <c>opt_ownerId</c>
       <c>String</c>
       <c>The ID of the owner of the page to navigate to; defaults to the
       current owner</c>
      </texttable><xref target="Issue-1300">Discussion</xref></t>
     </section>
     <section title="openGadget"
              anchor="gadgets.views.openGadget">
       <t>&lt;static&gt; gadgets.views.openGadget(resultCallback, navigateCallback, opt_params)</t>
       <t>Description: Opens a gadget in the container UI. The location of the gadget site
       in the container will be determined by the view target passed in. The container
       would open the view in a dialog, if view target is dialog or the gadgets
       view in a tab for view target is tab.   <xref target="Issue-1167">Discussion</xref></t>
       <t>Parameters:
        <texttable align="left">
         <ttcol>Name</ttcol>
         <ttcol>Type</ttcol>
         <ttcol>Description</ttcol>
         <c>resultCallback</c>
         <c>function</c>
         <c>Callback function to be called when the gadget closes.
         The function will be called with the return value as a parameter.</c>
         <c>navigateCallback</c>
         <c>function</c>
         <c>Callback function to be called with the site handler and metadata as parameters.
         The site handler can only be used as parameter in gadgets.views.close(opt_site_handler).</c>
         <c>opt_params </c>
         <c>Object</c>
         <c>These are optional parameters which can be used to open gadgets.
         The following parameters may be included in this object. </c>
        </texttable></t>
       <t>opt_params:
       <x:incubating href="http://code.google.com/p/opensocial-resources/issues/detail?id=1231" note="Issue 1231:  Enhance open-views and CommonContainer apis to allow for opening gadgets/ees/views at specific locations">
        <texttable align="left">
         <ttcol>Name</ttcol>
         <ttcol>Type</ttcol>
         <ttcol>Description</ttcol>
         <c>view </c>
         <c>string </c>
         <c>The surface view that indicates the type of gadget site.</c>
         <c>viewTarget </c>
         <c>string </c>
         <c>The view that indicates where to open the gadget. For example,
          <xref target="gadgets.views.ViewType.ViewTarget">tab, dialog or modaldialog</xref>.</c>
         <c>viewParams </c>
         <c>Object</c>
         <c>View parameters for the view being rendered.</c>
         <c>coordinates</c>
         <c>Object</c>
         <c>
           Object containing the desired absolute positioning css parameters 
           (top|bottom|left|right) with appropriate values. All values are 
           relative to the calling gadget. Do not specify top AND bottom or
           left AND right parameters to indirectly define height and width. Use 
           viewParams for that. The result of doing so here is undefined.
           
           Container implementations SHOULD honor optionally specified 
           coordinates for the FLOAT viewTarget. Containers MAY honor 
           coordinates for any other target they choose.
         </c>
        </texttable><xref target="Issue-1231">Discussion</xref></x:incubating></t>
     </section>
     <section title="openEmbeddedExperience" 
     anchor="gadgets.views.openEmbeddedExperience">
     <t>&lt;static&gt; 
     gadgets.views.openEmbeddedExperience(resultCallback, navigateCallback, dataModel, opt_params)</t>
       <t>Description: Opens an embedded experience in the container UI. The location 
       of the gadget or URL site in the container will be determined by the view target 
       passed in. The container would open the embedded experience in a dialog, if view 
       target is dialog or the embedded exerience view in a tab for view target is tab.   
       <xref target="Issue-1167">Discussion</xref></t>
       <t>Parameters:
        <texttable align="left">
         <ttcol>Name</ttcol>
         <ttcol>Type</ttcol>
         <ttcol>Description</ttcol>
         <c>resultCallback</c>
         <c>function</c>
         <c>Callback function to be called when the gadget closes.
         The function will be called with the return value as a parameter.</c>
         <c>navigateCallback</c>
         <c>function</c>
         <c>Callback function to be called with the site handler and metadata as parameters.
         The site handler can only be used as parameter in gadgets.views.close(opt_site_handler).</c>
         <c>dataModel</c>
         <c>Object</c>
         <c>The embedded experiences data model.  If a String is passed, it is assumed to be a parsable XML representation of the embedded experiences data model. 
         See appendix on <xref target="Embedded-Experiences">the embedded experiences data model</xref> <xref target="Issue-1321">Discussion</xref></c>
         <c>opt_params </c>
         <c>Object</c>
         <c>These are optional parameters which can be used to open gadgets.
         The following parameters may be included in this object. </c>
        </texttable></t>
       <t>opt_params:
       <x:incubating href="http://code.google.com/p/opensocial-resources/issues/detail?id=1231" note="Issue 1231:  Enhance open-views and CommonContainer apis to allow for opening gadgets/ees/views at specific locations">
        <texttable align="left">
         <ttcol>Name</ttcol>
         <ttcol>Type</ttcol>
         <ttcol>Description</ttcol>
         <c>viewTarget </c>
         <c>string </c>
         <c>The view that indicates where to open the gadget. For example,
          <xref target="gadgets.views.ViewType.ViewTarget">tab, dialog or modaldialog</xref>.</c>
         <c>viewParams </c>
         <c>Object</c>
         <c>View parameters for the view being rendered.</c>
         <c>coordinates</c>
         <c>Object</c>
         <c>
           Object containing the desired absolute positioning css parameters 
           (top|bottom|left|right) with appropriate values. All values are 
           relative to the calling gadget. Do not specify top AND bottom or
           left AND right parameters to indirectly define height and width. Use 
           viewParams for that. The result of doing so here is undefined.
           
           Container implementations SHOULD honor optionally specified 
           coordinates for the FLOAT viewTarget. Containers MAY honor 
           coordinates for any other target they choose.
         </c>
        </texttable><xref target="Issue-1231">Discussion</xref>
        </x:incubating></t>
     </section>
     <section title="openUrl"
              anchor="gadgets.views.openUrl">
       <t>&lt;static&gt; gadgets.views.openUrl(url, navigateCallback, opt_viewTarget)</t>
       <t>Description: Opens a URL in the container UI. The location of the URL site will be determined by the container
       based on the target view. The container would open the view in a dialog,
       if opt_viewTarget=dialog or the gadgets view in a tab for opt_viewTarget=tab.   <xref target="Issue-1167">Discussion</xref></t>
       <t>Parameters:
       <x:incubating href="http://code.google.com/p/opensocial-resources/issues/detail?id=1231" note="Issue 1231:  Enhance open-views and CommonContainer apis to allow for opening gadgets/ees/views at specific locations">
        <texttable align="left">
         <ttcol>Name</ttcol>
         <ttcol>Type</ttcol>
         <ttcol>Description</ttcol>
         <c>url</c>
         <c>string</c>
         <c>URL to a web page to open in a URL site in the container.  (Note this should not be a URL to a gadget definition.)</c>
         <c>navigateCallback</c>
         <c>function</c>
         <c>Callback function to be called with the handler of the site which has been opened.
         The site handler can only be used as paramater in gadgets.views.close(opt_site_handler).</c>
         <c>opt_viewTarget </c>
         <c>string </c>
         <c>Optional parameter,the view that indicates where to open the URL.</c>
         <c>opt_coordinates</c>
         <c>Object</c>
         <c>
           Optional parameter, Object containing the desired absolute 
           positioning css parameters (top|bottom|left|right) with appropriate
           values. All values are relative to the calling gadget. You may 
           specify top AND bottom or left AND right parameters to indirectly 
           define height and width.
           
           Container implementations SHOULD honor optionally specified 
           coordinates for the FLOAT viewTarget. Containers MAY honor 
           coordinates for any other target they choose.
         </c>
        </texttable><xref target="Issue-1231">Discussion</xref></x:incubating></t>
     </section>
     <section title="close"
              anchor="gadgets.views.close">
       <t>&lt;static&gt; gadgets.views.close(opt_site_handler)</t>
       <t>Description: Closes an opened site. If the opt_site_handler parameter is null the container 
       will close the calling site.   <xref target="Issue-1167">Discussion</xref></t>
       <t>Parameters:
        <texttable align="left">
         <ttcol>Name</ttcol>
         <ttcol>Type</ttcol>
         <ttcol>Description</ttcol>
         <c>opt_site_handler</c>
         <c>Object</c>
         <c>Optional parameter which specifies handler to what site to close. If null it will close the current gadget site.</c>
        </texttable></t>
     </section>
     <section title="setReturnValue"
              anchor="gadgets.views.setReturnValue">

       <t>&lt;static&gt; gadgets.views.setReturnValue(returnValue)</t>
       <t>Description: Sets the return value for the current window.
       This method should only be called inside those secondary view types defined in gadgets.views.ViewType.
       For example, <xref target="gadgets.views.ViewType.ViewTarget">DIALOG or MODALDIALOG</xref>.  <xref target="Issue-1167">Discussion</xref></t>
       <t>Parameters:
        <texttable align="left">
         <ttcol>Name</ttcol>
         <ttcol>Type</ttcol>
         <ttcol>Description</ttcol>
         <c>returnValue</c>
         <c>Object</c>
         <c>A serializable JSON object which specifies return value.</c>
        </texttable> </t>
     </section>

    </section>
   </section>
   <section title="gadgets.views.View"
            anchor="gadgets.views.View">
    <!-- ============================== class summary ========================== -->
    <t>Base interface for all view objects.</t>
    <section title="Method Details">
    <x:deprecated href="http://code.google.com/p/opensocial-resources/issues/detail?id=1309" note="Deprecated in OpenSocial 2.5"> 
     <section title="bind"
              anchor="gadgets.views.View.bind">
      <t>Type: {String} bind(environment)</t>
      <t>Description: Binds the view's URL template with variables in the
      passed environment to produce a URL string.
      <t>See also:
      <xref target="gadgets.views.View.getUrlTemplate">
      getUrlTemplate()</xref> </t></t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>environment</c>
       <c></c>
       <c>A set of named variables (for example, [OWNER | PATH | PARAMS |
       NAME]) of type string.</c>
      </texttable></t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>String</c>
       <c>A URL string</c>
      </texttable></t>
     </section>
   </x:deprecated>
     <section title="getName"
              anchor="gadgets.views.View.getName">
      <t>Type: {
      <xref target="gadgets.views.ViewType">gadgets.views.ViewType</xref> |
      String} getName()</t>
      <t>Description: Returns the name of this view.</t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>
       <xref target="gadgets.views.ViewType">gadgets.views.ViewType</xref> |
       String</c>
       <c>The view name, usually specified as a gadgets.views.ViewType</c>
      </texttable></t>
     </section>
   <x:deprecated href="http://code.google.com/p/opensocial-resources/issues/detail?id=1309" note="Deprecated in OpenSocial 2.5">
     <section title="getUrlTemplate"
              anchor="gadgets.views.View.getUrlTemplate">
      <t>Type: {String} getUrlTemplate()</t>
      <t>Description: Returns a string URI template conforming to the
      <eref target="http://bitworking.org/projects/URI-Templates/spec/draft-gregorio-uritemplate-03">
      IETF spec draft</eref> with variables for substitution.
      <t>Four variables are supported:</t>
      <list style="hanging">
      <t hangText="name">The name or ID of the application</t>
      <t hangText="owner">The ID of the owner of the page</t>
      <t hangText="path">An array of path steps</t>`
      <t hangText="params">Associative array or
      array[param1,value1,param2,value2,...]</t></list>Example
      <figure>
       <preamble>Here are two valid URL template strings:</preamble>
       <artwork xml:space="preserve">
http://container.com/{-list|/|name,owner,path}?{-join|&amp;|params}
http://container.com/apps/{name}/{owner}{-prefix|/|path}{-opt|?os_|params}{-join|&amp;os_|params}
</artwork>
      </figure>
      <t>Here are some parameters:</t>
      <figure>
       <artwork xml:space="preserve">
{
    name : 'Wilma',
    owner : 'Betty',
    path : ['dino','car'],
    params : { a : 'Barney', b : 'Fred'}
}
</artwork>
      </figure>
      <t>With those parameters, the two example URL template strings resolve to
      the following URLs:</t>
      <figure>
       <artwork xml:space="preserve">
http://container.com/Wilma/Betty/dino/car?a=Barney&amp;b=Fred
http://container.com/apps/Wilma/Betty/dino/car?os_a=Barney&amp;os_b=Fred
</artwork>
      </figure>
      <t>See also:
      <xref target="gadgets.views.View.bind">bind()</xref> </t></t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>String</c>
       <c>A template that can be used to construct URLs that navigate to this
       view</c>
      </texttable></t>
     </section>
   </x:deprecated>
     
     <section title="isOnlyVisibleGadget"
              anchor="gadgets.views.View.isOnlyVisibleGadget">
      <t>Type: {boolean} isOnlyVisibleGadget()</t>
      <t>Description: Returns true if the gadget is the only visible gadget in
      this view. On a canvas page or in maximize mode this is most likely true;
      on a profile page or in dashboard mode, it is most likely false.</t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>boolean</c>
       <c>True if the gadget is the only visible gadget; otherwise, false</c>
      </texttable></t>
     </section>
    </section>
   </section>
   <section title="gadgets.views.ViewType"
            anchor="gadgets.views.ViewType">
    <!-- ============================== class summary ========================== -->
    <t>Used by
    <xref target="gadgets.views.View">View objects</xref>.</t>
      <list style="hanging">
	<t hangText="ABOUT"
	           anchor="gadgets.views.ViewType.ABOUT">
	      A view used to provide descriptive information regarding the gadget. This view is typically rendered in a smaller area. The viewer is not always the same as the owner. This field may be used interchangeably with the string 'ABOUT'. <xref target="Issue-1169">Discussion</xref></t>
     <t hangText="CANVAS"
              anchor="gadgets.views.ViewType.CANVAS">
      A view where the gadget is displayed in a very large
      mode. It is typically the main content on the page. The viewer is not
      always the same as the owner. This field may be used interchangeably with
      the string 'CANVAS'.</t>
          <t hangText="EMBEDDED"
             anchor="gadgets.views.ViewType.EMBEDDED">
              A view used when an gadget is to be rendered in the context of some other content. For example, an
              activity stream entry may include a diagram. Rather than requiring the user to navigate to a dashboard,
              the container may render the gadget "embedded" in the stream. The developer should anticipate that there
              may be limited chrome surrounding the gadget. The viewer is not
              always the same as the owner.
              This field may be used interchangeably with the
              string 'EMBEDDED'. <xref target="Issue-1169">Discussion</xref>
          </t>
     <t hangText="HOME"
              anchor="gadgets.views.ViewType.HOME">
      A view where the gadget is displayed in a small area
      usually on a page with other gadgets. Typically the viewer is the same as
      the owner. This field may be used interchangeably with the string
      'HOME'.</t>
	<t hangText="PREFERENCES"
              anchor="gadgets.views.ViewType.PREFERENCES">
        A view used to allow the user to display and set the user preferences defined by the gadget. For example, it is
        common for gadgets to present a form for visible user prefs. Because the user preferences are specific to a
        user, owner and viewer MUST be the same in this view.
        This field may be used interchangeably with the
        string 'PREFERENCES'. <xref target="Issue-1169">Discussion</xref></t>
     <t hangText="PREVIEW"
              anchor="gadgets.views.ViewType.PREVIEW">
      A demo view of the gadget. In this view the owner and
      viewer are not known. This field may be used interchangeably with the
      string 'PREVIEW'.</t>
          <t hangText="PROFILE"
             anchor="gadgets.views.ViewType.PROFILE">
              A view where the gadget is displayed in a small area
              usually on a page with other gadgets. A typical use case for this view is for the gadget to be placed on
              the profile page of a user, for example, a gadget that allows you to schedule a meeting with the person.
              The viewer is not always the same
              as the owner. This field may be used interchangeably with the string
              'PROFILE'.
          </t>
          <t hangText="SUPPORT"
             anchor="gadgets.views.ViewType.SUPPORT">
              A view used to communicate to the user where to get support information for the gadget. Typically, the
              gadget is displayed in a small area. The viewer MUST always the same
              as the owner. This field may be used interchangeably with the string
              'SUPPORT'. <xref target="Issue-1169">Discussion</xref>
          </t>
      </list>
    <section title="View Target" anchor="gadgets.views.ViewType.ViewTarget">
      <xref target="Issue-1167">Discussion</xref>
      <list style="hanging">
      <t hangText="TAB"
              anchor="gadgets.views.ViewType.TAB">
      A view where the gadget is displayed inside a container tab.
      This field may be used interchangeably with the string
      'TAB'.</t>
      <t hangText="DIALOG"
              anchor="gadgets.views.ViewType.DIALOG">
      A view where the gadget is displayed in a pop up box. This field may be used interchangeably with the string
      'DIALOG'.</t>
      <t hangText="MODALDIALOG"
              anchor="gadgets.views.ViewType.MODALDIALOG">
      A view where the gadget is displayed in a modal pop up box. This field may be used interchangeably with the string
      'MODALDIALOG'.</t>
      <t hangText="FLOAT"
              anchor="gadgets.views.ViewType.FLOAT">
      A view where the gadget is displayed in a floating box. It is similar to the 'DIALOG' view type, but without chrome around it. This field may be used interchangeably with the string
      'FLOAT'.</t>
      <t hangText="SIDEBAR"
              anchor="gadgets.views.ViewType.SIDEBAR">
      A view where the gadget is displayed in a sidebar area. This field may be used interchangeably with the string
      'SIDEBAR'.</t>

    </list>

    </section>
   </section>
   <section title="opensocial.data" anchor="opensocial.data">
    <t>The opensocial.data namespace provides an API to access the pipelined data on
   the client.  There are methods to get the data returned from the data pipeline, set
   additional data, and listen to changes in data of a given key.</t>
    <t>Pipelined data is only available to the client when embedded in
   @type="html" content or content returned by a proxied content request. Data
   posted as part of a pipelined data request MUST not be available on the
   client.</t>
   <figure>
    <preamble>Examples</preamble>
    <artwork xml:space="preserve">
var viewer = opensocial.data.getContext().getDataSet('Viewer');
alert('Hello ' + viewer.name);
os.data.getDataContext().putDataSet('Params', {"Page": 2, "PageSize": 10});
opensocial.data.getDataContext().registerListener('Friends', function(key) {
   var el = document.getElementById('friend-details');
   el.style.display = 'show';
});
</artwork>
   </figure>

      <section title="getContext"
               anchor="opensocial.data.getContext">
       <list style="hanging">
       <t hangText="Signature">&lt;static&gt; <x:ref>DataContext</x:ref> opensocial.data.getContext()</t>
       <t hangText="Description">Gets the DataContext associated with the
    gadget.</t>
       <t hangText="Parameters">None.</t>
       <t hangText="Returns">
       <texttable align="left">
        <ttcol>Type</ttcol>
        <ttcol>Description</ttcol>
        <c>DataContext</c>
        <c>The data associated with Data Pipelining requests.</c>
       </texttable>
       </t>
       </list>
      </section>
      <section title="DataContext"
               anchor="DataContext_Client">
               <t>The DataContect object maintains all the data associated with the current gadget's data pipelining requests.</t>
        <section title="getDataSet" anchor="opensocial.data.DataContext.getDataSet">
       <list style="hanging">
       <t hangText="Signature">Object getDataSet(String key)</t>
       <t hangText="Description">Retrieves the
    object data that is currently mapped to the specified key.</t>
       <t hangText="Parameters">
       <texttable align="left">
        <ttcol>Name</ttcol>
        <ttcol>Type</ttcol>
        <ttcol>Description</ttcol>
        <c>key</c>
        <c>String</c>
        <c>The key for the data object to be retrieved</c>
       </texttable>
       </t>
       <t hangText="Returns">
       <texttable align="left">
        <ttcol>Type</ttcol>
        <ttcol>Description</ttcol>
        <c>Object</c>
        <c>The object stored with the given key.</c>
       </texttable></t>
       </list>
      </section>
      <section title="putDataSet"
               anchor="opensocial.data.putDataSet">
       <list style="hanging">
       <t hangText="Signature">void putDataSet(String key, String|Object value)</t>
       <t hangText="Description">Puts additional data into the data context.  This data can later be accessed using the key provided..</t>
       <t hangText="Parameters">
       <texttable align="left">
        <ttcol>Name</ttcol>
        <ttcol>Type</ttcol>
        <ttcol>Description</ttcol>
        <c>key</c>
        <c>String</c>
        <c>The key to use to refer to this data</c>
        <c>value</c>
        <c>String | Object</c>
        <c>The data to store.  If the value is a JSON string, it will be parsed and stored as a JavaScript object.</c>
       </texttable>
       </t>
       <t hangText="Returns">None.</t>
       </list>
      </section>
      <section title="putDataSets"
               anchor="opensocial.data.putDataSets">
       <list style="hanging">
       <t hangText="Signature">void putDataSets(Object dataSets)</t>
       <t hangText="Description">Puts many
    data sets into the data context at once, with appropriate listeners firing
    after all the updates are done.</t>
       <t hangText="Parameters">
       <texttable align="left">
        <ttcol>Name</ttcol>
        <ttcol>Type</ttcol>
        <ttcol>Description</ttcol>
        <c>dataSets</c>
        <c>Object</c>
        <c>an object whose property names are data set keys, and whose
     properties are actual data sets</c>
       </texttable>
       </t>
       <t hangText="Returns">None.</t>
       </list>
      </section>
      <section title="registerListener"
               anchor="opensocial.data.registerListener">
       <list style="hanging">
       <t hangText="Signature">void registerListener(String | Array&gt;String&lt;> keys, Function callback)</t>
       <t hangText="Description">Listens for any updates
    to data keyed by one of "keys". The wildcard key, "*", may be used
    to listen to all keys.</t>
       <t hangText="Parameters">
       <texttable align="left">
        <ttcol>Name</ttcol>
        <ttcol>Type</ttcol>
        <ttcol>Description</ttcol>
        <c>keys</c>
        <c>String | Array&gt;String&lt;></c>
        <c>The key or list of keys to add the listener to</c>
        <c>callback</c>
        <c>Function</c>
        <c>A function to invoke when the data at the given keys changes.  When the function is invoked, it MUST receive a single parameter, which is a list of the keys that have newly-updated values.</c>
       </texttable>
       </t>
       <t hangText="Returns">None.</t>
       </list>
      </section>
     </section>
   </section>
    <section title="osapi"
            anchor="osapi">
     <t>The osapi API is more natural to
     JavaScript developers and more succinct for creating OpenSocial gadgets
     than the existing JS APIs. It relies on the existing JSON-RPC protocol
     handlers, and is marked by the use of simple JSON objects as input and
     output. Note: this specification follows the JSON-RPC spec 1:1, but could
     also be implemented over REST.</t>
      <list style="symbols">
       <t>Introduces standard method signature for data requests - JSON in,
       JSON out</t>
       <t>Input and output parameters match JSON-RPC calls 1:1 and share
       documentation</t>
       <t>Data requests look like functions on "service" objects, e.g.,
       osapi.people.get(), instead of
       opensocial.DataRequest.newXXXRequest()</t>
       <t>Data requests can be called individually or as part of a batch</t>
       <t>Batch calls are designed for call chaining. The newBatch() call
       returns the batch, as does add, so that you can succinctly add more
       requests to the batch and execute it.</t>
       <t>Located in the osapi namespace</t>
      </list>
     <t>A container MUST emit the osapi JavaScript libraries and data files
     required by the libraries if an application includes &lt;Require
     feature="osapi"/&gt; in the ModulePrefs section of the gadget XML file.
     The container SHOULD emit the osapi JavaScript libraries and data files
     required by the libraries if an application optionally requests the
     feature by including &lt;Optional feature="osapi"/&gt; in the ModulePrefs
     of the gadget XML file.</t>
     <section title="Service Objects">
        <t>Services objects available are dependent upon the container. The server SHOULD generate service objects for all available services. For example, Social API Servers supporting services such as <eref target="Social-API-Server.xml#People-Service">People</eref>, and <eref target="Social-API-Server.xml#Activities-Service">Activities</eref> would create JavaScript objects for osapi.people and osapi.activites.</t>
        <t>Each service object SHOULD make JavaScript functions available for all methods that the service supports. These functions SHOULD take a single parameter which is a JavaScript representation of the service method's parameters.  These functions MUST return a <x:ref>osapi.Request</x:ref> object that may be sent immediately by the <x:ref>osapi.Request.execute</x:ref>, or may be added to a <x:ref>osapi.BatchRequest</x:ref>.</t>
        <t>Developers wanting to write gadgets safely can test for the existence of a service and method as follows:</t>
      <artwork type="example" xml:space="preserve">if (osapi.people &amp;&amp; osapi.people.getViewer) {
  osapi.people.getViewer().execute(function(result) {
    if (!result.error) {
      alert('Your name is ' + result.displayName + '!');
    }
  });
}
</artwork>
     </section>
     <section title="Service Requests">
      <section title="osapi.Request"
               anchor="osapi.Request">
       <t>All methods of osapi service objects (e.g. osapi.people.get())
       return a JavaScript object representing the request. These objects MUST
       support the following method(s):</t>
        <section title="execute"
                 anchor="osapi.Request.execute">
         <list style="hanging">
          <t hangText="Signature">osapi.Response.execute(callback)</t>
          <t hangText="Description">Sends a request to execute a request to a service method.  Generally invoked as &lt;service-name&gt;.&lt;method-name&gt;(params).execute(callback) to send a request to the given method (&lt;method-name&gt;) on the specified service (&lt;service-name&gt;). Takes a callback for response processing.</t>
          <t hangText="Parameters">
           <texttable align="left">
            <ttcol>Name</ttcol>
            <ttcol>Type</ttcol>
            <ttcol>Description</ttcol>
            <c>callback</c>
            <c>Function</c>
            <c>A callback function to handle the response. The callback function will be invoked with a parameter which contains the response payload (<eref target="Core-Data.xml#HTTP-Response-Payload">Core HTTP-Response-Payload</eref>) specified by the service method that is invoked. <xref target="Issue-1215">Discussion</xref></c>
           </texttable></t>
          <t hangText="Returns">None</t>
         </list>
        </section>
       <section title="Examples">
        <figure>
         <preamble>A simple example to request the owner's friends and display the total number of friends.  Note that the 'totalResults' property contains the total number of friends, even only a portion of the collection is actually returned (e.g. for paging purposes):</preamble>
         <artwork xml:space="preserve">var params = {"userId": "@owner", "groupId": "@friends"};
osapi.people.get(params).execute(callback);

function callback(ownerFriends) {
  if (!ownerFriends.error) {
    alert('You have ' + ownerFriends.totalResults + ' friends');
  }
});
</artwork>
        </figure>
       </section>
      </section>
      <section title="Batch Request Objects"
               anchor="osapi.BatchRequest">
       <t>Multiple service requests can be combined into a single batch request using
       the following methods:</t>
        <section title="newBatch"
                 anchor="osapi.newBatch">
         <list style="hanging">
         <t hangText="Signature"><x:ref>osapi.BatchRequest</x:ref> osapi.newBatch()</t>
         <t hangText="Description">Creates a new batch request.</t>
         <t hangText="Parameters">None</t>
         <t hangText="Returns">
          <texttable align="left">
           <ttcol>Type</ttcol>
           <ttcol>Description</ttcol>
           <c><x:ref>osapi.BatchRequest</x:ref></c>
           <c>A new batch request.</c>
          </texttable>
         </t>
         </list>
        </section>
        <section title="add"
                 anchor="osapi.BatchRequest.add">
         <list style="hanging">
          <t hangText="Signature"><x:ref>osapi.BatchRequest</x:ref> osapi.add(key, request)</t>
          <t hangText="Description">Adds a service request to the batch associated with
         the specified key. A single batch request can contain both JSON-RPC
         calls (e.g. osapi.people.get()) and HTTP calls to third parties (e.g.
         osapi.http.get()).</t>
          <t hangText="Parameters">
           <texttable align="left">
            <ttcol>Name</ttcol>
            <ttcol>Type</ttcol>
            <ttcol>Description</ttcol>
            <c>key</c>
            <c>String</c>
            <c>A key to access the result of the given request from the parameter
          sent to the callback function.</c>
            <c>request</c>
            <c><x:ref>osapi.Request</x:ref></c>
            <c>A request to add to the batch.</c>
           </texttable>
          </t>
          <t hangText="Returns">
           <texttable align="left">
            <ttcol>Type</ttcol>
            <ttcol>Description</ttcol>
            <c><x:ref>osapi.BatchRequest</x:ref></c>
            <c>A batch request containing the given request (and any previously added requests).</c>
           </texttable>
          </t>
         </list>
        </section>
        <section title="execute"
                 anchor="osapi.BatchRequest.execute">
         <list style="hanging">
          <t hangText="Signature">void osapi.BatchRequest.execute(callback)</t>
          <t hangText="Description">Executes all of the requests in the batch. Takes a
         callback for response processing, which is passed a JSON object
         mapping each request key to a JSON response object.</t>
          <t hangText="Parameters">
           <texttable align="left">
            <ttcol>Name</ttcol>
            <ttcol>Type</ttcol>
            <ttcol>Description</ttcol>
            <c>callback</c>
            <c>Function</c>
            <c>A callback function to handle the response. The callback function will be invoked with a parameter which contains a map. The key is the "key"
specified in the <x:ref>osapi.BatchRequest.add</x:ref> method. The value is the response payload for the service method that is invoked.</c>
           </texttable>
          </t>
          <t hangText="Returns">None</t>
         </list>
        </section>
       <section title="Examples">
        <figure>
         <preamble>An example illustrating two requests batched
         together:</preamble>
         <artwork xml:space="preserve">
          var batch = osapi.newBatch().
             add("viewer", osapi.people.getViewer()).
             add('activities', osapi.activities.get({ userId : '@viewer', groupId : '@self'})).
          batch.execute(function(result) {
            if (!result.error) {
              alert('Hi, ' + result.viewer.displayName + '!');
              alert('You have ' + result.activities.totalResults + ' activities.');
            }
          });
</artwork>
        </figure>

       </section>
      </section>
     </section>
     <section title="Error Handling">
      <t>The error handling works exactly as it does for the JSON-RPC
      interface, since this api is based on that protocol. The JSON object
      returned reflects any errors that occurred in the request. This breaks
      down into 3 types of errors:</t>
      <list style="symbols">
       <t>Network error, these return a top level error. For example, in the
       callback, the object passed will have an error object.
       <figure>
        <preamble>Example:</preamble>
        <artwork xml:space="preserve">
osapi.people.get({userId: '@owner', groupId: '@friends'}).execute(function(ownerFriends) {
  if (ownerFriends.error) {
    alert('Error occurred: ' + error.message);
  } else {
    alert('You have ' + ownerFriends.totalResults + ' friends');
  }
});
</artwork>
       </figure></t>
       <t>Application Error for Single Request
       <t>In this case, a top-level error object is set. Note, this is just
       like the previous error case.</t>
       <figure>
        <preamble>Example:</preamble>
        <artwork xml:space="preserve">
osapi.people.get({userId: '@owner', groupId: '@friends'}).execute(function(ownerFriends) {
  if (ownerFriends.error) {
    alert('Error occurred: ' + error.message);
  } else {
    alert('You have ' + ownerFriends.totalResults + ' friends');
  }
});
</artwork>
       </figure></t>
       <t>Application Error for a Batched Request.
       <t>In this case, a top-level error is set, but results are still
       returned for all individual requests that succeeded, if any. The
       individual request that failed has an error set.</t>
       <t>Note that 'error' is reserved and may not be used</t>
       <list style="symbols">
        <t>as a key to batch.add()</t>
        <t>as a property of a JSON RPC batch response item.
        <figure>
         <preamble>Example: Bailing out if there is any error in the
         batch:</preamble>
         <artwork xml:space="preserve">
var batch = osapi.newBatch().
    add("viewer", osapi.people.getViewer()).
    add('activities', osapi.activities.get({ userId : '@viewer', groupId : '@self'})).
batch.execute(function(result) {
  if (result.error) {
    alert("This batch had an error: " + error.message);
  } else {alert('Hi, ' + result.viewer.displayName + '!');
    alert('You have ' + result.activities.totalResults + ' activities.');
  }
});
</artwork>
        </figure>
        <figure>
         <preamble>Example: Processing any sub requests in the batch that
         succeeded:</preamble>
         <artwork xml:space="preserve">
var batch = osapi.newBatch().
   add('v', osapi.people.getViewer()).
   add('vf', osapi.people.getViewerFriends());
batch.execute(function(result) {
 for (var name in result) {
   if (result.hasOwnProperty(name)) {
     if (result[name].error) {
       gadgets.log("Found an error: ", result[name].error.message);
     } else {
       gadgets.log("Got some data: ", result[name]);
     }
   }
 }
});
</artwork>
        </figure></t>
       </list></t>
      </list>
     </section>
    </section>
         <section title="osapi.http"
               anchor="osapi.http">
       <t>Service object for making HTTP requests to third party servers. This
       is not a JSON-RPC endpoint, but a third party web service. The object created by methods (e.g. get(), post()) is an <x:ref>osapi.Request</x:ref> object, suitable for immediate
execution with <x:ref>osapi.Request.execute</x:ref> or batch operations with
<x:ref>osapi.BatchRequest</x:ref>.</t>
        <section title="head"
                 anchor="osapi.http.head">
         <list style="hanging">
          <t hangText="Signature">&lt;static&gt; <x:ref>osapi.Request</x:ref> osapi.http.head(params)</t>
          <t hangText="Description">Creates a HEAD request to an arbitrary URL.</t>
          <t hangText="Parameters">
           <texttable align="left">
            <ttcol>Name</ttcol>
            <ttcol>Type</ttcol>
            <ttcol>Description</ttcol>
            <c>params</c>
            <c><eref target="Core-Data.xml#HTTP-Request-Params">HTTP-Request-Parameters</eref></c>
            <c>A JavaScript representation of HTTP-Request-Parameters.</c>
           </texttable>
          </t>
          <t hangText="Returns">
           <texttable align="left">
            <ttcol>Type</ttcol>
            <ttcol>Description</ttcol>
            <c><x:ref>osapi.Request</x:ref></c>
            <c>A request to retrieve information from an arbitrary URL.</c>
           </texttable>
          </t>
         </list>
        </section>
        <section title="get"
                 anchor="osapi.http.get">
         <list style="hanging">
          <t hangText="Signature">&lt;static&gt; <x:ref>osapi.Request</x:ref> osapi.http.get(params)</t>
          <t hangText="Description">Creates a GET request to an arbitrary URL.</t>
          <t hangText="Parameters">
           <texttable align="left">
            <ttcol>Name</ttcol>
            <ttcol>Type</ttcol>
            <ttcol>Description</ttcol>
            <c>params</c>
            <c><eref target="Core-Data.xml#HTTP-Request-Params">HTTP-Request-Parameters</eref></c>
            <c>A JavaScript representation of HTTP-Request-Parameters.</c>
           </texttable>
          </t>
          <t hangText="Returns">
           <texttable align="left">
            <ttcol>Type</ttcol>
            <ttcol>Description</ttcol>
            <c><x:ref>osapi.Request</x:ref></c>
            <c>A request to retrieve information from an arbitrary URL.</c>
           </texttable>
          </t>
         </list>
        </section>
        <section title="post"
                 anchor="osapi.http.post">
         <list style="hanging">
          <t hangText="Signature">&lt;static&gt; <x:ref>osapi.Request</x:ref> osapi.http.post(params)</t>
          <t hangText="Description">Creates a POST request to an arbitrary URL.</t>
          <t hangText="Parameters">
           <texttable align="left">
            <ttcol>Name</ttcol>
            <ttcol>Type</ttcol>
            <ttcol>Description</ttcol>
            <c>params</c>
            <c><eref target="Core-Data.xml#HTTP-Request-Params">HTTP-Request-Parameters</eref></c>
            <c>A JavaScript representation of HTTP-Request-Parameters.  osapi.http.post supports an additional property, 'body', whose value is used as the post body of the HTTP request.</c>
           </texttable>
          </t>
          <t hangText="Returns">
           <texttable align="left">
            <ttcol>Type</ttcol>
            <ttcol>Description</ttcol>
            <c><x:ref>osapi.Request</x:ref></c>
            <c>A request to POST information to an arbitrary URL.</c>
           </texttable>
          </t>
         </list>
        </section>
        <section title="put"
                 anchor="osapi.http.put">
         <list style="hanging">
          <t hangText="Signature">&lt;static&gt; <x:ref>osapi.Request</x:ref> osapi.http.put(params)</t>
          <t hangText="Description">Creates a PUT request to an arbitrary URL.</t>
          <t hangText="Parameters">
           <texttable align="left">
            <ttcol>Name</ttcol>
            <ttcol>Type</ttcol>
            <ttcol>Description</ttcol>
            <c>params</c>
            <c><eref target="Core-Data.xml#HTTP-Request-Params">HTTP-Request-Parameters</eref></c>
            <c>A JavaScript representation of HTTP-Request-Parameters.   osapi.http.put supports an additional property, 'body', whose value is used as the post body of the HTTP request.</c>
           </texttable>
          </t>
          <t hangText="Returns">
           <texttable align="left">
            <ttcol>Type</ttcol>
            <ttcol>Description</ttcol>
            <c><x:ref>osapi.Request</x:ref></c>
            <c>A request to PUT information to an arbitrary URL.</c>
           </texttable>
          </t>
         </list>
        </section>
        <section title="delete"
                 anchor="osapi.http.delete">
         <list style="hanging">
          <t hangText="Signature">&lt;static&gt; <x:ref>osapi.Request</x:ref> osapi.http.delete(params)</t>
          <t hangText="Description">Creates a DELETE request to an arbitrary URL.</t>
          <t hangText="Parameters">
           <texttable align="left">
            <ttcol>Name</ttcol>
            <ttcol>Type</ttcol>
            <ttcol>Description</ttcol>
            <c>params</c>
            <c><eref target="Core-Data.xml#HTTP-Request-Params">HTTP-Request-Parameters</eref></c>
            <c>A JavaScript representation of HTTP-Request-Parameters.</c>
           </texttable>
          </t>
          <t hangText="Returns">
           <texttable align="left">
            <ttcol>Type</ttcol>
            <ttcol>Description</ttcol>
            <c><x:ref>osapi.Request</x:ref></c>
            <c>A request to delete information at an arbitrary URL.</c>
           </texttable>
          </t>
         </list>
        </section>
        <x:incubating href="http://code.google.com/p/opensocial-resources/issues/detail?id=1200" note="Add support for HTTP PATCH">
        <section title="patch"
                 anchor="osapi.http.patch">
         <list style="hanging">
          <t hangText="Signature">&lt;static&gt; <x:ref>osapi.Request</x:ref> osapi.http.patch(params)</t>
          <t hangText="Description">Creates a PATCH request to an arbitrary URL.</t>
          <t hangText="Parameters">
           <texttable align="left">
            <ttcol>Name</ttcol>
            <ttcol>Type</ttcol>
            <ttcol>Description</ttcol>
            <c>params</c>
            <c><eref target="Core-Data.xml#HTTP-Request-Params">HTTP-Request-Parameters</eref></c>
            <c>A JavaScript representation of HTTP-Request-Parameters.</c>
           </texttable>
          </t>
          <t hangText="Returns">
           <texttable align="left">
            <ttcol>Type</ttcol>
            <ttcol>Description</ttcol>
            <c><x:ref>osapi.Request</x:ref></c>
            <c>A request to patch information at an arbitrary URL.</c>
           </texttable>
          </t>
         </list>
        </section>
        </x:incubating>



       <section title="Examples">
        <figure>
         <preamble>Suppose a request to http://www.somephotosite.com/latest
         returns the following JSON:</preamble>
         <artwork xml:space="preserve">
{
  photos : [ "http://www.somephotosite.com/photos/1.jpg",
             "http://www.somephotosite.com/photos/2.jpg",
             "http://www.somephotosite.com/photos/3.jpg",
           ],
  lastUpdate : "Mon, 13 Apr 2009 23:17:04 GMT"
}
</artwork>
        </figure>
        <figure>
         <preamble>The data can be retrieved and accessed as
         follows:</preamble>
         <artwork xml:space="preserve">
osapi.http.get({href:'http://www.somephotosite.com/latest'}).execute(function(result) {
  if (!result.error) {
    alert('There are ' + result.content.photos.length + ' new photos');
  }
});
</artwork>
        </figure>
        <figure>
         <preamble>An example illustrating some available request
         parameters:</preamble>
         <artwork xml:space="preserve">
var params = {
    'href': 'http://www.somephotosite.com/prefs?uid=1234',
    'format': 'json',
    'headers': {'Content-Type': ['application/json;charset=utf-8'], "Accept-Language": ["en-us"]},
    'body': {'numResults': 100, theme: 'beach'},
    'authz': 'SIGNED',
};
osapi.http.post(params).execute(function(result) {
  if (!result.error) {
    alert('Request to update user preferences was successful');
  }
});
</artwork>
        </figure>

       
        <figure>
            <preamble>This example demonstrates the use of 'alias'</preamble>
            <artwork>
                var params = {
                    'alias': 'sharepoint',
                    'href': '/departmentList',
                    'format': 'json',
                    'headers': {'Content-Type': ['application/json;charset=utf-8'], "Accept-Language": ["en-us"]}
                };
                osapi.http.get(params).execute(function(result) {
                  if (!result.error) {...}
                });
            </artwork>
        </figure>
       <xref target='Issue-1178'>Discussion</xref>

       </section>
      </section>
  </section>
  <section title="Data Pipelining" anchor="DataPipelining">
   <t>Data Pipelining is a declarative syntax for defining the data a gadget requires from the container. The &lt;os:DataRequest&gt; element provides access to OpenSocial data, and the &lt;os:HttpRequest&gt; element provides access to content from any HTTP endpoint.</t>
   <t>All Data Pipelining tags MUST have a 'key' attribute which contains a string that is used to identify the data in the response.
   Values of the key attribute are case-sensitive when referenced through the data context object or the Expression Language.</t>
   <t>Tags that invoke API Server methods support a 1:1 mapping between the XML
   attributes and the service method parameters.  See <xref target="Core-API-Server"/> and <xref target="Social-API-Server"/> for information on the parameters available for each service method. Note that Data Pipelining MUST only be used for API Server calls that get data. Service methods that update data MUST NOT be implemented as Data Pipelining tags.</t>
   <t>Here's an example of Data Pipelining tags in a gadget XML file.</t>
   <figure>
    <artwork xml:space="preserve">
&lt;Content type="html"&gt;&lt;![CDATA[
  &lt;script xmlns:os="http://ns.opensocial.org/2008/markup" type="text/os-data"&gt;
    &lt;os:DataRequest key="vwr" method="people.get" userId="@viewer" fields="name,birthday"/&gt;
    &lt;os:HttpRequest key="mydata" href="http://example.com/api"/&gt;
  &lt;/script&gt;
  ... HTML content here ...
]]&gt;&lt;/Content&gt;
</artwork>
   </figure>

   <t>Data Pipelining creates a new feature name for use in the Gadget
   Specification: opensocial-data. When data pipelining elements are embedded
   in type=@html, the Module must contain this XML:
   <figure>
    <artwork xml:space="preserve">
&lt;ModulePrefs&gt;
 &lt;Require feature="opensocial-data"/&gt;
&lt;/ModulePrefs&gt;
</artwork>
   </figure></t>

      <section title="DataContext"
               anchor="DataContext">
   <t>The DataContect object maintains all the data associated with the current
   gadget's data pipelining requests.
   Items in the data context may be access
   through <xref target="EL">EL statements</xref> or on the client
   with the <xref target="opensocial.data">opensocial.data APIs</xref>.
   </t>

   <t>Data may be placed into the data context with any data pipeline tags,
   such as <xref target="osVar">&lt;os:Var&gt;</xref>,
   or through the <xref target="opensocial.data">opensocial.data APIs</xref>.
   </t>

   <t>Data in the Data Context is available in three contexts:</t>
   <list style="numbers">
    <t>Proxied content requests. This data will be POSTed to the developer
    party server with requests for proxied content.</t>
    <t>OpenSocial Templates. The data will be available as named variables in
    OpenSocial templates.</t>
    <t>JavaScript. This data will be available in the JavaScript API.</t>
   </list>
   </section>

   <section title="Data block">

   <t>A data block may be defined to hold a number of data pipeline tags.  See the
   <xref target="DataElement">Data Element</xref> section for more information on this element. <xref target="Issue-1162">Discussion</xref>
   <figure>
    <artwork xml:space="preserve">
&lt;Module&gt;
 &lt;Data&gt;
  &lt;os:DataRequest key="PagedFriends" method="people.get" userId="@owner" groupId="@friends" startIndex="40" count="20"/&gt;
 &lt;/Data&gt;
 &lt;Content&gt;
 ...
 &lt;/Content&gt;
&lt;/Module&gt;
</artwork>
   </figure></t>

   </section>

   <section title="Tag: &lt;os:DataRequest&gt;"
           anchor="DataRequest">
    <list style="hanging">
     <t hangText="Description">Request to get OpenSocial data, including person data, activity data, and any container-specific endpoints.</t>
     <t hangText="Attributes">The following attributes are REQUIRED.  Any additional attributes will be passed as parameters to the service method.
       <texttable align="left">
          <ttcol>Name</ttcol>
          <ttcol>Type</ttcol>
          <ttcol align="left">Description</ttcol>
          <c>key</c>
          <c>String</c>
          <c>A key for accessing the response.</c>
          <c>method</c>
          <c>String</c>
          <c>The name of the service and method to call.</c>
       </texttable>
     </t>
     <t hangText="Returns">A JSON object representing the <eref target="Core-API-Server.xml#Return-Object">Return-Object</eref> specified by the service method.</t>
    </list>
   <figure>
    <preamble>Example of tag syntax:</preamble>
    <artwork xml:space="preserve">
&lt;os:DataRequest key="PagedFriends" method="people.get" userId="@owner" groupId="@friends" startIndex="40" count="20"/&gt;
</artwork>
   </figure>
  </section>
   <section title="Tag: &lt;os:HttpRequest&gt;"
           anchor="HttpRequest">
    <list style="hanging">
     <t hangText="Description">Request for arbitrary URL data, equivalent to <x:ref>osapi.http</x:ref>.  Containers SHOULD cache the results of these requests.</t>
     <t hangText="Attributes">MUST support all of the fields in <eref target="Core-Data.xml#HTTP-Request-Params">HTTP-Request-Params</eref> as attributes.  In addition, following fields are REQUIRED:
       <texttable>
          <ttcol>Name</ttcol>
          <ttcol>Type</ttcol>
          <ttcol align="left">Description</ttcol>
          <c>key</c>
          <c>String</c>
          <c>A key for accessing the response.</c>
          <c>method</c>
          <c>String</c>
          <c>HTTP method to use, one of "get" or "post". Defaults to "get".
           <list style="symbols">
            <t>If method is "post", then &lt;os:HttpRequest&gt; supports an addition parameter, "body" which contains key/value pairs to send as POST
     content with a content type of "application/x-www-form-urlencoded".</t>
           </list>
          </c>
       </texttable>
     </t>
     <t hangText="Returns">A <eref target="Core-API-Server.xml#RPC-Response-Payload">RPC-Response-Payload</eref> object with "id", "error",
   and "result" properties. The "result" object is not available for 4xx or 5xx
   responses. When available, the "result" object in turn contains a <eref target="Core-Data.xml#HTTP-Response-Paylaod">HTTP-Response-Payload</eref>.</t>
   </list>
   <figure>
    <preamble>Example of tag syntax:</preamble>
    <artwork xml:space="preserve">&lt;os:HttpRequest key="Pets" href="http://example.com/api" authz="signed"/&gt;
</artwork>
   </figure>
   <t>For errors, the "message" property MUST NOT contain the response
   body, but SHOULD contain a descriptive message describing the HTTP error.
   The error MAY contain a data block providing the content and headers.
   <figure>
    <preamble>Example responses:</preamble>
    <artwork xml:space="preserve">
// @format='text' example
{result: {
 content: 'Hi there!',
 status: 200,
 headers: {'Content-Type': ['text/plain;charset=utf-8']}
}}
// @format='json' example
{result: {
 content: {'hi': 'there!'},
 status: 200,
 headers: {'Content-Type': ['application/json;charset=utf-8']}
}}
// 404 error
{error: {
 code: 404,
 message: 'Resource not found',
 // Optional data block
 data: {
  content : {'&lt;html&gt;&lt;body&gt;File not found... '},
   headers: {'Content-Type': ['text/html; charset=iso-8859-1']}
 }
}}
// Unparseable JSON
{error: {
 message: "JSON could not be parsed",
 code: 406,
 data: {
  content: {'This isn't JSON'}
 }
}}
</artwork>
   </figure></t>
  </section>

  <section title="Tag: &lt;os:Var&gt;"
           anchor="osVar">
    <list style="hanging">
     <t hangText="Description">Declare a literal value or result of an EL statement under a different key.</t>
     <t hangText="Attributes">The following attributes are supported.
       <texttable align="left">
          <ttcol>Name</ttcol>
          <ttcol>Type</ttcol>
          <ttcol align="left">Description</ttcol>
          <c>key</c>
          <c>String</c>
          <c>A key for accessing the value.  REQUIRED</c>
          <c>value</c>
          <c>String</c>
          <c>Literal string, EL statement, or JSON object.  OPTIONAL.  If not specified the contents of the tag are used for value.</c>
       </texttable>
     </t>
     <t hangText="Returns">Value as resolve by below processing rules.</t>
    </list>
   <figure>
    <preamble>Example of tag syntax:</preamble>
    <artwork xml:space="preserve">&lt;os:Var key="myNumber" value="1"/&gt;
</artwork>
   </figure>
   <section title="Processing Rules" anchor="osvarProcessingRules">
	<t>
	When processing values, the processor attempts to resolve the value of the os:Var tag in the following manner:
	</t>
	<list style="numbers">
	<t>Process to replace EL statements (${} markup)</t>
	<t>Attempt to parse it as a JSON value and return the resulting object if successful.</t>
	<t>If all other processing does not resolve the value, return as a string</t>
	</list>
     <t>The value created with os:Var may contain literals, JSON data, or EL statements.
	 An array may be declared using JSON or JavaScript array syntax.
	</t>

	<t>The below example creates a one-dimensional array with values [1,2,3,5,7]
	and assigns it to the key "primes" in the data context
	  <figure>
     <preamble>Example: simple array</preamble>
     <artwork xml:space="preserve">
&lt;os:Var key="primes" value="[1,2,3,5,7]" /&gt;
	 </artwork>
    </figure>
	</t>

	<t>The below places the result of the EL statement ${1+1} under the key "onePlusOne".
	  <figure>
     <preamble>Example: EL statement</preamble>
     <artwork xml:space="preserve">
&lt;os:Var key="onePlusOne" value="${1+1}" /&gt;
	 </artwork>
    </figure>
	</t>

	<t>The below creates a JSON object and places it under the key "mockViewer"
	  <figure>
     <preamble>Example: JSON object</preamble>
     <artwork xml:space="preserve">
&lt;os:Var key="mockViewer" &gt;
{"displayName": "John Doe",
 "thumbnailUrl": "http://example.org/person.png"
}
&lt;/os:Var&gt;
	 </artwork>
    </figure>
	</t>

   </section>
  </section>
  <section title="Proxied content" anchor="DataPipelining-ProxiedContent">
   <t>Data pipelining tags can be top level elements in the &lt;Content&gt;
   section of a gadget using <xref target="ProxiedContent">Proxied Content</xref>.
   <figure>
    <preamble>Example</preamble>
    <artwork xml:space="preserve">
&lt;Content href="http://example.com/canvas" xmlns:os="http://ns.opensocial.org/2008/markup"&gt;
  &lt;os:PeopleRequest key="vf" userId="@viewer" groupId="@friends"/&gt;
&lt;/Content&gt;
</artwork>
   </figure>When preparing a request for proxied content, a container MUST
   process data pipelining elements that are direct children of the proxied
   content's &lt;Content&gt; element. Data pipelining elements are ALWAYS valid
   when preparing a request for proxied content, even if the opensocial-data
   feature is not present.</t>
   <t>The results of the data pipelining requests will be sent to the href of
   the &lt;Content&gt; section as POSTed JSON data. The structure will be in
   <eref target="./Core-API-Server.xml#RPC">JSON-RPC format</eref>.</t>
   <t>Elements in a data pipeline with @userId referencing the viewer (via
   @viewer, @me) will return a 403 (Forbidden) error response if the container
   is unable to also send the opensocial_viewer URL parameter to the 3rd party
   server. The same holds true for @owner and opensocial_owner URL
   parameter.</t>
  </section>
  <section title="Handling of errors">
   <t>With pipelined data prepared for proxied content, errors are simply
   delivered to the href of the &lt;Content&gt; element as POSTed JSON data
   with the JSON-RPC error format unmodified.</t>
   <t>With pipelined data prepared for the Javascript API, or otherwise
   embedded in @type="html" content, per-item errors are not modified, but
   errors that fail the entire request are modified by cloning the error into
   each item.
   <figure>
   <preamble>Example</preamble>
   <artwork xml:space="preserve">
  &lt;script xmlns:os="http://ns.opensocial.org/2008/markup" type="text/os-data"&gt;
    &lt;os:ViewerRequest key="vwr"/&gt;
    &lt;os:PeopleRequest key="vf" userId="@viewer" groupId="@friends"/&gt;
  &lt;/script&gt;
</artwork>If the above request failed with a server error, the resulting
dataset would contain content resembling:
   <artwork xml:space="preserve">
 {vwr: {error: {message: 'Server error', code: 500}}, vf: {error: {message: 'Server error', code: 500}}}
</artwork></figure></t>
  </section>
  <section title="Handling of unrecognized tags">
   <t>Containers should ignore unrecognized tags or return error code 404 (Not
   Found). If a tag is ignored, the JSON structure can either include a null
   value for the request key or just not include the request key.</t>
  </section>
  <section title="Namespace">
   <t>The XML namespace for all of the Data Pipelining tags is
   http://ns.opensocial.org/2008/markup. (Note that namespace declarations on
   &lt;Content&gt; and &lt;Module&gt; elements do not apply to content inside
   of CDATA sections, so namespaces must be declared within CDATA.)</t>
  </section>
  <section title="Dynamic parameters">
   <t>Data and HTTP requests often need to change based on input parameters.
   Two key use cases:
   <list style="symbols">
    <t>Passing gadgets view parameters to a request, for example the current
    page in a paginated list.</t>
    <t>Passing OpenSocial data to a following &lt;os:HttpRequest&gt;,
    specifically IDs of (viewer, owner, viewer friends, owner friends).</t>
   </list></t>
   <t>Data pipelining will support a limited subset of the expression language
   used in OpenSocial templates (based on
   <xref target="JSPEL">JSP EL</xref>):
   <list style="symbols">
    <t>Expressions of format ${A(.B)*} will be supported, where "A" is the key
    and "B" is any number of properties. Examples: ${UserPrefs.size},
    ${ViewParams.nav.first}.</t>
    <t>Multiple expressions may appear within a single attribute, and mixed
    with non-expression text. The result of all non-expression text and
    expression evaluations will be concatenated.</t>
    <t>The key "ViewParams" is reserved and refers to the parameters passed
    into the gadget rendering, equivalent to
    <xref target="gadgets.views.getParams">gadgets.views.getParams()</xref>.</t>
    <t>The key "UserPrefs" is reserved and refers to gadget user preferences -
    ${UserPrefs.PREF} will return the value of gadgets.Prefs.getString('PREF')
    - see [API].</t>
   </list>The results of expression evaluation are treated as if the results
   were inserted as the literal string value of the XML attribute. JSON arrays
   within ViewParams are output as "a,b", not "[a,b]". The results of
   expression evaluation for URL-typed attributes - specifically, @href and
   @param on &lt;os:HttpRequest&gt; - MUST be
   <eref target="http://www.ietf.org/rfc/rfc1738.txt">RFC 1738, Section 2.2
   encoded (URL encoded)</eref> before being inserted into a final string.</t>
   <t>The following attributes support expressions:
   <list style="symbols">
    <t>Any attribute on os:DataRequest other than @key and @method</t>
    <t>@userId</t>
    <t>@groupId</t>
    <t>@fields</t>
    <t>@startIndex</t>
    <t>@count</t>
    <t>@sortBy</t>
    <t>@sortOrder</t>
    <t>@filterBy</t>
    <t>@filterOp</t>
    <t>@filterValue</t>
    <t>@activityIds</t>
    <t>@href</t>
    <t>@params</t>
   </list>An implementation MUST evaluate dynamic properties for these
   attributes and MUST NOT evaluate dynamic properties for attributes not on
   this list.</t>
   <t>
    <figure>
     <preamble>Example</preamble>
     <artwork xml:space="preserve">
&lt;os:PeopleRequest key="PagedFriends" userId="@owner" groupId="@friends" startIndex="${ViewParams.first}" count="20"/&gt;
&lt;os:HttpRequest href="http://example.com/api?ids=${PagedFriends.ids}"/&gt;
</artwork>
    </figure>
   </t>
   <t>
   Dynamic parameters may access request attributes of other data tags through the special "Request" key
   and response meta information of other data requests through the reserved keys "totalResults", "startIndex", and "count".
    <figure>
     <preamble>Example</preamble>
     <artwork xml:space="preserve">
&lt;os:PeopleRequest key="Page1" userId="@owner" groupId="@friends"
  startIndex="${ViewParams.first}" count="20"/&gt;

&lt;os:PeopleRequest key="Page2" userId="${Page1.Request.userId}" groupId="@friends"
  startIndex="${Page1.Request.startIndex + Page1.Request.count}"
  count="${Page1.Request.count}"/&gt;

</artwork>
    </figure>
   </t>
  </section>
  </section>


 </middle>
 <back>
  <section title="Gadget XML Schema"
           anchor="GadgetXmlSchema">
           
   <t> 

    <figure>
    
     <artwork xml:space="preserve">
&lt;?xml version="1.0"?&gt;
&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
  &lt;xs:element name="Module"&gt;
    &lt;xs:complexType&gt;
      &lt;xs:sequence&gt;
        &lt;xs:element name="ModulePrefs" minOccurs="0"&gt;
          &lt;xs:complexType&gt;
            &lt;xs:choice minOccurs="0" maxOccurs="unbounded"&gt;
              &lt;xs:element name="Require" type="GadgetFeatureType"/&gt;
              &lt;xs:element name="Optional" type="GadgetFeatureType"/&gt;
              &lt;xs:element name="Preload"&gt;
                &lt;xs:complexType&gt;
                  &lt;xs:attribute name="href" type="xs:string" use="required"/&gt;
                  &lt;xs:attribute name="authz" default="none"&gt;
                    &lt;xs:simpleType&gt;
                      &lt;xs:restriction base="xs:string"&gt;
                        &lt;xs:enumeration value="none"/&gt;
                        &lt;xs:enumeration value="signed"/&gt;
                        &lt;xs:enumeration value="oauth"/&gt;
                        &lt;xs:enumeration value="oauth2"/&gt;
                      &lt;/xs:restriction&gt;
                    &lt;/xs:simpleType&gt;
                  &lt;/xs:attribute&gt;
                  &lt;xs:attribute name="sign_owner" type="xs:boolean" default="true"/&gt;
                  &lt;xs:attribute name="sign_viewer" type="xs:boolean" default="true"/&gt;
                  &lt;xs:attribute name="views" type="xs:string" use="optional"/&gt;
                &lt;/xs:complexType&gt;
              &lt;/xs:element&gt;
              &lt;xs:element name="icon"&gt;
                &lt;xs:complexType&gt;
                  &lt;xs:simpleContent&gt;
                    &lt;xs:extension base="xs:string"&gt;
                      &lt;xs:attribute name="mode"&gt;
                        &lt;xs:simpleType&gt;
                          &lt;xs:restriction base="xs:string"&gt;
                            &lt;xs:enumeration value="base64"/&gt;
                          &lt;/xs:restriction&gt;
                        &lt;/xs:simpleType&gt;
                      &lt;/xs:attribute&gt;
                      &lt;xs:attribute name="type" type="xs:string"/&gt;
                    &lt;/xs:extension&gt;
                  &lt;/xs:simpleContent&gt;
                &lt;/xs:complexType&gt;
              &lt;/xs:element&gt;
              &lt;xs:element name="mediumIcon"&gt;
                &lt;xs:complexType&gt;
                  &lt;xs:simpleContent&gt;
                    &lt;xs:extension base="xs:string"&gt;
                      &lt;xs:attribute name="mode"&gt;
                        &lt;xs:simpleType&gt;
                          &lt;xs:restriction base="xs:string"&gt;
                            &lt;xs:enumeration value="base64"/&gt;
                          &lt;/xs:restriction&gt;
                        &lt;/xs:simpleType&gt;
                      &lt;/xs:attribute&gt;
                      &lt;xs:attribute name="type" type="xs:string"/&gt;
                    &lt;/xs:extension&gt;
                  &lt;/xs:simpleContent&gt;
                &lt;/xs:complexType&gt;
              &lt;/xs:element&gt;
              &lt;xs:element name="largeIcon"&gt;
                &lt;xs:complexType&gt;
                  &lt;xs:simpleContent&gt;
                    &lt;xs:extension base="xs:string"&gt;
                      &lt;xs:attribute name="mode"&gt;
                        &lt;xs:simpleType&gt;
                          &lt;xs:restriction base="xs:string"&gt;
                            &lt;xs:enumeration value="base64"/&gt;
                          &lt;/xs:restriction&gt;
                        &lt;/xs:simpleType&gt;
                      &lt;/xs:attribute&gt;
                      &lt;xs:attribute name="type" type="xs:string"/&gt;
                    &lt;/xs:extension&gt;
                  &lt;/xs:simpleContent&gt;
                &lt;/xs:complexType&gt;
              &lt;/xs:element&gt;
              &lt;xs:element name="Locale"&gt;
                &lt;xs:complexType&gt;
                  &lt;xs:sequence&gt;
                    &lt;xs:element name="msg" minOccurs="0" maxOccurs="unbounded"&gt;
                      &lt;xs:complexType&gt;
                        &lt;xs:simpleContent&gt;
                          &lt;xs:extension base="xs:string"&gt;
                            &lt;xs:attribute name="name" type="xs:string" use="required"/&gt;
                            &lt;xs:attribute name="desc" type="xs:string" use="optional"/&gt;
                          &lt;/xs:extension&gt;
                        &lt;/xs:simpleContent&gt;
                      &lt;/xs:complexType&gt;
                    &lt;/xs:element&gt;
                  &lt;/xs:sequence&gt;
                  &lt;xs:attribute name="lang" type="xs:string" use="optional"/&gt;
                  &lt;xs:attribute name="country" type="xs:string" use="optional"/&gt;
                  &lt;xs:attribute name="messages" type="xs:string" use="optional"/&gt;
                  &lt;xs:attribute name="language_direction"&gt;
                    &lt;xs:simpleType&gt;
                      &lt;xs:restriction base="xs:string"&gt;
                        &lt;xs:enumeration value="ltr"/&gt;
                        &lt;xs:enumeration value="rtl"/&gt;
                      &lt;/xs:restriction&gt;
                    &lt;/xs:simpleType&gt;
                  &lt;/xs:attribute&gt;
                  &lt;xs:attribute name="views" type="xs:string" use="optional"/&gt;
                &lt;/xs:complexType&gt;
              &lt;/xs:element&gt;
              &lt;xs:element name="Link"&gt;
                &lt;xs:complexType&gt;
                  &lt;xs:attribute name="href" type="xs:string" use="required"/&gt;
                  &lt;xs:attribute name="rel" use="required"&gt;
                    &lt;xs:simpleType&gt;
                      &lt;xs:restriction base="xs:string"&gt;
                        &lt;xs:enumeration value="gadgets.help"/&gt;
                        &lt;xs:enumeration value="gadgets.support"/&gt;
                        &lt;xs:enumeration value="icon"/&gt;
                      &lt;/xs:restriction&gt;
                    &lt;/xs:simpleType&gt;
                  &lt;/xs:attribute&gt;
                &lt;/xs:complexType&gt;
              &lt;/xs:element&gt;
              &lt;xs:element name="OAuth" minOccurs="0" maxOccurs="1"&gt;
                &lt;xs:complexType&gt;
                  &lt;xs:sequence&gt;
                    &lt;xs:element name="Service" maxOccurs="unbounded"&gt;
                      &lt;xs:complexType&gt;
                        &lt;xs:all&gt;
                          &lt;xs:element name="Request" type="OAuthResourceType" minOccurs="0"/&gt;
                          &lt;xs:element name="Access" type="OAuthResourceType" minOccurs="0"/&gt;
                          &lt;xs:element name="Authorization" minOccurs="0"&gt;
                            &lt;xs:complexType&gt;
                              &lt;xs:attribute name="url" type="xs:string" use="required"/&gt;
                            &lt;/xs:complexType&gt;
                          &lt;/xs:element&gt;
                        &lt;/xs:all&gt;
                      &lt;/xs:complexType&gt;
                    &lt;/xs:element&gt;
                  &lt;/xs:sequence&gt;
                  &lt;xs:attribute name="name" type="xs:string" use="optional"/&gt;
                &lt;/xs:complexType&gt;
              &lt;/xs:element&gt;
              &lt;xs:element name="OAuth2" minOccurs="0" maxOccurs="1"&gt;
                &lt;xs:complexType&gt;
                  &lt;xs:sequence&gt;
                    &lt;xs:element name="Service" maxOccurs="unbounded"&gt;
                      &lt;xs:complexType&gt;
                        &lt;xs:all&gt;
                          &lt;xs:element name="Authorization" type="OAuthResourceType" minOccurs="0"/&gt;
                          &lt;xs:element name="Token" type="OAuthResourceType" minOccurs="0"/&gt;
                        &lt;/xs:all&gt;
                      &lt;/xs:complexType&gt;
                    &lt;/xs:element&gt;
                  &lt;/xs:sequence&gt;
                  &lt;xs:attribute name="name" type="xs:string" use="optional"/&gt;
                  &lt;xs:attribute name="scope" type="xs:string" use="optional"/&gt;
                &lt;/xs:complexType&gt;
              &lt;/xs:element&gt;
            &lt;/xs:choice&gt;
            &lt;xs:attribute name="title" type="xs:string" use="optional"/&gt;
            &lt;xs:attribute name="title_url" type="xs:string" use="optional"/&gt;
            &lt;xs:attribute name="description" type="xs:string" use="optional"/&gt;
            &lt;xs:attribute name="author" type="xs:string" use="optional"/&gt;
            &lt;xs:attribute name="author_email" type="xs:string" use="optional"/&gt;
            &lt;xs:attribute name="screenshot" type="xs:string" use="optional"/&gt;
            &lt;xs:attribute name="thumbnail" type="xs:string" use="optional"/&gt;
          &lt;/xs:complexType&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="UserPref" minOccurs="0" maxOccurs="unbounded"&gt;
          &lt;xs:complexType&gt;
            &lt;xs:sequence&gt;
              &lt;xs:element name="EnumValue" minOccurs="0" maxOccurs="unbounded"&gt;
                &lt;xs:complexType&gt;
                  &lt;xs:attribute name="value" type="xs:string" use="required"/&gt;
                  &lt;xs:attribute name="display_value" type="xs:string" use="optional"/&gt;
                &lt;/xs:complexType&gt;
              &lt;/xs:element&gt;
            &lt;/xs:sequence&gt;
            &lt;xs:attribute name="name" type="xs:string" use="required"/&gt;
            &lt;xs:attribute name="display_name" type="xs:string" use="optional"/&gt;
            &lt;xs:attribute name="default_value" type="xs:string" use="optional"/&gt;
            &lt;xs:attribute name="required" type="xs:string" use="optional"/&gt;
            &lt;xs:attribute name="datatype" default="string"&gt;
              &lt;xs:simpleType&gt;
                &lt;xs:restriction base="xs:string"&gt;
                  &lt;xs:enumeration value="string"/&gt;
                  &lt;xs:enumeration value="hidden"/&gt;
                  &lt;xs:enumeration value="bool"/&gt;
                  &lt;xs:enumeration value="enum"/&gt;
                  &lt;xs:enumeration value="number"/&gt;
                &lt;/xs:restriction&gt;
              &lt;/xs:simpleType&gt;
            &lt;/xs:attribute&gt;
          &lt;/xs:complexType&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="Content" minOccurs="1" maxOccurs="unbounded"&gt;
          &lt;xs:complexType&gt;
            &lt;xs:simpleContent&gt;
              &lt;xs:extension base="xs:string"&gt;
                &lt;xs:attribute name="type" use="optional" default="html"&gt;
                  &lt;xs:simpleType&gt;
                    &lt;xs:restriction base="xs:string"&gt;
                      &lt;xs:enumeration value="html"/&gt;
                      &lt;xs:enumeration value="url"/&gt;
                    &lt;/xs:restriction&gt;
                  &lt;/xs:simpleType&gt;
                &lt;/xs:attribute&gt;
                &lt;xs:attribute name="authz" use="optional" default="none"&gt;
                  &lt;xs:simpleType&gt;
                    &lt;xs:restriction base="xs:string"&gt;
                      &lt;xs:enumeration value="none"/&gt;
                      &lt;xs:enumeration value="signed"/&gt;
                      &lt;xs:enumeration value="oauth"/&gt;
                      &lt;xs:enumeration value="oauth2"/&gt;
                    &lt;/xs:restriction&gt;
                  &lt;/xs:simpleType&gt;
                &lt;/xs:attribute&gt;
                &lt;xs:attribute name="href" type="xs:string" use="optional"/&gt;
                &lt;xs:attribute name="view" type="xs:string" use="optional"/&gt;
                &lt;xs:attribute name="preferred_height" type="xs:integer" use="optional"/&gt;
                &lt;xs:attribute name="preferred_width" type="xs:integer" use="optional"/&gt;
              &lt;/xs:extension&gt;
            &lt;/xs:simpleContent&gt;
          &lt;/xs:complexType&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="ExternalServices" minOccurs="0" maxOccurs="1"&gt;
          &lt;xs:complexType&gt;
            &lt;xs:sequence&gt;
              &lt;xs:element name="ServiceTag" maxOccurs="unbounded"&gt;
                &lt;xs:complexType&gt;
                  &lt;xs:attribute name="alias" type="xs:string" use="required"/&gt;
                &lt;/xs:complexType&gt;
              &lt;/xs:element&gt;
            &lt;/xs:sequence&gt;
          &lt;/xs:complexType&gt;
        &lt;/xs:element&gt;
      &lt;/xs:sequence&gt;
      &lt;xs:attribute name="specificationVersion" type="xs:string" use="optional" default="1.0.0"/&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  &lt;xs:complexType name="GadgetFeatureType"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name="Param" minOccurs="0" maxOccurs="unbounded"&gt;
        &lt;xs:complexType&gt;
          &lt;xs:simpleContent&gt;
            &lt;xs:extension base="xs:string"&gt;
              &lt;xs:attribute name="name" type="xs:string" use="required"/&gt;
            &lt;/xs:extension&gt;
          &lt;/xs:simpleContent&gt;
        &lt;/xs:complexType&gt;
      &lt;/xs:element&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:attribute name="feature" type="xs:string" use="required"/&gt;
    &lt;xs:attribute name="version" type="xs:string" use="optional"/&gt;
    &lt;xs:attribute name="views" type="xs:string" use="optional"/&gt;
  &lt;/xs:complexType&gt;
  &lt;xs:complexType name="OAuthResourceType"&gt;
    &lt;xs:attribute name="url" type="xs:string" use="required"/&gt;
    &lt;xs:attribute name="method" use="optional" default="GET"&gt;
      &lt;xs:simpleType&gt;
        &lt;xs:restriction base="xs:string"&gt;
          &lt;xs:enumeration value="GET"/&gt;
          &lt;xs:enumeration value="POST"/&gt;
        &lt;/xs:restriction&gt;
      &lt;/xs:simpleType&gt;
    &lt;/xs:attribute&gt;
    &lt;xs:attribute name="param_location" use="optional" default="auth-header"&gt;
      &lt;xs:simpleType&gt;
        &lt;xs:restriction base="xs:string"&gt;
          &lt;xs:enumeration value="auth-header"/&gt;
          &lt;xs:enumeration value="uri-query"/&gt;
          &lt;xs:enumeration value="post-body"/&gt;
        &lt;/xs:restriction&gt;
      &lt;/xs:simpleType&gt;
    &lt;/xs:attribute&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:schema&gt;
</artwork>
    </figure>
<xref target="Issue-1224">Discussion</xref>
<xref target="Issue-1142">Discussion</xref>
<xref target="Issue-1209">Discussion</xref>
<xref target="Issue-1212">Discussion</xref>
<xref target="Issue-1234">Discussion</xref>
   </t>
  </section>
  <section title="Message Bundle Schema"
           anchor="MessageBundleSchema">
   <t>
    <figure>
     <artwork xml:space="preserve">
&lt;?xml version="1.0"?&gt;
&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
  &lt;xs:element name="messagebundle"&gt;
    &lt;xs:complexType&gt;
      &lt;xs:sequence&gt;
        &lt;xs:element name="msg" minOccurs="0" maxOccurs="unbounded"&gt;
          &lt;xs:complexType&gt;
            &lt;xs:simpleContent&gt;
              &lt;xs:extension base="xs:string"&gt;
                &lt;xs:attribute name="name" type="xs:string" use="required"/&gt;
                &lt;xs:attribute name="desc" type="xs:string" use="optional"/&gt;
              &lt;/xs:extension&gt;
            &lt;/xs:simpleContent&gt;
          &lt;/xs:complexType&gt;
        &lt;/xs:element&gt;
      &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
&lt;/xs:schema&gt;
</artwork>
    </figure>
   </t>
  </section>
  <section title="Highly Recommended Features">
   <section title="gadgets.actions" anchor="gadgets.actions">
   <xref target="Issue-1161">Discussion</xref>
     <section title="Overview" anchor="gadgets.actions.overview">
	  	 <t>The actions feature allows gadgets to contribute actions to the container's UI. Some containers have
	  		global action contribution areas such as the header and footers of the container, which may include links, buttons, or menus.</t>

	  	 <t>Additionally, a gadget may need to contribute actions to specific Open Social Data Objects.  In traditional
	  		desktop applications, these actions are often rendered as menu items on context menus when you click on a person
	  		or file. For example, when a user right-clicks on a Person object to bring up the context menu, they may see actions
	  		specific to Person objects, including "Start a Chat" or "View Contact Information."</t>

	  	 <t>Some use cases are as follows:</t>
	     <t>Action contribution by path
			<list style="numbers">
			 <t>Gadget contributes a top level action to the container, aka such as a link at the top</t>
			 <t>Gadget contributes a action to the Gadget's drop down menu(drawn by the container)</t>
			 <t>Gadget contributes an action to a container specific defined path location, such as a container's toolbar</t>
	    	</list>
	     </t>
	     <t>Action contribution to an Open Social Data type
		   <list style="numbers">
			<t>Gadget contributes an action to container's Person object. Example, a gadget providing SMS capability can bind to a container's list of active contacts/buddy list.</t>
			<t>Gadget contributes an action to a container's Message. Example, a new button or action is added to the forward, reply, delete list when displaying a message.</t>
			<t>Same holds true for all Open Social defined data types Group, Activity, etc.</t>
			<t>Gadgets may bind to any container specific types that are defined.  Containers shall make all efforts to use types in shared namespace and to contribute back new types to the spec to maintain cross-container abilities of gadgets.</t>
		   </list>
	     </t>

	  	 <t>The container controls how to render the items such that all actions can be rendered consistently throughout the container,
	  		regardless of which gadget contributes the action.  Gadgets register actions by specifying a label, icon and a callback
	  		function.  Gadget developers do not need to worry about other UI details.</t>

		 <t>A gadget may programmatically contribute actions at any time by calling addAction(actionObject).  In addition,
			a gadget may declaratively contribute an action to the container in the gadget
			definition.  This allows actions to be added to the container before the gadget has been fully rendered.</t>
     </section>
     <section title="Action Objects" anchor="gadgets.actions.actionobjects">
      <t>An action object is a JSON representation of an action, and may contain the following attributes:</t>
      <texttable align="left">
        <ttcol>Attribute</ttcol>
       	<ttcol>Description</ttcol>
       	<ttcol>Required/Optional</ttcol>
	 	<c>id</c>
	 	<c>Unique identifier</c>
	 	<c>Required</c>
	 	<c>label</c>
	 	<c>Text string to display for this action</c>
	 	<c>Required</c>
	 	<c>path</c>
	 	<c>The container-defined location for this action, as described in <eref target="#gadgets.actions.paths">Action Paths</eref>.  Example: path=container/menus/Edit</c>
	 	<c>Optional*</c>
	 	<c>dataType</c>
	 	<c>The Open Social Data type, as described in <eref target="#gadgets.actions.datatypes">Action Data Types</eref>, with which to associate this action. Example: opensocial.Person</c>
	 	<c>Optional*</c>
	 	<c>tooltip</c>
	 	<c>Tooltip to display on hovering over an icon</c>
	 	<c>Optional</c>
	 	<c>icon</c>
	 	<c>Path to image icon.  Absolute URL or URL relative to gadget URL</c>
	 	<c>Optional</c>
	 	<c>iconSize</c>
	 	<c>See <eref target="http://code.google.com/p/opensocial-resources/issues/detail?id=1155">related issue on icon size</eref> for more information.</c>
	 	<c>Optional</c>
	 	<c>iconOffset</c>
	 	<c>x and y coordinates of icon if using image sprites</c>
	 	<c>Optional</c>
	 	<c>view</c>
	 	<c>The view ID the gadget should navigate to when the action is invoked.</c>
	 	<c>Optional</c>
	    <c>viewTarget</c>
	 	<c>The target area to render the view.</c>
	 	<c>Optional</c>
	 	<c>url</c>
	 	<c>Simple actions that are just links can specify a url instead of a callback function.</c>
	 	<c>Optional</c>
      </texttable>
      <t>* Either path or dataType MUST be specified.</t>
     </section>
     <section title="Action Locations">
	  <section title="Paths" anchor="gadgets.actions.paths">
	   <t>Gadgets may contribute actions to container-defined common action locations.  These may include the following
	   suggested standardized paths, but the container may also choose to support additional paths to which gadgets
	   can contribute:
	   </t>
       <texttable align="left">
        <ttcol>Path</ttcol>
       	<ttcol>Description</ttcol>
	 	<c>container/navigationLinks</c>
	 	<c>The top level navigation links, providing links to related services.</c>
		<c>container/menus</c>
	 	<c>The top level menu.  For example to add a new action to File->New->Presentation path="container/menu/File/New." </c>
	 	<c>container/toolbars</c>
	 	<c>Top level toolbars owned by the container. For example to add a new action to Toolbar in a docs editor.</c>
	 	<c>gadget/menu</c>
	 	<c>The optional menu drawn by the container, around each gadget.</c>
	   </texttable>
	  </section>
	  <section title="Data Types" anchor="gadgets.actions.datatypes">
	   <t>Gadgets may use any of the data types defined in <eref target="./Social-Data.xml">Social-Data.xml</eref>
	      when binding actions to OpenSocial Data types.  These include, but are not limited to, the following:
		<list style="hanging">
		 <t><eref target="./Social-Data.xml#Person">opensocial.Person</eref></t>
		 <t><eref target="./Social-Data.xml#Message">opensocial.Message</eref></t>
		 <t><eref target="./Social-Data.xml#Activity">opensocial.Activity</eref></t>
		 <t><eref target="./Social-Data.xml#Group">opensocial.Group</eref></t>
		</list>
 	   </t>
	  </section>
	 </section>
     <section title="Example">
      <t>Below is an example of the declarative contribution in a gadget's metadata and the javascript code needed to bind action ID to callback function:</t>
	   <figure>
		<artwork xml:space="preserve">
&lt;Module&gt;
 &lt;ModulePrefs title="Sample VOIP"&gt;
  &lt;Optional feature="actions"&gt;
   &lt;Param name="action-contributions"&gt;
    &lt;![CDATA[
    &lt;action id="org.samplevoip.callbyperson" dataObject="opensocial.Person" label="Call using VOIP Phone"
      view="DialByPerson" icon="http://ww.samplervoip.org/phone.gif" /&gt;
    &lt;action id="org.samplervoip.navLink" path="container/navigationLinks" label="Phone" /&gt;
    ]]&gt;
   &lt;/Param&gt;
  &lt;/Optional&gt;
 &lt;/ModulePrefs&gt;
 &lt;Content type="html"&gt;
  &lt;![CDATA[
   &lt;script&gt;

	// Bind javascript function to action ID
  var mycallback = function(){
    ...
  };
	var myaction = {
		id: "org.samplevoip.callbyperson",
		callback: mycallback
	}
	gadgets.actions.updateAction(myaction);

   &lt;/script&gt;
  ]]&gt;
 &lt;/Content&gt;
&lt;/Module&gt;
  		</artwork>
	   </figure>
      </section>
      <section title="Method Details">
	   <section title="addAction" anchor="gadgets.actions.addAction">
	    <t>&lt;static&gt; gadgets.actions.addAction(action)</t>
	    <t>Description: Adds the specified action(s) to the container.</t>
	    <t>Parameters:</t>
		<texttable align="left">
         <ttcol>Name</ttcol>
         <ttcol>Type</ttcol>
         <ttcol>Description</ttcol>
		 <c>action</c>
		 <c>Object</c>
		 <c>The action to be added to the container</c>
		</texttable>
	    <t>Example contributing an action to a container's Person object:</t>
        <artwork type="code">
var mycallback = function(){
	...
};

var myaction = {
	id: "com.acme.mycallaction",
	tooltip: "My Action Tooltip",
	label: "Call Person",
	icon: "images/myicon.png",
	callback: mycallback,
	dataType: "opensocial.Person"
}

gadgets.actions.addAction(myaction);
		</artwork>
	  </section>


      <section title="updateAction" anchor="gadgets.actions.updateAction">
	    <t>&lt;static&gt; gadgets.actions.updateAction(action)</t>
	    <t>Description: Updates the specified action(s) in the container.</t>
	    <t>Parameters:</t>
		<texttable align="left">
         <ttcol>Name</ttcol>
         <ttcol>Type</ttcol>
         <ttcol>Description</ttcol>
		 <c>action</c>
		 <c>Object</c>
		 <c>The action to be updated in the container</c>
		</texttable>
	    <t>Example updating a declarative action to bind a callback function:</t>
        <artwork type="code">
var mycallback = function(){
	...
};

var myaction = {
	id: "com.acme.mycallaction",
	callback: mycallback
}

gadgets.actions.updateAction(myaction);
		</artwork>
	  </section>


	  <section title="removeAction" anchor="gadgets.actions.removeAction">
	    <t>&lt;static&gt; gadgets.actions.removeAction (actionId)</t>
	    <t>Description: Removes the specified action from the container</t>
	    <t>Parameters:</t>
		<texttable align="left">
         <ttcol>Name</ttcol>
         <ttcol>Type</ttcol>
         <ttcol>Description</ttcol>
		 <c>id</c>
		 <c>String</c>
		 <c>The ID referencing the action to be removed from the container</c>
		</texttable>
	  </section>
	  <section title="getActionsByPath" anchor="gadgets.actions.getActionsByPath">
	    <t>&lt;static&gt; gadgets.actions.getActionsByPath (path, callback)</t>
	    <t>Description: Gets array of actions from the container at the specified path and passes the result to the callback function</t>
	    <t>Parameters:</t>
		<texttable align="left">
         <ttcol>Name</ttcol>
         <ttcol>Type</ttcol>
         <ttcol>Description</ttcol>
		 <c>path</c>
		 <c>String</c>
		 <c>The String representation of the path to the actions</c>
		 <c>callback</c>
		 <c>Function</c>
		 <c>A callback function to handle the returned actions array</c>
		</texttable>
	  </section>
	  <section title="getActionsByDataType" anchor="gadgets.actions.getActionsByDataType">
	    <t>&lt;static&gt; gadgets.actions.getActionsByDataType (dataType, callback)</t>
	    <t>Description: Gets array of actions from the container for the specified data type and passes the result to the callback function.</t>
	    <t>Parameters:</t>
		<texttable align="left">
         <ttcol>Name</ttcol>
         <ttcol>Type</ttcol>
         <ttcol>Description</ttcol>
		 <c>dataType</c>
		 <c>String</c>
		 <c>The String representation of an OpenSocial data type.</c>
		 <c>callback</c>
		 <c>Function</c>
		 <c>A callback function to handle the returned actions array</c>
		</texttable>
	  </section>
      <section title="runAction" anchor="gadgets.actions.runAction">
        <t>&lt;static&gt; gadgets.actions.runAction (actionId, opt_selection)</t>
        <t>Description: Executes the action callback associated with the specified actionId in the context of the gadget which
        contributed that action.  The gadget should call this method whenever an action is triggered by the user.</t>
        <t>Parameters:</t>
        <texttable align="left">
          <ttcol>Name</ttcol>
          <ttcol>Type</ttcol>
          <ttcol>Description</ttcol>
          <c>actionId</c>
          <c>String</c>
          <c>The id of the action to execute.</c>
          <c>opt_selection</c>
          <c>Object</c>
          <c>The current <xref target="gadgets.selection">selection</xref>.  This is an optional parameter.</c>
        </texttable>
      </section>
      <section title="registerShowActionsListener" anchor="gadgets.actions.registerShowActionsListener">
        <t>&lt;static&gt; gadgets.actions.registerShowActionsListener (showActionsHandler)</t>
        <t>Description: Registers a function to render actions in the gadget. The function will be called whenever new actions
        are added to the container.  The gadget can use this listener to add the new actions to its UI.</t>
        <t>Parameters:</t>
        <texttable align="left">
          <ttcol>Name</ttcol>
          <ttcol>Type</ttcol>
          <ttcol>Description</ttcol>
          <c>showActionsHandler</c>
          <c>Function</c>
          <c>The gadgets's function to render actions in its UI. The function takes in one parameter which is an array of action objects to render.</c>
        </texttable>
        <t>Parameters for show actions handler function:</t>
        <texttable align="left">
          <ttcol>Name</ttcol>
          <ttcol>Type</ttcol>
          <ttcol>Description</ttcol>
          <c>actionObjs</c>
          <c>Object[]</c>
          <c>An array of action objects.</c>
        </texttable>
        <t>Example:</t>
        <artwork type="code">
var myShowActionsHandler = function(actionObjs){
       // draw the UI, toolbars menus, etc
       // to do the invocation of the action, call the following API:
       // gadgets.actions.runAction(actionObjs[0].id);  
}
gadgets.actions.registerShowActionsHandler(myShowActionHandler);
        </artwork>
      </section>
      <section title="registerHideActionsListener" anchor="gadgets.actions.registerHideActionsListener">
        <t>&lt;static&gt; gadgets.actions.registerHideActionsListener (hideActionsHandler)</t>
        <t>Description: Registers a function to remove actions from the gadget. The function will be called whenever
        the container unloads a gadget which contributes actions.</t>
        <t>Parameters:</t>
        <texttable align="left">
          <ttcol>Name</ttcol>
          <ttcol>Type</ttcol>
          <ttcol>Description</ttcol>
          <c>hideActionsHandler</c>
          <c>Function</c>
          <c>The gadgets's function to hide actions in its UI. The function takes in one parameter which is an array of action objects to hide.</c>
        </texttable>
        <t>Parameters for hide actions handler function:</t>
        <texttable align="left">
          <ttcol>Name</ttcol>
          <ttcol>Type</ttcol>
          <ttcol>Description</ttcol>
          <c>actionObjs</c>
          <c>Object[]</c>
          <c>An array of action objects.</c>
        </texttable>
        <t>Example:</t>
        <artwork type="code">
var myhideActionsHandler = function(actionObjs){
       // remove any UI elements that were created to represent the action
}
gadgets.actions.registerHideActionsHandler(myHideActionHandler);
        </artwork>        
      </section>
     </section>
   </section>
   <section title="gadgets.flash"
            anchor="gadgets.flash">
    <!-- ============================== class summary ========================== -->
    <t>Embeds Flash content in gadgets.</t>
    <section title="Method Details">
     <section title="embedCachedFlash"
              anchor="gadgets.flash.embedCachedFlash">
      <t>&lt;static&gt; Type: {Boolean} gadgets.flash.embedCachedFlash()</t>
      <t>Description: Injects a cached Flash file into the DOM tree. Accepts
      the same parameters as gadgets.flash.embedFlash does.</t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>Boolean</c>
       <c>Whether the function call completes successfully</c>
      </texttable></t>
     </section>
     <section title="embedFlash"
              anchor="gadgets.flash.embedFlash">
      <t>&lt;static&gt; Type: {Boolean} gadgets.flash.embedFlash(swfUrl,
      swfContainer, swfVersion, opt_params)</t>
      <t>Description: Injects a Flash file into the DOM tree.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>swfUrl</c>
       <c>String</c>
       <c>SWF URL</c>
       <c>swfContainer</c>
       <c>String | Object</c>
       <c>The ID or object reference of an existing HTML container element</c>
       <c>swfVersion</c>
       <c>Number</c>
       <c>Minimum Flash Player version required</c>
       <c>opt_params</c>
       <c>Object</c>
       <c>An optional object that may contain any valid HTML parameter; all
       attributes will be passed through to the Flash movie on creation</c>
      </texttable></t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>Boolean</c>
       <c>Whether the function call completes successfully</c>
      </texttable></t>
     </section>
     <section title="getMajorVersion"
              anchor="gadgets.flash.getMajorVersion">
      <t>&lt;static&gt; Type: {Number} gadgets.flash.getMajorVersion()</t>
      <t>Description: Detects Flash Player and its major version.</t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>Number</c>
       <c>The major version of Flash Player or 0 if Flash is not supported</c>
      </texttable></t>
     </section>
    </section>
   </section>
   <section title="gadgets.MiniMessage"
            anchor="gadgets.MiniMessage">
    <!-- ============================== class summary ========================== -->
    <t>MiniMessage class, used to create messages that will appear to the user
    within the gadget. Typical use cases:
    <list style="symbols">
     <t>Status messages: loading, saving, etc.</t>
     <t>Promotional messages: new features, new gadget, etc.</t>
     <t>Debug/error messages: bad input, failed connection to server, etc.</t>
    </list></t>
    <!-- ============================== constructor details ==================== -->
    <section title="Constructor"
             anchor="gadgets.MiniMessage.ctor">
     <t>gadgets.MiniMessage(opt_moduleId, opt_container)</t>
     <t>Creates a MiniMessage.</t>
     <t>Parameters:
     <texttable align="left">
      <ttcol>Name</ttcol>
      <ttcol>Type</ttcol>
      <ttcol>Description</ttcol>
      <c>opt_moduleId</c>
      <c>String</c>
      <c>Optional module ID</c>
      <c>opt_container</c>
      <c>HTMLElement</c>
      <c>Optional HTML container element where mini-messages will appear</c>
     </texttable></t>
    </section>
    <section title="Method Details">
     <section title="createDismissibleMessage"
              anchor="gadgets.MiniMessage.createDismissibleMessage">
      <t>Type: {HTMLElement} createDismissibleMessage(message,
      opt_callback)</t>
      <t>Description: Creates a dismissible message with an [x] icon that
      allows users to dismiss the message. When the message is dismissed, it is
      removed from the DOM and the optional callback function, if defined, is
      called.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>message</c>
       <c>String | Object</c>
       <c>The message as an HTML string or DOM element</c>
       <c>opt_callback</c>
       <c>Function</c>
       <c>Optional callback function to be called when the message is
       dismissed. The callback function will not be called until after the
       existing callstack has completed execution.</c>
      </texttable></t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>HTMLElement</c>
       <c>HTML element of the created message</c>
      </texttable></t>
     </section>
     <section title="createStaticMessage"
              anchor="gadgets.MiniMessage.createStaticMessage">
      <t>Type: {HTMLElement} createStaticMessage(message)</t>
      <t>Description: Creates a static message that can only be dismissed
      programmatically (by calling dismissMessage()).</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>message</c>
       <c>String | Object</c>
       <c>The message as an HTML string or DOM element</c>
      </texttable></t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>HTMLElement</c>
       <c>HTML element of the created message</c>
      </texttable></t>
     </section>
     <section title="createTimerMessage"
              anchor="gadgets.MiniMessage.createTimerMessage">
      <t>Type: {HTMLElement} createTimerMessage(message, seconds,
      opt_callback)</t>
      <t>Description: Creates a message that displays for the specified number
      of seconds. When the timer expires, the message is dismissed and the
      optional callback function is executed.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>message</c>
       <c>String | Object</c>
       <c>The message as an HTML string or DOM element</c>
       <c>seconds</c>
       <c>number</c>
       <c>Number of seconds to wait before dismissing the message</c>
       <c>opt_callback</c>
       <c>Function</c>
       <c>Optional callback function to be called when the message is
       dismissed. The callback function will not be called until after the
       existing callstack has completed execution.</c>
      </texttable></t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>HTMLElement</c>
       <c>HTML element of the created message</c>
      </texttable></t>
     </section>
     <section title="dismissMessage"
              anchor="gadgets.MiniMessage.dismissMessage">
      <t>dismissMessage(message)</t>
      <t>Description: Dismisses the specified message.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>message</c>
       <c>HTMLElement</c>
       <c>HTML element of the message to remove</c>
      </texttable></t>
     </section>
    </section>
   </section>
   <section title="gadgets.oauth.Popup"
            anchor="gadgets.oauth.Popup">
    <!-- ============================== class summary ========================== -->
    <t>OAuth popup window manager.</t>
    <t>Expected usage:
    <list style="numbers">
     <t>Gadget attempts to fetch OAuth data for the user and discovers that
     approval is needed. The gadget creates two new UI elements:
     <list style="symbols">
      <t>a "personalize this gadget" button or link</t>
      <t>a "personalization done" button or link, which is initially
      hidden.</t>
     </list>The "personalization done" button may be unnecessary. The popup
     window manager will attempt to detect when the window closes. However, the
     "personalization done" button should still be displayed to handle cases
     where the popup manager is unable to detect that a window has closed. This
     allows the user to signal approval manually.</t>
     <t>Gadget creates a popup object and associates event handlers with the UI
     elements:
     <figure>
      <artwork xml:space="preserve">
// Called when the user opens the popup window.
var onOpen = function() {
  $("personalizeDone").style.display = "block"
}
// Called when the user closes the popup window.
var onClose = function() {
  $("personalizeDone").style.display = "none"
  fetchData();
}
var popup = new gadgets.oauth.Popup(
    response.oauthApprovalUrl,
    "height=300,width=200",
    onOpen,
    onClose
);
personalizeButton.onclick = popup.createOpenerOnClick();
personalizeDoneButton.onclick = popup.createApprovedOnClick();
</artwork>
     </figure></t>
     <t>When the user clicks the personalization button/link, a window is
     opened to the approval URL. The onOpen function is called to notify the
     gadget that the window was opened.</t>
     <t>When the window is closed, the popup manager calls the onClose function
     and the gadget attempts to fetch the user's data.</t>
    </list></t>
    <!-- ============================== constructor details ==================== -->
    <section title="Constructor"
             anchor="gadgets.oauth.Poup.ctor">
     <t>gadgets.oauth.Popup(destination, windowOptions, openCallback,
     closeCallback)</t>
     <t>Description: used to create a new OAuth popup window manager.</t>
     <t>Parameters:
     <texttable align="left">
      <ttcol>Name</ttcol>
      <ttcol>Type</ttcol>
      <ttcol>Description</ttcol>
      <c>destination</c>
      <c>String</c>
      <c>Target URL for the popup window.</c>
      <c>windowOptions</c>
      <c>String</c>
      <c>Options for window.open, used to specify look and feel of the
      window.</c>
      <c>openCallback</c>
      <c>Function</c>
      <c>Function to call when the window is opened.</c>
      <c>closeCallback</c>
      <c>Function</c>
      <c>Function to call when the window is closed.</c>
     </texttable></t>
    </section>
    <section title="Method Details">
     <section title="createOpenerOnClick"
              anchor="gadgets.oauth.Popup.createOpenerOnClick">
      <t>Type: {Function} createOpenerOnClick()</t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>Function</c>
       <c>an onclick handler for the "open the approval window" link.</c>
      </texttable></t>
     </section>
     <section title="createApprovedOnClick"
              anchor="gadgets.oauth.Popup.createApprovedOnClick">
      <t>Type: {Function} createApprovedOnClick()</t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>Function</c>
       <c>an onclick handler for the "I've approved" link. This may not ever be
       called. If we successfully detect that the window was closed, this link
       is unnecessary.</c>
      </texttable></t>
     </section>
    </section>
   </section>
   <section title="gadgets.rpc"
            anchor="gadgets.rpc">
    <!-- ============================== class summary ========================== -->
    <t>Provides operations for making remote procedure calls for
    gadget-to-container, container-to-gadget, and gadget-to-gadget
    communication.</t>
    <section title="Method Details">
     <section title="call"
              anchor="gadgets.rpc.call">
      <t>&lt;static&gt; gadgets.rpc.call(targetId, serviceName, callback,
      var_args)</t>
      <t>Description: Calls an RPC service.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>targetId</c>
       <c>String</c>
       <c>ID of the RPC service provider; empty if calling the parent
       container</c>
       <c>serviceName</c>
       <c>String</c>
       <c>Service name to call</c>
       <c>callback</c>
       <c>Function|null</c>
       <c>Callback function (if any) to process the return value of the RPC
       request. The callback function will not be called until after the
       existing callstack has completed execution.</c>
       <c>var_args</c>
       <c>*</c>
       <c>Parameters for the RPC request</c>
      </texttable></t>
     </section>

       <section title="config" anchor="gadgets.rpc.config">
			<t>&lt;static&gt; gadgets.rpc.config(params)</t>
			<t>Description: Configures the existing RPC instance with the given parameters. Paramaters is a <xref target="gadgets.rpc.ConfigParameters">gadgets.rpc.ConfigParameters</xref></t>
			<t>
				Parameters:
				<texttable align="left">
					<ttcol>Name</ttcol>
					<ttcol>Type</ttcol>
					<ttcol>Description</ttcol>
					<c>params</c>
					<c>gadgets.rpc.ConfigParameters</c>
					<c>Parameters object passed into the config method.
					</c>
				</texttable>
			</t>
	</section>

	<section title="getReceiverOrigin" anchor="gadgets.rpc.getReceiverOrigin">

			<t>&lt;static&gt; gadgets.rpc.getReceiverOrigin(receiverId)</t>
			<t>Description: Returns the origin for the given RPC service provider.  If the origin cannot be verified, returns null.</t>
			<t>
				Parameters:
				<texttable align="left">
					<ttcol>Name</ttcol>
					<ttcol>Type</ttcol>
					<ttcol>Description</ttcol>
					<c>receiverId</c>
					<c>String</c>
					<c>ID of the RPC service provider; empty if calling the parent
						container</c>
				</texttable>
			</t>
			<t>
				Returns:
				<texttable align="left">
					<ttcol>Type</ttcol>
					<ttcol>Description</ttcol>
					<c>String|null</c>
					<c>If the underlying transport is parent-verifiable, then returns the origin for the given receiverId, otherwise, returns null.</c>
				</texttable>
			</t>
	</section>


     <section title="register"
              anchor="gadgets.rpc.register">
      <t>&lt;static&gt; gadgets.rpc.register(serviceName, handler)</t>
      <t>Description: Registers an RPC service.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>serviceName</c>
       <c>String</c>
       <c>Service name to register</c>
       <c>handler</c>
       <c>Function</c>
       <c>Service handler</c>
      </texttable></t>
     </section>
     <section title="registerDefault"
              anchor="gadgets.rpc.registerDefault">
      <t>&lt;static&gt; gadgets.rpc.registerDefault(handler)</t>
      <t>Description: Registers a default service handler to process all
      unknown remote procedure calls, which fail silently by default.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>handler</c>
       <c>Function</c>
       <c>Service handler</c>
      </texttable></t>
     </section>
     <section title="unregister"
              anchor="gadgets.rpc.unregister">
      <t>&lt;static&gt; gadgets.rpc.unregister(serviceName)</t>
      <t>Description: Unregisters an RPC service.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>serviceName</c>
       <c>String</c>
       <c>Service name to unregister</c>
      </texttable></t>
     </section>
     <section title="unregisterDefault"
              anchor="gadgets.rpc.unregisterDefault">
      <t>&lt;static&gt; gadgets.rpc.unregisterDefault()</t>
      <t>Description: Unregisters the default service handler. Future unknown
      remote procedure calls will fail silently.</t>
     </section>
    </section>

     <section title="ConfigParameters" anchor="gadgets.rpc.ConfigParameters">
			<t>gadgets.rpc.ConfigParameters</t>
			<t>Description: Object used to hold the parameters into the config method, supports the following properties: </t>
			<t>
				<texttable align="left">
					<ttcol>Name</ttcol>
					<ttcol>Type</ttcol>
					<ttcol>Description</ttcol>
					<c>securityCallback</c>
					<c>function</c>
					<c>securityCallback:  Callback function which is invoked when RPC connection encounters a security issue. Function syntax is securityCallback( receiverId, error ). The following are the defined security errors:
						<list style="symbols">
							<t>gadgets.rpc.LOAD_TIMEOUT - receiver failed to connect in time</t>
							<t>gadgets.rpc.FRAME_PHISH - receiver's iframe may have been maliciously redirected to a new location</t>
							<t>gadgets.rpc.FORGED_MSG - RPC detected a possibly forged message</t>
						</list>
					</c>
				</texttable>
			</t>
	</section>
   </section>
   <section title="gadgets.selection" anchor="gadgets.selection">
<xref target="Issue-1161">Discussion</xref>
  	 <section title="Overview" anchor="gadgets.selection.overview">
	  	 <t>The selection feature gives gadgets the ability to participate in the container's selection eventing. The concept
	  		of selection is common among many containers. Examples include:
	 		<list style="symbols">
	  		 <t>selected person in a buddy or contacts list</t>
	  		 <t>selected activity in an activity stream</t>
	  		 <t>selected item in a user's profile</t>
	  		</list>
	  	 </t>
	  	 <t>Selection is a user-driven singleton belonging to the container. For example, when a user selects
	  		a Person in their contact list before sending that Person a message, that Person becomes the selected object.  Typically, a
	  		user gesture triggers a gadget to post selection to the container's selection service.
	  		Each time something is posted to the selection service, gadgets that are registered to listen for selection events are
	  		notified. The current selection for the container represents what was posted last and can be queried at any time. The
	  		selected object can represent a single object or a collection of objects.</t>
	  	 <t>Note: gadgets must opt in to publish data via selection and should be aware it is a broadcast event.</t>
  	</section>
    <section title="Method Details">
   		<section title="setSelection" anchor="gadgets.selection.setSelection">
   			<t>&lt;static&gt; gadgets.selection.setSelection (selectionArray)</t>
   			<t>Description: Sets the selection for the container.  The selection may be an array of multiple objects.
   			</t>
   			<t>Parameters:
				<texttable align="left">
		         <ttcol>Name</ttcol>
		         <ttcol>Type</ttcol>
		         <ttcol>Description</ttcol>
		         <c>selectionArray</c>
		         <c>Object[]</c>
		         <c>Array of object(s) to be set as selected, with attributes defined in table below.</c>
		        </texttable>
		    </t>
		    <t>Each selection object must have the following attributes:
		  	  <texttable align="left">
		  	   <ttcol>Name</ttcol>
		  	   <ttcol>Type</ttcol>
		  	   <ttcol>Description</ttcol>
		  	   <c>type</c>
		  	   <c>String</c>
		  	   <c>Open Social data type, as specified in the <eref target="./Social-Data.xml">Social Data Specification</eref></c>
			   <c>dataObject</c>
		  	   <c>Object</c>
		  	   <c>Object representing the selection.</c>

		  	  </texttable>
  	 		</t>
  	 		<t>
				Example:
				<artwork type="code">
//an array of 2 people who are currently selected
var selection = [
	{type: "opensocial.Person", dataObject: bob}, {type: "opensocial.Person", dataObject: joe}
];
gadgets.selection.setSelection(selection);
	   			</artwork>
   			</t>
   		</section>
   		<section title="getSelection" anchor="gadgets.selection.getSelection">
   			<t>&lt;static&gt; Type: Object[] gadgets.selection.getSelection()</t>
   			<t>Description: Gets the current selection for the container.</t>
   			<t>Returns:
	   			<texttable align="left">
		         <ttcol>Type</ttcol>
		         <ttcol>Description</ttcol>
		         <c>Object[]</c>
		         <c>The array of currently selected objects, each with type and dataObject properties</c>
		        </texttable>
   			</t>
   		</section>
   		<section title="addListener" anchor="gadgets.selection.addListener">
   			<t>&lt;static&gt; gadgets.selection.addListener(callback)</t>
   			<t>Description: Registers the callback function to be called for selection events. <xref target="Issue-1259">Discussion</xref></t>
   			<t>
				<texttable align="left">
		         <ttcol>Name</ttcol>
		         <ttcol>Type</ttcol>
		         <ttcol>Description</ttcol>
		         <c>callback</c>
		         <c>Function</c>
		         <c>The callback function that is called for the specified selection event.</c>
		        </texttable>
   			</t>
   		</section>
   		<section title="removeListener" anchor="gadgets.selection.removeListener">
   			<t>&lt;static&gt; gadgets.selection.removeListener(callback)</t>
   			<t>Description: Unregisters the callback function previously registered by addListener. <xref target="Issue-1259">Discussion</xref></t>
   			<t>Parameters:
	   			<texttable align="left">
		         <ttcol>Name</ttcol>
		         <ttcol>Type</ttcol>
		         <ttcol>Description</ttcol>
		         <c>callback</c>
		         <c>Function</c>
		         <c>The callback function to be unregistered.</c>
		        </texttable>
   			</t>
   		</section>

   	</section>
   </section>
   <section title="gadgets.skins"
            anchor="gadgets.skins">
<x:deprecated href="http://code.google.com/p/opensocial-resources/issues/detail?id=1275" note="Deprecated in OpenSocial 2.5">            
    <!-- ============================== class summary ========================== -->
    <t>Provides operations for getting display information about the currently
    shown skin.</t>
    <section title="Method Details">
     <section title="getProperty"
              anchor="gadgets.skins.getProperty">
      <t>&lt;static&gt; Type: {String}
      gadgets.skins.getProperty(propertyKey)</t>
      <t>Description: Fetches the display property mapped to the given key.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>propertyKey</c>
       <c>String</c>
       <c>The key to get data for; keys are defined in
       <xref target="gadgets.skins.Property">gadgets.skins.Property</xref> </c>
      </texttable></t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>String</c>
       <c>The data</c>
      </texttable></t>
     </section>
    </section>
</x:deprecated>
   </section>
   <section title="gadgets.skins.Property"
            anchor="gadgets.skins.Property">
<x:deprecated href="http://code.google.com/p/opensocial-resources/issues/detail?id=1275" note="Deprecated in OpenSocial 2.5">      
    <!-- ============================== class summary ========================== -->
    <t>All of the display values that can be fetched and used in the gadgets
    UI. These are the supported keys for the
    <xref target="gadgets.skins.getProperty">
    gadgets.skins.getProperty()</xref> method.</t>
    <list style="hanging">
     <t hangText="ANCHOR_COLOR"
              anchor="gadgets.skins.Property.ANCHOR_COLOR">
      The color that anchor tags should use. This field may be
      used interchangeably with the string 'ANCHOR_COLOR'.
     </t>
     <t hangText="BG_COLOR"
              anchor="gadgets.skins.Property.BG_COLOR">
      The color of the background of the gadget. This field may
      be used interchangeably with the string 'BG_COLOR'.</t>
     <t hangText="BG_IMAGE"
              anchor="gadgets.skins.Property.BG_IMAGE">
      An image to use in the background of the gadget. This
      field may be used interchangeably with the string 'BG_IMAGE'.</t>
     <t hangText="FONT_COLOR"
              anchor="gadgets.skins.Property.FONT_COLOR">
      The color in which the main font should be rendered. This
      field may be used interchangeably with the string 'FONT_COLOR'.</t>
    </list>
</x:deprecated>
   </section>
   <section title="gadgets.Tab"
            anchor="gadgets.Tab">
    <x:deprecated href="http://code.google.com/p/opensocial-resources/issues/detail?id=1275" note="Deprecated in OpenSocial 2.5">
    <!-- ============================== class summary ========================== -->
    <t>Tab class for gadgets. You create tabs using the TabSet addTab() method.
    To get Tab objects, use the TabSet getSelectedTab() or getTabs() methods.
    <t>See also:
    <xref target="gadgets.TabSet">TabSet</xref> </t></t>
    <section title="Method Details">
     <section title="getCallback"
              anchor="gadgets.Tab.getCallback">
      <t>Type: {Function} getCallback()</t>
      <t>Description: Returns the callback function that is executed when the
      tab is selected.</t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>Function</c>
       <c>The callback function of the tab</c>
      </texttable></t>
     </section>
     <section title="getContentContainer"
              anchor="gadgets.Tab.getContentContainer">
      <t>Type: {HTMLElement} getContentContainer()</t>
      <t>Description: Returns the HTML element where the tab content is
      rendered.</t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>HTMLElement</c>
       <c>The HTML element of the content container</c>
      </texttable></t>
     </section>
     <section title="getIndex"
              anchor="gadgets.Tab.getIndex">
      <t>Type: {Number} getIndex()</t>
      <t>Description: Returns the tab's index.</t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>Number</c>
       <c>The tab's index</c>
      </texttable></t>
     </section>
     <section title="getName"
              anchor="gadgets.Tab.getName">
      <t>Type: {String} getName()</t>
      <t>Description: Returns the label of the tab as a string (may contain
      HTML).</t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>String</c>
       <c>The label of the tab</c>
      </texttable></t>
     </section>
     <section title="getNameContainer"
              anchor="gadgets.Tab.getNameContainer">
      <t>Type: {HTMLElement} getNameContainer()</t>
      <t>Description: Returns the HTML element that contains the tab's
      label.</t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>HTMLElement</c>
       <c>The HTML element of the tab's label</c>
      </texttable></t>
     </section>
    </section>
    </x:deprecated>
   </section>
   <section title="gadgets.TabSet"
            anchor="gadgets.TabSet">
<x:deprecated href="http://code.google.com/p/opensocial-resources/issues/detail?id=1275" note="Deprecated in OpenSocial 2.5">      
    <!-- ============================== class summary ========================== -->
    <t>A class gadgets can use to make tabs.</t>
    <!-- ============================== constructor details ==================== -->
    <section title="Constructor"
             anchor="gadgets.TabSet.ctor">
     <t>gadgets.TabSet(opt_moduleId, opt_defaultTab, opt_container)</t>
     <t>Creates a new TabSet object</t>
     <t>Parameters:
     <texttable align="left">
      <ttcol>Name</ttcol>
      <ttcol>Type</ttcol>
      <ttcol>Description</ttcol>
      <c>opt_moduleId</c>
      <c>String</c>
      <c>Optional suffix for the ID of tab container</c>
      <c>opt_defaultTab</c>
      <c>String</c>
      <c>Optional tab name that specifies the name of of the tab that is
      selected after initialization; if this parameter is omitted, the first
      tab is selected by default</c>
      <c>opt_container</c>
      <c>HTMLElement</c>
      <c>The HTML element to contain the tabs; if omitted, a new div element is
      created and inserted at the very top</c>
     </texttable></t>
    </section>
    <section title="Method Details">
     <section title="addTab"
              anchor="gadgets.TabSet.addTab">
      <t>Type: {String} addTab(tabName, opt_params)</t>
      <t>Description: Adds a new tab based on the name-value pairs specified in
      opt_params. The following properties are supported in opt_params:
      <list style="hanging">
       <t hangText="contentContainer">An existing HTML element to be used as
       the tab content container. If omitted, the tabs library creates one.</t>
       <t hangText="callback">A callback function to be executed when the tab
       is selected. The callback function will not be called until after the
       existing callstack has completed execution.</t>
       <t hangText="tooltip">A tooltip description that pops up when user moves
       the mouse cursor over the tab.</t>
       <t hangText="index">The index at which to insert the tab. If omitted,
       the new tab is appended to the end.</t>
      </list></t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>tabName</c>
       <c>String</c>
       <c>Label of the tab to create</c>
       <c>opt_params</c>
       <c>Object</c>
       <c>Optional parameter object</c>
      </texttable></t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>String</c>
       <c>DOM id of the tab container</c>
      </texttable></t>
     </section>
     <section title="alignTabs"
              anchor="gadgets.TabSet.alignTabs">
      <t>alignTabs(align, opt_offset)</t>
      <t>Description: Sets the alignment of tabs. Tabs are center-aligned by
      default.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>align</c>
       <c>String</c>
       <c>'left', 'center', or 'right'</c>
       <c>opt_offset</c>
       <c>Number</c>
       <c>Optional parameter to set the number of pixels to offset tabs from
       the left or right edge; the default value is 3px</c>
      </texttable></t>
     </section>
     <section title="displayTabs"
              anchor="gadgets.TabSet.displayTabs">
      <t>displayTabs(display)</t>
      <t>Description: Shows or hides tabs and all associated content.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>display</c>
       <c>Boolean</c>
       <c>True to show tabs; false to hide tabs</c>
      </texttable></t>
     </section>
     <section title="getHeaderContainer"
              anchor="gadgets.TabSet.getHeaderContainer">
      <t>Type: {HTMLElement} getHeaderContainer()</t>
      <t>Description: Returns the tab headers container element.</t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>HTMLElement</c>
       <c>The tab headers container element</c>
      </texttable></t>
     </section>
     <section title="getSelectedTab"
              anchor="gadgets.TabSet.getSelectedTab">
      <t>Type: {
      <xref target="gadgets.Tab">gadgets.Tab</xref> } getSelectedTab()</t>
      <t>Description: Returns the currently selected tab object.</t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>
        <xref target="gadgets.Tab">gadgets.Tab</xref>
       </c>
       <c>The currently selected tab object</c>
      </texttable></t>
     </section>
     <section title="getTabs"
              anchor="gadgets.TabSet.getTabs">
      <t>Type: {Array.&lt;gadgets.Tab&gt;} getTabs()</t>
      <t>Description: Returns an array of all existing tab objects.</t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>Array.&lt;gadgets.Tab&gt;</c>
       <c>Array of all existing tab objects</c>
      </texttable></t>
     </section>
     <section title="removeTab"
              anchor="gadgets.TabSet.removeTab">
      <t>removeTab(tabIndex)</t>
      <t>Description: Removes a tab at tabIndex and all of its associated
      content.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>tabIndex</c>
       <c>Number</c>
       <c>Index of the tab to remove</c>
      </texttable></t>
     </section>
     <section title="setSelectedTab"
              anchor="gadgets.TabSet.setSelectedTab">
      <t>setSelectedTab(tabIndex)</t>
      <t>Description: Selects the tab at tabIndex and fires the tab's callback
      function if it exists. If the tab is already selected, the callback is
      not fired.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>tabIndex</c>
       <c>Number</c>
       <c>Index of the tab to select</c>
      </texttable></t>
     </section>
     <section title="swapTabs"
              anchor="gadgets.TabSet.swapTabs">
      <t>swapTabs(tabIndex1, tabIndex2)</t>
      <t>Description: Swaps the positions of tabs at tabIndex1 and tabIndex2.
      The selected tab does not change, and no callback functions are
      called.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>tabIndex1</c>
       <c>Number</c>
       <c>Index of the first tab to swap</c>
       <c>tabIndex2</c>
       <c>Number</c>
       <c>Index of the secnod tab to swap</c>
      </texttable></t>
     </section>
    </section>
    </x:deprecated>
   </section>
   <section title="gadgets.window"
            anchor="gadgets.window">
    <!-- ============================== class summary ========================== -->
    <t>Provides operations for getting information about and modifying the
    window the gadget is placed in.</t>
    <section title="Method Details">
     <section title="adjustHeight"
              anchor="gadgets.window.adjustHeight">
      <t>&lt;static&gt; gadgets.window.adjustHeight(opt_height)</t>
      <t>Description: Adjusts the gadget height.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>opt_height</c>
       <c>Number</c>
       <c>An optional preferred height in pixels; If not specified, will
       attempt to fit the gadget to its content</c>
      </texttable></t>
     </section>
     <section title="adjustWidth" anchor="gadgets.window.adjustWidth">
       <xref target="Issue-1191">Discussion</xref>
	     <t>&lt;static&gt; gadgets.window.adjustWidth(opt_width)</t>
	     <t>Description: Adjusts the gadget width.</t>
	     <t>Parameters:
	       <texttable align="left">
	         <ttcol>Name</ttcol>
	         <ttcol>Type</ttcol>
	         <ttcol>Description</ttcol>
	         <c>opt_width</c>
	         <c>Number</c>
	         <c>An optional preferred width in pixels; If not specified, will attempt to fit the gadget to its content</c>
	       </texttable>
	     </t>
     </section>
     <section title="adjustSize" anchor="gadgets.window.adjustSize">
          <xref target="Issue-1191">Discussion</xref>
         <t>&lt;static&gt; gadgets.window.adjustSize(opt_height, opt_width)</t>
         <t>Description: Adjusts the gadget size.</t>
         <t>Parameters:
           <texttable align="left">
             <ttcol>Name</ttcol>
             <ttcol>Type</ttcol>
             <ttcol>Description</ttcol>
             <c>opt_height</c>
             <c>Number</c>
             <c>An optional preferred height in pixels; If not specified, will attempt to fit the gadget to its content</c>
             <c>opt_width</c>
             <c>Number</c>
             <c>An optional preferred width in pixels; If not specified, will attempt to fit the gadget to its content</c>
           </texttable>
         </t>
     </section>
     <section title="getViewportDimensions"
              anchor="gadgets.window.getViewportDimensions">
      <t>&lt;static&gt; Type: {Object}
      gadgets.window.getViewportDimensions()</t>
      <t>Description: Detects the inner dimensions of a frame. See
      <eref target="http://www.quirksmode.org/dom/w3c_cssom">
      http://www.quirksmode.org/dom/w3c_cssom</eref> for more information.</t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>Object</c>
       <c>An object with width and height properties</c>
      </texttable></t>
     </section>
     <section title="getContainerDimensions"
              anchor="gadgets.window.getContainerDimensions">
      <t>&lt;static&gt; gadgets.window.getContainerDimensions(resultCallback)</t>
      <t>Description: Gets the dimensions of the container displaying this gadget through callback function which will be called with the return value as a parameter.   <xref target="Issue-1167">Discussion</xref></t>
      <t>Parameter:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>resultCallback</c>
       <c>function</c>
       <c>Callback function will be called with the return value as a parameter.</c>
      </texttable></t>
     </section>
     <section title="setTitle"
              anchor="gadgets.window.setTitle">
      <t>&lt;static&gt; gadgets.window.setTitle(title)</t>
      <t>Description: Sets the gadget title.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>title</c>
       <c>String</c>
       <c>The preferred title</c>
      </texttable></t>
     </section>
    </section>
   </section>

<section title="Inter-Gadget Eventing" anchor="interGadgetEventing">
        <t>The inter-gadget eventing mechanism in OpenSocial, commonly known
            as pub/sub, provides the ability for loosely coupled inter-gadget
            communication via the delivery of messages on topics. The definition
            of the OpenSocial API is based on the OpenAjax Hub 2.0 (OA Hub)
            specification defined by the OpenAjax Alliance. The addition of this
            capability adds API in three areas, an event hub to manage the
            subscription and publication of events on the client, the publish and
            subscribe methods for the gadgets, and wiring meta-data that can be
            used by advanced containers and tooling. The semantics of the API
            offered in OpenSocial will match that of the OA Hub.</t>
        <t>Process: Pub/sub is handled through messages between a client and
            the hub, which are defined in the OpenAjax specification. There is one hub client per gadget instance. When
            the gadget is loaded, the client is "connected" to the hub. The
            general pattern for using pub/sub in a gadget is as follows:</t>
        <list style="numbers">
            <t>(Optional) Override the default settings used to configure the gadget's hub client instance.</t>
            <t>Call publish or subscribe methods.</t>
        </list>
        <t>The full capability of the OpenAjax Hub is available for use within
    OpenSocial. To understand the complete set of capability provided by
    the hub, please refer to OpenAjax Web site for the complete
    documentation and specification. </t>
        <t>
            In order to take advantage of intergadget communication, each
            instance of a gadget needs a client that that is connected to the
            hub. The full specification for the client is available on the
            OpenAjax Alliance documentation Web site. Please refer to
            <eref
                target="http://openajax.org/member/wiki/OpenAjax_Hub_2.0_Specification_Managed_Hub_APIs#OpenAjax.hub.HubClient">OpenAjax Hub Client section</eref>
            for more information. Following the general pattern of pub/sub based
            systems, a gadget will publish a message on a topic. Other gadgets
            (or even the publishing gadget) may subscribe to the topic to receive
            the information that has been published. In addition, the OpenAjax
            Alliance has defined a collection of best practices that should be
            used as guidelines when developing gadgets that leverage pub/sub.
            Please see
            <eref
                tartget="http://www.openajax.org/member/wiki/OpenAjax_Hub_2.0_Specification_Best_Practices">OpenAjax Hub 2.0 Specification Best Practices</eref>
            for more information.
        </t>
        <section
            title="Container responsibilities for supporting inter-gadget eventing">
            <t>
                In order to ensure that the OpenAjax Hub client is properly
                configured, when the PubSub feature is added, the container MUST
                provide the following initialization steps for the gadget when this
                feature is added. The behavior described in this section ensures that
                simple gadgets do not need to do anything at all to set up their
                HubClient instances; but it allows gadgets with special needs to
                override the default parameters and behavior as required.
                <list style="numbers">
                    <t>Set default values</t>
                    <t>Register an onLoad handler</t>
                    <t>The onLoad handler constructs the HubClient and calls HubClient.connect.</t>
                </list>
            </t>
    </section>
        <section title="Topics" anchor="Topics">
            <t> The publish and subscribe methods, as well as the wiring
                metadata make use of a "topic". A "topic" MUST be a String and MUST
                conform to the Topic Name Rules defined by the OpenAjax Hub. The
                following list summarizes the content that is described by the OA
                Hub speicificaiton.</t>
            <list style="symbols">
                <t>Wildcards usage on topic subscription: Valid wild cards are "*"
                    for single token and "**" for multiple token.</t>
                <t>Considerations on unicode and special characters: Developers
                    SHOULD NOT not use control, whitespace, quote, or punctuation
                    characters in topic names.</t>
                <t>
                    Reverse DNS topic names: To avoid potential topic name conflicts
                    with other components, it is RECOMMENDED that all topic names begin
                    with a registered internet domain expressed in reverse order, such
                    as org.openajax.registerLibrary. Further, there SHOULD be a logical
                    correlation between the reverse DNS namespace of the topic name and
                    the prefix pattern used when defining an extension to the
                    OpenSocial data model. See
                    <xref target="OpenSocial-Specification">OpenSocial Specification</xref>
                    for more details on the extension model.
                </t>
                    <t>
                See
                <eref
                    target="http://www.openajax.org/member/wiki/OpenAjax_Hub_2.0_Specification_Topic_Names">OpenAjax Hub 2.0 Specification Topic Names</eref>
                for more information.
            </t>
            </list>
            <section title="Reserved Topic Namespace" anchor="ReservedTopicNamespace">
                <t>OpenSocial reserves the reverse DNS namespace
                    org.opensocial, and all derivities, for use within the OpenSocial specification.
                    Developers MUST NOT use org.opensocial or any derivitive
                    namespace when defining their own topics.</t>

            </section>

        </section>
        <section title="gadgets.Hub" anchor="gadgets.Hub">

            <section title="Method Details">
                <section title="publish" anchor="publish">
                    <t>publish(topic, payload)</t>
                    <t>Description: The publish method conforms to the semantics of the
                        OA Hub. The OAHub embraces the notion that pubsub is anonymous and
                        does not automatically include any information about the
                        identification of the publishing gadget with the message. The
                        following is an excerpt from their documentation.</t>
                    <t>
                        Parameters:
                        <texttable align="left">
                            <ttcol>Name</ttcol>
                            <ttcol>Type</ttcol>
                            <ttcol>Description</ttcol>
                            <c>topic</c>
                            <c>String</c>
                            <c>A string that conforms to the rules defined above and by the
                                OA Hub to name the channel that the payload will be deliverd on.
                                Wildcards are NOT permitted.</c>
                            <c>payload</c>
                            <c>*</c>
                            <c>It is permissible to publish any object. The payload MUST
                                be serializable to JSON.</c>
                        </texttable>
                    </t>
                    <t>See the <eref target="http://www.openajax.org/member/wiki/OpenAjax_Hub_2.0_Specification_Managed_Hub_APIs#OpenAjax.hub.Hub.prototype.publish">OpenAjax Hub 2.0 documentation</eref> for more information.</t>
                    <section title="subscribe" anchor="subscribe">
                        <t>subscribe(topic, callback [,scope [,onCompleteCallback [,subscriberData]]])</t>
                        <t>Description: The subscribe method is used to indicate to the
                            hub the topic from which the gadget is interested in receiving
                            information. When information is published on the topic, the hub
                            will invoke the callback method on the gadget. Since a gadget may
                            have multiple subscriptions on the same topic, the subscribe
                            method returns an opaque identifier that is used to uniquely
                            identify the subscription. This identifier is used to unsubscribe
                            to the topic. It is gadget developer's responsibility to manage
                            this identifier.</t>
                        <t>
    Parameters:
    <texttable align="left">
        <ttcol>Name</ttcol>
        <ttcol>Type</ttcol>
        <ttcol>Description</ttcol>
        <c>topic</c>
        <c>String</c>
        <c>A string that conforms to the rules defined above and by the OA Hub
            to name the channel that the payload will be deliverd on. Wildcards
            MAY be used.</c>
        <c>callback</c>
        <c>String</c>
        <c>A callback function to be executed when the tab is selected. The
            callback function will not be called until after the existing
            callstack has completed execution.</c>
        <c>scope</c>
        <c>object</c>
        <c> When onData callback or onComplete callback is invoked, the
            JavaScript "this" keyword refers to this scope object. If no scope is
            provided, default is window.</c>
        <c>onCompleteCallback</c>
        <c>function</c>
        <c> Function invoked to tell the client application whether the
            subscribe operation succeeded or failed.</c>
        <c>subscriberData</c>
        <c>*</c>
        <c>Client application provides this data, which is handed back to the
            client application in the subscriberData parameter of the onData
            callback function.</c>
    </texttable>
</t>
                        <t>
    Returns:
    <texttable align="left">
        <ttcol>Type</ttcol>
        <ttcol>Description</ttcol>
        <c>String</c>
        <c>An opaque subscription identifier. This identifier is an arbitrary
            ID string that is unique within this Hub instance</c>
    </texttable>
        <t>See the <eref target="http://www.openajax.org/member/wiki/OpenAjax_Hub_2.0_Specification_Managed_Hub_APIs#OpenAjax.hub.Hub.prototype.subscribe">OpenAjax Hub documentation</eref> for
    more information</t>
    </t>
    </section>
    <section title="unsubscribe" anchor="unsubscribe">
        <t>unsubscribe(subscriptionId)</t>
        <t>Description: This method is used to remove a subuscription for a
            gadget from the hub. The unsubscribe function immediately throws an
            exception if there is no subscription with the specified subscription
            ID. Otherwise, unsubscribe immediately deactivates the subscription.
        </t>
        <t>
            Parameters:
            <texttable align="left">
                <ttcol>Name</ttcol>
                <ttcol>Type</ttcol>
                <ttcol>Description</ttcol>
                <c>subscriptionId</c>
                <c>String</c>
                <c>The subscriptionId is the opaque string that is returned from the
                    subscribe(...) method.</c>
            </texttable>
        </t>
        <t>See the <eref target="http://www.openajax.org/member/wiki/OpenAjax_Hub_2.0_Specification_Managed_Hub_APIs#OpenAjax.hub.Hub.prototype.unsubscribe">OpenAjax Hub documentation</eref> for
            more information.</t>
         </section>

        </section>
        <section title="Other Methods" anchor="OtherMethods">
            <t>The 'gadgets.Hub' object is an instance of IframeHubClient and supports some additional methods.
            Please see the <eref target="http://www.openajax.org/member/wiki/OpenAjax_Hub_2.0_Specification_Managed_Hub_APIs#OpenAjax.hub.IframeHubClient">OpenAjax Hub documentation</eref> for more information.</t>
        </section>
        </section>


        </section>

    <section title="Container Example" anchor="ContainerExample">
    <t>The following example illustrates how a container could provide support for this feature.</t>
    <list style="numbers">
        <t>
            Set default values.
            <artwork type="code">
// Create a pubsub settings object
gadgets.HubSettings = {};

// Set default HubClient constructor params object
gadgets.HubSettings.params = {
 HubClient: {
    onSecurityAlert: function( alertSource, alertType ) {
      alert( "Gadget stopped attempted security breach: " + alertType );
      window.location.href = "about:blank"; // Forces container to see Frame Phish alert and probably close this gadget
    },
    scope: gadgetInstance
  } };

// Set default onComplete function for HubClient.connect
gadgets.HubSettings.onConnected = function( hub, suc, err ) { };
            </artwork>
        </t>
        <t>
    Register an onLoad handler
    <t>An onLoad handler to actually create the HubClient and connect it
        to the ManagedHub. Delaying the HubClient creation and
        connection allows the gadget to override default values stored
        in gadgets.HubSettings. For example, IframeHubClient
        supports params properties such as seed, tokenLength and log,
        which are not set by default; and a gadget might need to
        override onSecurityAlert and/or scope, for which default values
        are provided. More importantly, the onComplete function for
        HubClient.connect usually sets up the gadget's subscriptions by
        calling gadgets.Hub.subscribe, or if the connection fails
        asynchronously, the onComplete function handles the error.</t>
            <artwork type="code">
// Register an onLoad handler
gadgets.util.registerOnLoadHandler( function() {
  try {
    // Create the HubClient.
    gadgets.Hub = new OpenAjax.hub.IframeHubClient(  gadgets.HubSettings.params );

    // Connect to the ManagedHub
    gadgets.Hub.connect( gadgets.HubSettings.onConnect );

  } catch(e) {
    // TODO: error handling should be consistent with other OS gadget initialization error handling
  }
} );
            </artwork>
        </t>

    </list>
</section>
    <section title="Gadget Example" anchor="GadgetExample">
        <t>By default, a HubClient is instantiated automatically by the
                        pubsub-2 code, on gadget load. If the gadget wants to override the default parameters to the HubClient
                        constructor, it can do so by setting values on gadgets.HubSettings. For
                        example:</t>
                <artwork type="code">
gadgets.HubSettings.params.HubClient.onSecurityAlert = function(alertSource, alertType) {
        // handle security alert here
};
gadgets.HubSettings.params.HubClient.log = function(msg) {
        // custom logging code here, for recording logging msgs from HubClient
};
gadgets.util.registerOnLoadHandler(function() {
        gadgets.Hub.subscribe("org.foo.bar.topic", callback);
        gadgets.Hub.publish("org.foo.bar.topic2", data);
});
   </artwork>
        <t>
            See
            <eref
                target="http://openajax.org/member/wiki/OpenAjax_Hub_2.0_Specification_Managed_Hub_APIs#OpenAjax.hub.HubClient_constructor">OpenAjax Hub 2.0 Specification document</eref>
            for more information.
        </t>
    </section>
    <section title="Wiring Metadata">
        <t> The OpenSocial specification defines additional metadata that can
    be used to describe the events that a gadget publishes or to which it
    is able to subscribe. This allows the container to automatically "wire" gadgets together, and/or provide a
    UI that allows the user to wire publisher gadgets to subscriber
    gadgets. For example, manual wiring is often necessary because there
    sometimes are multiple widgets publishing to or subscribing to the same
    topic, such as "date", where one widget might provide a start date and
    the other widget an end date, and also because sometimes topic names
    and/or payload types are too generic for automatic mapping.</t>

    <section title="Attributes for Wiring Metadata" anchor="AttributesForWiringMetadata">
        <t>
            <texttable align="left">
                <ttcol>Attribute</ttcol>
                <ttcol>Type</ttcol>
                <ttcol>Usage</ttcol>
                <ttcol>Description</ttcol>
                <c>name</c>
                <c>String</c>
                <c>Required</c>
                <c>
                The dot-delimited topic name, e.g. "org.example.randomNumber". This
                name follows the rules defined in the <eref target="http://www.openajax.org/member/wiki/OpenAjax_Metadata_1.0_Specification_Widget_Metadata#topic_element_name_attribute">OpenAjax Widget Metadata
                specification</eref>. Developers of gadgets MAY allow the @name attribute to be ovveridden using user preference variables. See <xref target="usingVariablesForNameAttribute">Using Varuables for @name</xref></c>

                <c>type</c>
                <c>String</c>
                <c>Optional</c>
                <c>Type name for the event's payload data. When not specificed, any
                type wil be allowed. See <xref target="EventDataTypes">Event Data Types</xref>.</c>

                <c>title</c>
                <c>String</c>
                <c>Optional</c>
                <c>Title for this type of event that is appropriate for a non-technical reader. When not specified, the value of the "name" attribute will be used.</c>

                <c>publish</c>
                <c>boolean</c>
                <c>Optional</c>
                <c>Indicates if the gadget publishes events on this topic. The default value is "false".</c>

                <c>subscribe</c>
                <c>boolean</c>
                <c>Optional</c>
                <c>Indicates if the gadget subscribes to events that are published on this topic. The default value is "false".</c>

                <c>description</c>
                <c>String</c>
                <c>Optional</c>
                <c>
                The textual description of the gadget's publish or subscribe
                endpoint.
                This can be used as an indication of the gadget's behavior.
                Consider a gadget that subscribes to a topic "com.example.address".
                The description migh read, "When this gadget receives an event on the com.example.address
                topic, it displays mass transit options within 10km of the address received as the event payload."</c>

                <c>aboutUrl</c>
                <c>String</c>
                <c>Optional</c>
                <c>
                A URL pointing to a resource that provides more extensive
                descriptive information than can be provided in the description
                attribute.</c>
            </texttable>
        </t>
        <section title="Using Variables for @name" anchor="usingVariablesForNameAttribute">
        <t>
                In the absence of a specific standard for events within a given
                domain, it is inevitable that different groups of developers,
                working in different niches on similar problems, will use different
                topic naming schemes for what is essentially the same event. While
                some developers in a domain may eventually consolidate around a
                standard set of topic names, it's also inevitable that installed
                bases, legacy implementations, politics, requirement to integrate
                with third party gadgets from other domains, schedule constraints
                and other factors will ensure that once a topic space becomes
                balkanized, it will remain that way for a long time.</t>
                <t>It is important that the specification offer a mechanism that allows
                developers to bridge simple mismatches between gadgets. It is
                important that gadget developers use this mechanism where possible.
                This will maximize the reusability of gadgets -- a major goal.</t>

                <section title="Example: Using Variables for @name">
                <t>The following is an example of how to use variable substituion in the definition of the @name attribute.
                <figure>
                   <artwork xml:space="preserve">
&lt;Require feature="pubsub-2"&gt;
  &lt;Param name="topics"&gt;&lt;![CDATA[
     &lt;Topic title="Selected Location" name="__UP_location__"
           description="The currently selected location" type="http://nsgs.gov/geo#Place"
           publish="false" subscribe="true" aboutUrl="http://nsgs.gov"&gt;
    &lt;/Topic&gt;
    &lt;!-- etc. for other topics --&gt;
  ]]&gt;&lt;/Param&gt;
&lt;/Require&gt;
                </artwork></figure></t>
             </section>

        </section>

    </section>


    <section title="Event Data Types" anchor="EventDataTypes">
    <t>The OpenAjax Hub has a predefined set of identifiers that are used to indicate the data type. Tooling and runtime
    container code can use this to infer information about the messages being published
    as well as the parameters a gadget expects to receive when it
    subscribes to a topic.</t>

    <t>
    The data types provided by the OpenAjax Hub are "built in". These
    are referred to as the OpenAjax common types, and they require no
    namespace qualifier. When a type other than an OpenAjax common type
    is used, it MUST contain a namesake qualifier. The namespace should
    conform to reverse DNS rules. The namespace
    org.opensocial.* MUST NOT be
    used and is reserved for types defined
    in the specification, e.g.
    social data types.

        <texttable align="left">
            <ttcol>Type Name</ttcol>
            <ttcol>Comments</ttcol>
            <c>string</c>
            <c>ECMAScipt string</c>
        <c>number</c>
            <c>ECMAScipt number </c>

            <c>boolean</c>
            <c>ECMAScipt boolean </c>


            <c>array</c>
            <c>ECMAScipt array, e.g. [ 1, 1, 2, 3, 5, 8 ]. The element type/s are not specified when the generic "array" type is used.</c>


            <c>object *</c>
            <c>ECMAScipt object, e.g. { foo: "bar", baz: "boo" }. The specifics of the object are not specified when the generic "object" type is used.</c>


            <c>null *</c>
            <c>ECMAScipt null</c>



            <c>length *</c>
            <c>Any CSS length value <span style="color:red"> Howard 2009.11.10: CSS version?</span></c>


            <c>color *</c>
            <c>Any CSS color value</c>


            <c>id</c>
            <c>ID value - probably not useful for OpenSocial Gadgets, but might as well keep the two specs in sync</c>


            <c>class *</c>
            <c>zero of more CSS class names, separated by spaces</c>


            <c>style *</c>
            <c>a string that could be used as value for a 'style' attribute</c>


            <c>url</c>
            <c>A URL <span style="color:red"> Howard 2009.11.09: Do we want "uri" also?</span></c>


            <c>html</c>
            <c>A fragment of HTML markup.</c>


            <c>countrycode *</c>
            <c>A string that represents an [http://www.iso.org/iso/country_codes/iso_3166_code_lists.htm A3 ISO 3166 country code].</c>


            <c>languagecode *</c>
            <c>A string that represents an [http://www.loc.gov/standards/iso639-2/php/code_list.php ISO 639-2 language code].</c>


            <c>email</c>
            <c>A string that represents an e-mail address.</c>


            <c>person</c>
            <c>A string that holds a person's name.</c>


            <c>postalcode</c>
            <c>A string that represents a postal code.</c>


            <c>phone</c>
            <c>A string that represents a phone number.</c>


            <c>date *</c>
            <c>A string that represents a date. MUST be expressed using the "Date Time String Format" defined in the [http://www.ecmascript.org/docs/tc39-2009-043.pdf ECMAScript5 specification] using one of the date-only forms. For example: "2009-12-15"</c>


            <c>time *</c>
            <c>A string that represents a time of day. MUST be expressed using the "Date Time String Format" defined in the [http://www.ecmascript.org/docs/tc39-2009-043.pdf ECMAScript5 specification] using one of the time-only forms. For example: "18:45:00Z" or "10:26:24-05:00"</c>


            <c>timestamp *</c>
            <c>A string that represents a date and time of day. MUST be expressed using the "Date Time String Format" defined in the [http://www.ecmascript.org/docs/tc39-2009-043.pdf ECMAScript5 specification]. For example: "2009-12-15:18:45.000Z"</c>


            <c>duration *</c>
            <c>A string that represents a duration. MUST have format "PYYYY-DDDThh:mm:ss.fff". For example, "P0400-152T20:45:33.123" means "400 years, 152 days, 20 hours, 45 minutes, 33.123 seconds, while "P0003-000T01:56:22.000" means "3 years, 1 hour, 56 minutes and 22.000 seconds." (Must use this one variant defined in the ISO 8601 standard). </c>


            <c>*</c>
            <c>Asterisk, or missing type attribute, means "any datatype"</c>

        </texttable>

        </t>

    </section>

    <section title="Wiring Metadata Format" anchor="WiringMetadataFormat">

    <t>
        The Pub/Sub feature supports format for metadata
        that uses a string to represent the
        topic information. The format of this string is as follows:
 <figure>
 <artwork type="xml:space=preserve">

 &lt;Require feature="pubsub-2"&gt;
  &lt;Param name="topics"&gt;&lt;![CDATA[
    &lt;Topic title="string" name="string" description="string" type="string"
           publish="boolean" subscribe="boolean" aboutUrl="string"&gt;
    &lt;/Topic&gt;
    &lt;!-- etc. for other topics --&gt;
  ]]&lt;/Param&gt;
&lt;/Require&gt;

 </artwork></figure></t>
    </section>

    </section>
</section>



   <section title="JavaScript Internationalization (i18n)">
    <t>A container MUST emit the OpenSocial JavaScript internationalization
    libraries and data files required by the libraries if an application
    requires the feature &lt;Require feature="opensocial-i18n"/&gt;. The
    container SHOULD emit the OpenSocial JavaScript internationalization
    libraries and data files required by the libraries if an application
    optionallly requests the feature &lt;Optional
    feature="opensocial-i18n"/&gt;.</t>
    <section title="gadgets.i18n"
             anchor="gadgets.i18n">
     <!-- ============================== class summary ========================== -->
     <t>Class for internationalization features.</t>
    </section>
    <section title="Formatting/Parsing using Predefined Patterns is Done within Default Locale">
     <t>Gadgets locale is set at render time. The i18n package above will use
     getCountry and getLanguage to load the corresponding formatter/parser for
     that locale if any of the functions in the package are invoked. For
     example, let's say gadgets has lanuguage as french and country as france,
     the i18n package will use formatter/parser following french conventions by
     default. That means gadget developers could format/parse French
     date/time/number/currency using the predefined CURRENCY_PATTERN.
     <figure>
      <preamble>Example</preamble>
      <artwork xml:space="preserve">
gadgets.i18n.parseNumber(gadgets.i18n.CURRENCY_PATTERN, "20 000 \u20AC"); // will return 20000
</artwork>
     </figure>They could also parse foreign currency by passing in a
     opt_currencyCode. Note when French writes an amount of foreign currency,
     they will still use the French way of writing numbers the positioning
     currency code - just the currency code is different.
     <figure>
      <preamble>Example</preamble>
      <artwork xml:space="preserve">
gadgets.i18n.parseNumber(gadgets.i18n.CURRENCY_PATTERN, "20 000 $", 0, "USD"); // will return 20000
</artwork>
     </figure>It gets a little bit complicated if a foreign currency written in
     the foreign way is to be parsed. In that case, predefined patterns won't
     work, and string patterns need to be used. The example below returns 0
     (indicating error in parsing), as the number presented is not in French
     format.
     <figure>
      <preamble>Example</preamble>
      <artwork xml:space="preserve">
gadgets.i18n.parseNumber(gadgets.i18n.CURRENCY_PATTERN, "$20,000"); // will return 0, indicating error
</artwork>
     </figure>To make this work, a string pattern needs to be passed in, like
     what is done below:
     <figure>
      <preamble>Example</preamble>
      <artwork xml:space="preserve">
gadgets.i18n.parseNumber("#,###", "$20,000", 0, "USD"); // will return 20000
</artwork>
     </figure></t>
    </section>
    <section title="Pattern Specification">
     <section title="Date/Time Pattern Specification">
      <t>Both Formatting and Parsing following the same pattern specification.
      The date/time pattern specifications are found in
      <eref target="http://www.unicode.org/reports/tr35/#Date_Format_Patterns">
      Unicode Locale Data Markup Language, Date Format Patterns</eref> The
      following specifiers are not required in this release:
      <list style="symbols">
       <t>w: Week of year</t>
       <t>W: Week of Month.</t>
       <t>D: Day of year.</t>
       <t>F: Day of Week in Month.</t>
       <t>g: Modified Julian day</t>
      </list></t>
     </section>
     <section title="Number Pattern Specification">
      <t>Many characters in a pattern are taken literally; they are matched
      during parsing and output unchanged during formatting. Special
      characters, on the other hand, stand for other characters, strings, or
      classes of characters. For example, the '#' character is replaced by a
      localized digit. Often the replacement character is the same as the
      pattern character; in the U.S. locale, the ',' grouping character is
      replaced by ','. However, the replacement is still happening, and if the
      symbols are modified, the grouping character changes. Some special
      characters affect the behavior of the formatter by their presence; for
      example, if the percent character is seen, then the value is multiplied
      by 100 before being displayed.</t>
      <t>To insert a special character in a pattern as a literal, that is,
      without any special meaning, the character must be quoted. There are some
      exceptions to this which are noted below.</t>
      <t>The characters listed here are used in non-localized patterns.
      Localized patterns use the corresponding characters taken from
      corresponding locale symbol collection. Two exceptions are the currency
      sign and quote, which are not localized.
      <texttable align="left">
       <ttcol>Symbol</ttcol>
       <ttcol>Location</ttcol>
       <ttcol>Localized?</ttcol>
       <ttcol>Meaning</ttcol>
       <c>0</c>
       <c>Number</c>
       <c>Yes</c>
       <c>Digit</c>
       <c>#</c>
       <c>Number</c>
       <c>Yes</c>
       <c>Digit, zero shows as absent.</c>
       <c>.</c>
       <c>Number</c>
       <c>Yes</c>
       <c>Decimal separator or monetary decimal separator.</c>
       <c>-</c>
       <c>Number</c>
       <c>Yes</c>
       <c>Minus sign</c>
       <c>,</c>
       <c>Number</c>
       <c>Yes</c>
       <c>Grouping Separator</c>
       <c>E</c>
       <c>Number</c>
       <c>Yes</c>
       <c>Separates mantizza and exponent in scientific notation. Need not be
       quoted in prefix or suffix.</c>
       <c>;</c>
       <c>Subpattern boundary</c>
       <c>Yes</c>
       <c>Separates positive and negative subpatterns.</c>
       <c>%</c>
       <c>Prefix or suffix</c>
       <c>Yes</c>
       <c>Multiply by 100 and show as percentage.</c>
       <c>\u2030</c>
       <c>Prefix or suffix</c>
       <c>Yes</c>
       <c>Multiply by 1000 and show as per mile.</c>
       <c>¤ (\u00A4)</c>
       <c>Prefix or suffix</c>
       <c>No</c>
       <c>Currency sign, replaced by currency symbol. If doubled, replaced by
       international currency symbol. If present in a pattern, the monetary
       decimal separator is used instead of the decimal separator.</c>
       <c>'</c>
       <c>Prefix or suffix</c>
       <c>No</c>
       <c>Used to quote special characters in a prefix or suffix, for example,
       "'#'#" formats 123 to "#123". To create a single quote itself, use two
       in a row: "# o''clock".</c>
      </texttable>A NumberFormat pattern contains a postive and negative
      subpattern, for example, "#,##0.00;(#,##0.00)". Each subpattern has a
      prefix, a numeric part, and a suffix. If there is no explicit negative
      subpattern, the negative subpattern is the localized minus sign prefixed
      to the positive subpattern. That is, "0.00" alone is equivalent to
      "0.00;-0.00". If there is an explicit negative subpattern, it serves only
      to specify the negative prefix and suffix; the number of digits, minimal
      digits, and other characteristics are ignored in the negative subpattern.
      That means that "#,##0.0#;(#)" has precisely the same result as
      "#,##0.0#;(#,##0.0#)".</t>
      <t>The prefixes, suffixes, and various symbols used for infinity, digits,
      thousands separators, decimal separators, etc. may be set to arbitrary
      values, and they will appear properly during formatting. However, care
      must be taken that the symbols and strings do not conflict, or parsing
      will be unreliable. For example, the decimal separator and thousands
      separator should be distinct characters, or parsing will be
      impossible.</t>
      <t>The grouping separator is a character that separates clusters of
      integer digits to make large numbers more legible. It commonly used for
      thousands, but in some locales it separates ten-thousands. The grouping
      size is the number of digits between the grouping separators, such as 3
      for "100,000,000" or 4 for "1 0000 0000".</t>
      <section title="Pattern BNF">
       <t>
       <figure>
        <artwork xml:space="preserve">
 pattern := subpattern (';' subpattern)?
subpattern := prefix? number exponent? suffix?
 number :=
(integer ('.' fraction)?) | sigDigits
 prefix :=
'\u0000'..'\uFFFD' - specialCharacters
 suffix :=
'\u0000'..'\uFFFD' - specialCharacters
 integer := '#'* '0'*
'0'
 fraction := '0'* '#'*
 sigDigits := '#'* '@'
'@'* '#'*
 exponent := 'E' '+'? '0'* '0'
 padSpec
:= '*' padChar
 padChar := '\u0000'..'\uFFFD' -
quote

 Notation:
 X* 0 or more
instances of X
 X? 0 or 1 instances of X
 X|Y
either X or Y
 C..D any character from C up to D,
inclusive
 S-T characters in S, except those in T
</artwork>
       </figure>The first subpattern is for positive numbers. The second
       (optional) subpattern is for negative numbers.</t>
      </section>
     </section>
    </section>
     <list style="hanging">
     <t hangText="CURRENCY_PATTERN"
              anchor="gadgets.i18n.CURRENCY_PATTERN">
      Pattern for currency.</t>
     <t hangText="DECIMAL_PATTERN"
              anchor="gadgets.i18n.DECIMAL_PATTERN">
      Pattern for decimal numbers.</t>
     <t hangText="FULL_DATE_FORMAT"
              anchor="gadgets.i18n.FULL_DATE_FORMAT">
      Format for full representations of dates.</t>
     <t hangText="FULL_DATETIME_FORMAT"
              anchor="gadgets.i18n.FULL_DATETIME_FORMAT">
      Format for short representations of datetimes.</t>
     <t hangText="FULL_TIME_FORMAT"
              anchor="gadgets.i18n.FULL_TIME_FORMAT">
      Format for full representations of times.</t>
     <t hangText="LONG_DATE_FORMAT"
              anchor="gadgets.i18n.LONG_DATE_FORMAT">
      Format for long representations of dates.</t>
     <t hangText="LONG_DATETIME_FORMAT"
              anchor="gadgets.i18n.LONG_DATETIME_FORMAT">
      Format for short representations of datetimes.</t>
     <t hangText="LONG_TIME_FORMAT"
              anchor="gadgets.i18n.LONG_TIME_FORMAT">
      Format for long representations of times.</t>
     <t hangText="MEDIUM_DATE_FORMAT"
              anchor="gadgets.i18n.MEDIUM_DATE_FORMAT">
      Format for medium representations of dates.</t>
     <t hangText="MEDIUM_DATETIME_FORMAT"
              anchor="gadgets.i18n.MEDIUM_DATETIME_FORMAT">
      Format for medium representations of datetimes.</t>
     <t hangText="MEDIUM_TIME_FORMAT"
              anchor="gadgets.i18n.MEDIUM_TIME_FORMAT">
      Format for medium representations of times.</t>
     <t hangText="PERCENT_PATTERN"
              anchor="gadgets.i18n.PERCENT_PATTERN">
      Pattern for percentages.</t>
     <t hangText="SCIENTIFIC_PATTERN"
              anchor="gadgets.i18n.SCIENTIFIC_PATTERN">
      Pattern for scientific numbers.</t>
     <t hangText="SHORT_DATE_FORMAT"
              anchor="gadgets.i18n.SHORT_DATE_FORMAT">
      Format for short representations of dates.</t>
     <t hangText="SHORT_DATETIME_FORMAT"
              anchor="gadgets.i18n.SHORT_DATETIME_FORMAT">
      Format for short representations of datetimes.</t>
     <t hangText="SHORT_TIME_FORMAT"
              anchor="gadgets.i18n.SHORT_TIME_FORMAT">
      Format for short representations of times.</t>
    </list>
    <section title="Method Details">
     <section title="formatDateTime"
              anchor="gadgets.i18n.formatDateTime">
      <t>&lt;static&gt; Type: {string} gadgets.i18n.formatDateTime(pattern,
      date)</t>
      <t>Description: This method formats a "Date" object with provided pattern
      specification. The pattern could be a string using ICU notation or a
      predefined pattern. A string using ICU notation offers the most
      flexibility. Each field as specified in the pattern has locale specific
      behavior. The pattern string is allowed to contain string literals, and
      one type of pattern might not work for all locales. In those case, the
      pattern itself could also be locale specific, thus not good for sharing
      among locales.
      <figure>
       <preamble>Example</preamble>
       <artwork xml:space="preserve">
date = new Date(2006, 6, 27, 13, 10, 10, 250);
assertEquals("13:10:10", gadgets.i18n.formatDateTime("HH:mm:ss", date));
</artwork>
      </figure></t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>pattern</c>
       <c>string/number</c>
       <c>String to specify patterns or Number used to reference predefined
       pattern that a date should be formatted into.</c>
       <c>date</c>
       <c>Date</c>
       <c>Date object being formatted.</c>
      </texttable></t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>string</c>
       <c>string representation of date/time.</c>
      </texttable></t>
     </section>
     <section title="formatNumber"
              anchor="gadgets.i18n.formatNumber">
      <t>&lt;static&gt; Type: {string} gadgets.i18n.formatNumber(pattern,
      value, opt_currencyCode)</t>
      <t>Description: Format number using the pattern specified. The pattern
      could be a string pattern or one of the predefined patterns. The
      formatted string is returned. If an error is encountered, zero will be
      returned.
      <figure>
       <preamble>Example</preamble>
       <artwork xml:space="preserve">
var str = gadgets.i18n.formatNumber("#,###", 1234567890);
assertEquals("1,234,567,890", str);
var str = gadgets.i18n.formatNumber(gadgets.i18n.CURRRENCY_PATTERN, 1234.569);
assertEquals("$1,234.58", str);
</artwork>
      </figure></t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>pattern</c>
       <c>string/number</c>
       <c>String to specify patterns or Number used to reference predefined
       pattern that a number should be formatted into.</c>
       <c>value</c>
       <c>number</c>
       <c>The number being formatted.</c>
       <c>opt_currencyCode</c>
       <c>string</c>
       <c>optional international currency code, it determines the currency
       code/symbol should be used in format/parse. If not given, the currency
       code for current locale will be used.</c>
      </texttable></t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>string</c>
       <c>The formatted string.</c>
      </texttable></t>
     </section>
     <section title="parseDateTime"
              anchor="gadgets.i18n.parseDateTime">
      <t>&lt;static&gt; Type: {number} gadgets.i18n.parseDateTime(pattern,
      text, start, date)</t>
      <t>Description: This method will parse the input string ("text"),
      interpretting it as specified by pattern. The parsed result will be saved
      into a Date object ("date"). "start" indicates from where in the string
      the parse should start. This method returns the number of characters
      consumed.
      <figure>
       <preamble>Example</preamble>
       <artwork xml:space="preserve">
assertTrue(gadgets.i18n.parseDateTime("yyMMdd", "991202", 0, date) &gt; 0);
assertEquals(1999, date.getFullYear());
assertTrue(date.getMonth() == 12 - 1);
assertTrue(date.getDate() == 02);
assertTrue(gadgets.i18n.parseDateTime("yyyyMMdd", "20051202", 0, date) &gt; 0);
assertEquals(2005, date.getFullYear());
assertTrue(date.getMonth() == 12 - 1);
assertTrue(date.getDate() == 02);
</artwork>
      </figure>A whole piece of string is usually the target for parsing. But
      in some cases, you might just want to parse part of the string, "start"
      parameter and return value also make it very convenient. For example,
      suppose you want to parse a string like "88/01, 99/03, 98/05, 97/02", the
      following code will do the job.
      <figure>
       <preamble>Example</preamble>
       <artwork xml:space="preserve">
var date_array = [];
var pos = 0;
var text = "88/01, 99/03, 98/05, 97/02";
while(1) {
 var date = new Date;
    var consumed = gadgets.i18n.parseDateTime("yy/MM", text, pos, date);
    if (consumed &lt;= 0) break;
    date_array.push(date);
    pos += consumed;
    if (pos &lt; text.length &amp;&amp; text[pos] == ',') ++pos;
    if (pos &lt; text.length &amp;&amp; text[pos] == ' ') ++pos;
}
</artwork>
      </figure>Similar to the formatting functions, a predefined pattern could
      also be passed in as the first parameter.
      <figure>
       <preamble>Example</preamble>
       <artwork xml:space="preserve">
//assume locale has already been set to zh_CN
var date = new Date();
gadgets.i18n.parseDateTime(gadgets.i18n.LONG_DATE_FORMAT, "2006年7月24日", 0, date);
assertEquals(date.getFullYear(), 2006);
assertEquals(date.getMonth(), 7 - 1);
assertEquals(date.getDate(), 24);
</artwork>
      </figure></t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>pattern</c>
       <c>string/number</c>
       <c>String to specify patterns or Number used to reference predefined
       pattern that a date should be parsed from.</c>
       <c>text</c>
       <c>string</c>
       <c>The string that need to be parsed.</c>
       <c>start</c>
       <c>number</c>
       <c>The character position in "text" where parse begins.</c>
       <c>date</c>
       <c>Date</c>
       <c>The date object that will hold parsed value.</c>
      </texttable></t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>number</c>
       <c>The number of characters advanced or 0 if failed.</c>
      </texttable></t>
     </section>
     <section title="parseNumber"
              anchor="gadgets.i18n.parseNumber">
      <t>&lt;static&gt; Type: {number} gadgets.i18n.parseNumber(pattern, text,
      opt_pos, opt_currencyCode)</t>
      <t>Description: Parse string to get a number the pattern specified. The
      pattern could be a string pattern or one of the predefined patterns.
      <figure>
       <preamble>Example</preamble>
       <artwork xml:space="preserve">
var value = gadgets.i18n.parseNumber("0E0", "1.2345E+4");
assertEquals(12345.0, value);
//assume locale has already been set to fr
var value = gadgets.i18n.parseNumber(gadgets.i18n.CURRENCY_PATTERN, "0,30 €");
assertEquals(0.30, value);
</artwork>
      </figure></t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>pattern</c>
       <c>string/number</c>
       <c>String to specify patterns or Number used to reference predefined
       pattern that a number should be parsed from.</c>
       <c>text</c>
       <c>string</c>
       <c>input text being parsed.</c>
       <c>opt_pos</c>
       <c>Array</c>
       <c>optional one element array that holds position information. It tells
       from where parse should begin. Upon return, it holds parse stop
       position.</c>
       <c>opt_currencyCode</c>
       <c>string</c>
       <c>optional international currency code, it determines the currency
       code/symbol should be used in format/parse. If not given, the currency
       code for current locale will be used.</c>
      </texttable></t>
      <t>Returns:
      <texttable align="left">
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>number</c>
       <c>Parsed number, 0 if in error.</c>
      </texttable></t>
     </section>
    </section>
   </section>
   <section title="OpenSearch" anchor="OpenSearch">
     <xref target="Issue-1166">Discussion</xref>
     <t>
          The OpenSearch feature in OpenSocial allows gadgets to declare
          that they have searchable material by providing an
          <eref target="http://www.opensearch.org/Specifications/OpenSearch/1.1">OpenSearch 1.1</eref>
          description in their gadget definition. The OpenSeach
          description is passed as a parameter to the OpenSearch feature.
          Gadget developers may choose to embed the OpenSearch
          descriptior right in the gadget definition itself, or they may
          reference an OpenSearch description hosted on a server by using
          it's URL.
          Gadget developers SHOULD make the OpenSearch feature optional
          in thier gadget defintions to allow for ineroperability in all
          containers.
       </t>
     <section title="Data Model">
       <t>
          The OpenSearch description can be declared in two ways,
          first by embedding it in the gadget definition itself, or
          secondly by providing a URL to the description document.
          To do this gadget developers should provide a feature
          parameter to the OpenSearch feature. The parameter names
          can be one of the following.
          <texttable align="left">
            <ttcol>Parameter Name</ttcol>
            <ttcol>Description</ttcol>
            <c>description</c>
            <c>
              XML for the full OpenSearch 1.1 description as
              described on the OpenSearch site.
            </c>
            <c>url</c>
            <c>
              A URL to the OpenSearch 1.1 description document.
            </c>
          </texttable>
         </t>
         <section title="description">
          <t>
            The description parameter contains the full XML of the
            <eref target="http://www.opensearch.org/Specifications/OpenSearch/1.1#OpenSearch_description_document">OpenSearch 1.1 description</eref>,
            as described in the OpenSearch Specification.
            The description contains the template url for fetching results, the
            type of results returned, the title of the search contribution, and
            other information. Please see the link above for more details.
          </t>
         </section>
         <section title="url">
          <t>
            The url parameter points to an XML document that contains the full
            <eref target="http://www.opensearch.org/Specifications/OpenSearch/1.1#OpenSearch_description_document">OpenSearch 1.1 description</eref>.
          </t>
         </section>
         <section title="Sample Gadgets">
          <section title="Embedded OpenSearch Description">
            <figure>
              <artwork xml:space="preserve">
&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
&lt;Module&gt;
  &lt;ModulePrefs title="OpenSearch Example"&gt;
    &lt;Optional feature="opensearch"&gt;
      &lt;Param name="description"&gt;
        &lt;![CDATA[
          &lt;OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"&gt;
            &lt;ShortName&gt;Example Search&lt;/ShortName&gt;
            &lt;Description&gt;Realtime Example Search&lt;/Description&gt;
            &lt;Url type="application/atom+xml" method="get" template="http://search.example.com/search.atom?q={searchTerms}"/&gt;
            &lt;Image width="16" height="16"&gt;http://search.example.com/favicon.png&lt;/Image&gt;
            &lt;InputEncoding&gt;UTF-8&lt;/InputEncoding&gt;
            &lt;SearchForm&gt;http://search.example.com/&lt;/SearchForm&gt;
          &lt;/OpenSearchDescription&gt;
        ]]&gt;
      &lt;/Param&gt;
    &lt;/Optional&gt;
  &lt;/ModulePrefs&gt;
  &lt;Content type="url" href="http://example.com/searchGadget.xml" /&gt;
&lt;/Module&gt;
              </artwork>
            </figure>
          </section>
          <section title="Referenced OpenSearch Description">
            <figure>
              <artwork xml:space="preserve">
&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
&lt;Module&gt;
  &lt;ModulePrefs title="OpenSearch Example"&gt;
    &lt;Optional feature="opensearch"&gt;
      &lt;Param name="url"&gt;http://search.example.com/openSearchDescription.xml&lt;/Param&gt;
    &lt;/Optional&gt;
  &lt;/ModulePrefs&gt;
  &lt;Content type="url" href="http://example.com/searchGadget.xml" /&gt;
&lt;/Module&gt;
              </artwork>
            </figure>
          </section>
        </section>
      </section>
  </section>
   <section title="Embedded Experiences" anchor="Embedded-Experiences">
  <xref target="Issue-1144">Discussion</xref>
    <t>Embedded experiences provide a mechanism for embedding OpenSocial
    gadgets and other web-accessible content sources directly into a 
    variety of contexts such as Activity Streams, email messages and Atom feeds.
    The mechanism works by inserting a small structure of data that includes
    a reference to the embedded content along with contextual data an OpenSocial
    container would need to render the content appropriately.</t>
    
    <t>This data structure can be serialized as either a JSON object or XML and
    includes the following properties:</t>
    
    <texttable>
      <ttcol align="left" width="15%">Property</ttcol>
      <ttcol align="left">Description</ttcol>
      
      <c><spanx style="verb">context</spanx></c>
      <c>If the Embedded Experience is used to embed an OpenSocial gadget,
      the "context" field is used to pass data to the gadget so that it 
      knows exactly which content to render. For instance, a gadget that 
      displays a person's profile information will need to know which 
      profile to display; a gadget that displays an album of recent photos
      will need to know the identity of the album to display. The content
      of the "context" field is undefined and specific to each individual 
      gadget definition with one exception: the special property name 
      "opensocial" is reserved for use by the container implementation.
      The "context" properties JSON object value or XML element structure 
      MUST NOT contain a property named "opensocial".</c>

      <c><spanx style="verb">gadget</spanx></c>
      <c>A URL to an OpenSocial Gadget definition document that defines the 
      gadget to be embedded.</c>
      
      <c><spanx style="verb">preferredExperience</spanx></c>
      <c>An optional collection of properties that describe the preferred 
      way the creator of the embedded experience would like containers to
      render the content.</c>
      
      <c><spanx style="verb">previewImage</spanx></c>
      <c><x:incubating href="http://code.google.com/p/opensocial-resources/issues/detail?id=1316" note="Issue 1316 - Remove the previewImageData for EE data model and add support for data URI">An optional URI to an image that can be used as a preview for the 
      embedded content. This property accepts URL data scheme 
      (http://tools.ietf.org/html/rfc2397) to specify the image as Base64-encoded 
      embedded data.</x:incubating></c>
      
      <c><spanx style="verb">url</spanx></c>
      <c>A URL to a web page that allows virtually any web-accessible 
      resource to be used as an Embedded Experience.</c>
            
    </texttable>
    
    <t>The "url" and "gadget" properties each reference content that is to 
    be embedded. At least one of these properties MUST be specified.
    When both properties are used within the Embedded Experience, the decision about which 
    to render is left to the container.</t>
    
    <t>When serialized as JSON, the embedded experience take the form of a 
    single JSON Object with four distinct properties: "context", "gadget", 
    "previewImage" and "url". Additional extension properties MAY be included
    in the JSON object.</t>
    
    <figure><preamble>For instance, a simple JSON Embedded Experience
    that references an OpenSocial gadget:</preamble>
    <artwork>
  {
    "gadget" : "http://www.example.com/embedded/gadget.xml",
    "context" : {
      "title" : "Hello World",
      "id" : 123
    },
    "previewImage" : "http://www.example.com/embedded/123.png"
  }
    </artwork></figure>
    
    <t>When serialized as XML, it is expressed in the form of a root element 
    &lt;embed&gt; containing four child elements, the order of which is 
    considered insignificant: &lt;context&gt;, 
    &lt;gadget&gt;, &lt;previewImage&gt;, and &lt;url&gt;. Additional extension
    elements and attributes MAY be included in the XML object.</t>
    
    <figure><preamble>For example,</preamble>
    <artwork><![CDATA[
  <embed>
    <gadget>http://www.example.com/embedded/gadget.xml</gadget>
    <context>
      <title>Hello World</title>
      <id>123</id>
    </context>
    <previewImage>http://www.example.com/embedded/123.png</previewImage>
  </embed>
    ]]></artwork></figure>
    
    <t>Note that no XML namespace is currently declared for the XML
    serialization. This means that special care must be taken when 
    including an XML embedded experience into another type of XML 
    document. For example, the following shows an XML embedded experience
    within a partial Atom Entry Document. Note the addition of
    <spanx style="verb">xmlns=""</spanx> on the embed element in order
    to "undeclare" the in-scope default XML namespace.</t>
    
    <figure><artwork><![CDATA[
  <entry xmlns="http://www.w3.org/2005/Atom">
    <id>http://example.org/entries/1</id>
    ...
    <embed xmlns="">
      <gadget>http://www.example.com/embedded/gadget.xml</gadget>
      <context>
        <title>Hello World</title>
        <id>123</id>
      </context>
      <previewImage>http://www.example.com/embedded/123.png</previewImage>
    </embed>
  </entry>
    ]]></artwork></figure>
    
    <section title="Additional Examples">
    
      <figure><preamble>A simple URL embedded experience using the JSON 
      serialization:</preamble><artwork>
  {
    "url" : "http://www.example.org/embed/123.html"
  }
      </artwork></figure>
      
      <figure><preamble>The same URL embedded experience using the XML
      serialization:</preamble><artwork><![CDATA[
  <embed>
    <url>http://www.example.org/embed/123.html</url>
  </embed>
      ]]></artwork></figure>
    
      <figure><preamble>An embedded experience that specifies both a gadget 
      and URL serialized as JSON:</preamble><artwork>
  {
    "gadget" : "http://www.example.com/embedded/gadget.xml",
    "url" : "http://www.example.org/embed/123.html",
    "context" : {
      "title" : "Hello World",
      "id" : 123
    },
    "previewImage" : "http://www.example.com/embedded/123.png"
  }
      </artwork></figure>
      
    <figure><preamble>The same embedded experience serialized as XML:</preamble>
    <artwork><![CDATA[
  <embed>
    <gadget>http://www.example.com/embedded/gadget.xml</gadget>
    <url>http://www.example.org/embed/123.html</url>
    <context>
      <title>Hello World</title>
      <id>123</id>
    </context>
    <previewImage>http://www.example.com/embedded/123.png</previewImage>
  </embed>
    ]]></artwork></figure>
    
    </section>
    
    <section title="Considerations for Embedded Experience Gadgets">
      <section title="Views For Embedded Experiences">
      <x:incubating href="http://code.google.com/p/opensocial-resources/issues/detail?id=1284" note="Issue 1284:  Preferred Experiences and other refinements to Embedded Experiences">
        <t>When rendering a gadget as an embedded experience, the container
        will look within the embedded experience data model and see if there 
        is a <xref target="preferredExperience">"preferred experience"</xref> 
        object containing a "target" property.  If the 
        <xref target="eeTargetTypes">target object</xref> type is equal to 
        "gadget" and there is a view property specified, the container will 
        try and render the value of the "view" property.  If there is no "view" 
        property in the target object or there is no target object, or if 
        there is no preferred experience in the data model, the container will 
        render a view called "embedded".  If an "embedded" view or the view 
        specified within the target object of the embedded experience data 
        model is not found within the gadget definition, the container SHOULD 
        render the gadget's default view.</t>
        </x:incubating>
      </section>
      
      <section title="Accessing The Context">
        <t>An embedded experience gadget has the option of requiring some
        contextual information in order to render itself.  By abstracting the
        data from the gadget itself, gadget developers can develop
        generalized gadgets that can be used for all embedded expereinces of a
        specific type.  For example, a gadget developed to display videos can 
        be built so that the id of the video is contained and extracted from
        the embedded experience's "context" property.</t>
        
        <figure><artwork>
  {
    "gadget" : "http://example.org/embedded/video.xml",
    "context" : {
      "video-id" : "abc123"
    }
  }
        </artwork></figure>

        <t>Gadgets that are written to support embedded experiences MUST require 
        the "embedded-experiences" feature within their gadget definition in 
        order to access the context.  The contextual data is stored within the 
        <xref target="DataContext">data context</xref> object for the gadget.  
        The key, "org.opensocial.ee.context", is used to access the context.
        Gadgets can add a listener on the data context object for this key, or
        it may retreive the key's value by using the data context APIs.</t>
        
        <figure><preamble>For instance, the Gadget below registers a listener
        with the data context to retrieve any context data included with the 
        embedded experience:</preamble>
          <artwork xml:space="preserve">
  &lt;Module&gt;
    &lt;ModulePrefs title="Embedded Experiences Test" description="Tests the embedded experiences APIs."&gt;
      &lt;Require feature="embedded-experiences"&gt;&lt;/Require&gt;
    &lt;/ModulePrefs&gt;
    &lt;Content type="html" view="embedded"&gt;
        &lt;![CDATA[
          &lt;script type="text/javascript"&gt;
            function myCallback(key) {
              var context = opensocial.data.getDataContext().getDataSet(key);
              document.getElementById('contextData').innerHTML = gadgets.json.stringify(context);
            }
            function initData() {
              opensocial.data.getDataContext().registerListener(
                'org.opensocial.ee.context', myCallback);
            }
            gadgets.util.registerOnLoadHandler(initData);
        &lt;/script&gt;
         &lt;div id="contextData"&gt;&lt;/div&gt;
    ]]&gt;
    &lt;/Content&gt;
  &lt;/Module&gt;</artwork>
        </figure>
        
        <figure><preamble>Instead of using the data context APIs to get the embedded experiences
        context you may choose to use the <xref target="gadgets.ee.registerContextListener">
        gadgets.ee.registerContextListener</xref> API in order to lessen the amount of code you 
        need to write.  The above gadget example can be rewriten to use the 
        registerContextListener API:</preamble>
          <artwork xml:space="preserve">
  &lt;Module&gt;
    &lt;ModulePrefs title="Embedded Experiences Test" description="Tests the embedded experiences APIs."&gt;
      &lt;Require feature="embedded-experiences"&gt;&lt;/Require&gt;
    &lt;/ModulePrefs&gt;
    &lt;Content type="html" view="embedded"&gt;
        &lt;![CDATA[
          &lt;script type="text/javascript"&gt;
            gadgets.util.registerOnLoadHandler(function() {
              gadgets.ee.registerContextListener(function(context) {
                document.getElementById('contextData').innerHTML = gadgets.json.stringify(context);
              });
            });
        &lt;/script&gt;
         &lt;div id="contextData"&gt;&lt;/div&gt;
    ]]&gt;
    &lt;/Content&gt;
  &lt;/Module&gt;</artwork>
        </figure>
        <xref target="Issue-1249">Discussion</xref>
        
        <section title="Additional Container Specific Context" anchor="rootContext">
		<x:incubating href="http://code.google.com/p/opensocial-resources/issues/detail?id=1284" note="Issue 1284:  Preferred Experiences and other refinements to Embedded Experiences">  
          <t>While the contextual data associated with the 
          "org.opensocial.ee.context" key will generally originate 
          from the information provided by the "context" property
          within the Embedded Experience document, containers are 
          free to insert additional, container specific contexual 
          data into the object. For example, a container might wish to 
          communicate information about the type of parent object 
          within which the Embedded Experience information was 
          received.  If the "context" property of the embedded
          experience document is not an object than containers
          SHOULD NOT add any additional information to the "context"
          property.</t>
          
          <t>If such additional information is provided, the object 
          associated with the "org.opensocial.ee.context" key MUST have an
          additional "openSocial" property.</t>
          
          <t>Containers MAY use the "openSocial" property to communicate
          additional information about the object containing the embedded
          experience being rendered.  This information should be added to
          the "associatedContext" property and MUST contain the following
          properties:</t>
          
          <texttable>
            <ttcol align="left" width="15%">Property</ttcol>
            <ttcol align="left">Description</ttcol>
            <c><spanx style="verb">id</spanx></c>
            <c>The id of the <eref target="Social-Data.xml">OpenSocial Data object</eref> 
            containing the embedded experience.  The type of id will depend on the 
            type of OpenSocial Data object containing the embedded experience.</c>
            <c><spanx style="verb">type</spanx></c>
            <c>The type of OpenSocial Data object containing the embedded
            experience.</c>
          </texttable>
          
          <figure><preamble>The following is an example of what the 
          embedded experience data model looks like if the container adds
          the required fields of the "associatedContext" object.</preamble><artwork>
  {
    "gadget" : "http://example.org/AlbumViewer.xml",
    "context" : {
      "albumName": "Germany 2009",
      "photoUrls": [
        "http://examplephotos.com/3495/3925132517_5959dac775_t.jpg",
        "http://examplephotos.com/3629/3394799776_47676abb46_t.jpg",
        "http://examplephotos.com/4009/4413640211_715d924d9b_t.jpg",
        "http://examplephotos.com/2340/3528537244_d2fb037aba_t.jpg",
        "http://examplephotos.com/36/98407782_9c4c5866d1_t.jpg",
        "http://examplephotos.com/48/180544479_bb0d0f6559_t.jpg",
        "http://examplephotos.com/2668/3858018351_1e7b73c0b7_t.jpg"
      ],
      "openSocial" : {
        "associatedContext" : {
          "id" : "container.com:123abc",
          "type" : "opensocial.ActivityEntry"
        }
      }
    }
  }
          </artwork></figure>
          
          <t>Note: As stated above, everything inside the "openSocial" property 
          of the above example was added by the container.</t>
          
          <t>In addition to the "id" and the "type" properties, containers MAY add 
          an additional property to the associated context called "objectReference".
          If present, the "objectReference" property will contain the JSON representation 
          of the OpenSocial Data object containing the embedded experience.</t>
          
          <texttable>
            <ttcol align="left" width="15%">Property</ttcol>
            <ttcol align="left">Description</ttcol>
            <c><spanx style="verb">objectReference</spanx></c>
            <c>The JSON representation of the OpenSocial Data object 
            containing the embedded experience.  This OpenSocial Data object
            MUST contain the complete embedded experience data model.</c>
          </texttable>
          
          <figure><preamble>The following is an example of what the 
          embedded experience data model would look like if the container added
          the required and optional fields of the "associatedContext" 
          object.</preamble><artwork>
  {
    "gadget" : "http://example.org/AlbumViewer.xml",
    "context" : {
      "albumName": "Germany 2009",
      "photoUrls": [
        "http://examplephotos.com/3495/3925132517_5959dac775_t.jpg",
        "http://examplephotos.com/3629/3394799776_47676abb46_t.jpg",
        "http://examplephotos.com/4009/4413640211_715d924d9b_t.jpg",
        "http://examplephotos.com/2340/3528537244_d2fb037aba_t.jpg",
        "http://examplephotos.com/36/98407782_9c4c5866d1_t.jpg",
        "http://examplephotos.com/48/180544479_bb0d0f6559_t.jpg",
        "http://examplephotos.com/2668/3858018351_1e7b73c0b7_t.jpg"
      ],
      "openSocial" : {
        "associatedContext" : {
          "id" : "container.com:123abc",
          "type" : "opensocial.ActivityEntry",
          "objectReference" : {
            "postedTime": "2011-02-10T15:04:55Z",
            "actor": {
              "objectType" : "person",
              "id": "tag:example.org,2011:martin",
              "displayName": "Martin Smith"
            },
            "verb": "post",
            "object" : {
              "objectType":"collection",
              "objectTypes":["image"]
              "id": "http://example.org/albums/germany-2009",
              "url": "http://example.org/albums/germany-2009",
            },
            "openSocial" : {
              "embed" : {
                "gadget" : "http://example.org/AlbumViewer.xml",
                "context" : {
                  "albumName": "Germany 2009",
                  "photoUrls": [
                    "http://examplephotos.com/3495/3925132517_5959dac775_t.jpg",
                    "http://examplephotos.com/3629/3394799776_47676abb46_t.jpg",
                    "http://examplephotos.com/4009/4413640211_715d924d9b_t.jpg",
                    "http://examplephotos.com/2340/3528537244_d2fb037aba_t.jpg",
                    "http://examplephotos.com/36/98407782_9c4c5866d1_t.jpg",
                    "http://examplephotos.com/48/180544479_bb0d0f6559_t.jpg",
                    "http://examplephotos.com/2668/3858018351_1e7b73c0b7_t.jpg"
                  ]
                }
              }
            }
          }
        }
      }
    }
  }
          </artwork></figure>
          
          <figure><preamble>The following example illustrates how this 
          additional context information is accessed:</preamble><artwork>
  function myCallback(key) {
    var context = opensocial.data.getDataContext().getDataSet(key);
    var video_id = context['albumName'];
    
    var associatedContext = context.openSocial.associatedContext;
    var ac_id = associatedContext.id;
    var ac_type = associatedContext.type;
    
    //The container MAY also add an object reference
    var obj_ref = associatedContext.objectReference
    if(typeof obj_ref !== 'undefined') {
      //Do something with the object reference
    }
    // ...
  }
  function initData() {
    opensocial.data.getDataContext().registerListener(
      'org.opensocial.ee.context', myCallback);
  }
  gadgets.util.registerOnLoadHandler(initData);
          </artwork></figure>
          
          <t>Specific container implementations are free to insert any additional
          information they wish into the and "openSocial" object values. The 
          interpretation and use of any such information is
          considered out of the scope of this specification.</t>
        </x:incubating>
        </section>
      </section>  
  </section>
  <section title="Preferred Experiences" anchor="preferredExperience">
  <x:incubating href="http://code.google.com/p/opensocial-resources/issues/detail?id=1284" note="Issue 1284:  Preferred Experiences and other refinements to Embedded Experiences">
    <t>While the container retains control over deciding exactly how an
    embedded experience is processed and rendered, there are situations 
    where the creator of the embedded experience might wish to provide 
    clues to the container as to how it would prefer the content to be
    displayed. These clues are included within the Embedded Experience
    using the "preferredExperience" property.</t>
    
    <figure><preamble>The following illustrates a basic example 
    serialized as JSON:</preamble>
    <artwork>
  {
    "gadget" : "http://www.example.com/embedded/gadget.xml",
    "url" : "http://www.example.com/foo/bar.html",
    "context" : {
      "title" : "Hello World",
      "id" : 123
    },
    "previewImage" : "http://www.example.com/embedded/123.png",
    "preferredExperience" : {
      "target" : {
        "type" : "gadget",
        "view" : "my-ee-view"
      },
      "display" : {
        "type" : "text"
      }
  }
    </artwork></figure>
    
    <figure><preamble>And the same example using the alternative 
    XML serialization:</preamble>
    <artwork><![CDATA[
  <embed>
    <gadget>http://www.example.com/embedded/gadget.xml</gadget>
    <url>http://www.example.com/foo/bar.html</url>
    <context>
      <title>Hello World</title>
      <id>123</id>
    </context>
    <previewImage>http://www.example.com/embedded/123.png</previewImage>
    <preferredExperience>
      <target>
        <type>gadget</type>
        <view>my-ee-view</view>
      </target>
      <display>
        <type>text</type>
      </display>
    </preferredExperience>
  </embed>
    ]]></artwork></figure>

    <t>In this example, we have an embedded experience serialized as JSON.
    The structure defines both a "url" and a "gadget" property, both of 
    which can be used by the container to display embedded content. Typically,
    the decision of which to display when the embedded experience is rendered
    is up to the container. The "preferredExperience.target" property allows the 
    creator of the embedded experience to indicate that it would prefer the
    container to use the "gadget" property for rendering, and specifically that
    the "my-ee-view" view within that gadget be used. The "preferredExperience.display"
    property indicates that rather than simply displaying the gadget automatically,
    the embedded experience's creator would rather the container initially display a 
    hyperlink that, when clicked, causes the gadget to be displayed.</t>
    
    <texttable>
      <ttcol align="left" width="15%">Property</ttcol>
      <ttcol align="left">Description</ttcol>
      <c><spanx style="verb">display</spanx></c>
      <c>Describes preferences for how the embedded experience should 
      initially be displayed by the container. The "display" property provides 
      the preferred style to container on how it should render the hyperlink to open the 
      embedded experience. The value of the "display" property is an object that  
      contains a required "type" property, the value of which determines 
      what other properties might appear within the object.</c>
      <c><spanx style="verb">target</spanx></c>
      <c>Describes preferences for which type of embedded experience 
      the container should render. For instance, if the embed includes
      both a "url" and "gadget" property, the "target" is used to specify
      which is preferred. The value of the "target" property is an 
      object that contains a required "type" property, the value of which
      determines what other properties might appear within the object.</c>
    </texttable>

    <section title="Display Types">

      <t>This specification currently defines two possible values for the 
      required "type" property on the display object: "text", "image".
      Each of which are illustrated below.</t>
      <x:incubating note="Issue 1314 - Add icon optional property to the preferred experience display of type text" href="http://code.google.com/p/opensocial-resources/issues/detail?id=1314">
      <figure><preamble>Display using a hyperlink:</preamble><artwork>
  {
    "gadget" : "...",
    ...,
    "preferredExperience" : {
      "target": {...},
      "display": {
        "type" : "text",
        "label" : "Click on me!",
        "title" : "Click on this link!"
        "icon" : "http://mycontainer.com/app/openissue.jpg"
      }
    }
  }
      </artwork></figure>
      
      <t>When "type" equals "text", the additional properties on the 
      display object are:</t>
      
      <texttable>
        <ttcol align="left" width="15%">Property</ttcol>
        <ttcol align="left">Description</ttcol>
        <c><spanx style="verb">label</spanx></c>
        <c>A required String that provides the text to display with the hyperlink.</c>
        <c><spanx style="verb">title</spanx></c>
        <c>Optional text to display as the "popup help" or "tooltip" of 
        the hyperlink.</c>
        <c>icon</c>
        <c>
	The developer MAY provide a URL to an icon that can be used to
	decorate
	the text.
	For example, an issue management application may provide
	different
	icons for open issues than for those that are closed. Because
	it is expected that embedded experiences flow between containers, the
	URL MUST be absolute. Developers providing embedded experiences SHOULD
	ensure that the URL is able to be resolved by any container that will
	encounter the embedded experience. The container
	makes no assumptions
	about the size of the icon and MAY resize it to a
	size appropriate for
	the display needs. Use of the icon is optional.
	Depending on how the
	text is displayed, the container is not
	required to
	display the icon. The
	container MAY choose to display the icon in a
	manner appropriate to the
	current rendering of the object that contains
	the embedded experience.
	For example, it would be acceptable for the
	container to display the
	link in front of the text, or as a tool tip. </c>
      </texttable>
      </x:incubating>
      <figure><preamble>Display using the previewImage:</preamble><artwork>
  {
    "gadget" : "...",
    ...,
    "previewImage" : "http://example.org/preview.png",
    "preferredExperience" : {
      "target": {...},
      "display": {
        "type" : "image",
        "altText" : "The alt text",
        "width" : 100,
        "height" : 100
      }
    }
  } 
      </artwork></figure>
      <x:incubating href="http://code.google.com/p/opensocial-resources/issues/detail?id=1316" note="Issue 1316 - Remove the previewImageData for EE data model and add support for data URI">
      <figure><preamble>Display using Base64-encoded binary data in the URL data scheme:</preamble><artwork>
  {
    "gadget" : "...",
    ...,
    "previewImage" : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIA...",
    "preferredExperience" : {
      "target": {...},
      "display": {
        "type" : "image",
        "altText" : "The alt text",
        "width" : 100,
        "height" : 100
      }
    }
  } 
      </artwork></figure>
      </x:incubating>
      <t>When "type" equals "image", the additional properties on the 
      display object are:</t>
      
      <texttable>
        <ttcol align="left" width="15%">Property</ttcol>
        <ttcol align="left">Description</ttcol>
        <c><spanx style="verb">altText</spanx></c>
        <c>Specifies optional, alternative text to display if the image cannot 
        be displayed. Equivalent to the HTML image tags alt attribute.</c>
        <c><spanx style="verb">height</spanx></c>
        <c>Specifies the preferred display height of the image in pixels.</c>
        <c><spanx style="verb">width</spanx></c>
        <c>Specifies the preferred display width of the image in pixels.</c>
      </texttable>
     
      <t>Implementations are free to define additional display types, 
      each with their own properties. If a container encounters an 
      embedded experience that uses an unknown or unsupported display 
      type, the container MUST ignore the display preferences.</t>

    </section>    
    
    <section title="Target Types" anchor="eeTargetTypes">
    
      <t>This specification currently defines two possible values for the 
      type property on the target object: "gadget" and "url". Each of which 
      are illustrated below.</t>
    
      <figure><preamble>Preferring the gadget target:</preamble><artwork>
  {
    "gadget" : "...",
    "url" : "...",
    ...,
    "preferredExperience" : {
      "target": {
        "type" : "gadget",
        "view" : "my-ee-view"
      },
      "display": {
        ...
      }
    }
  }
      </artwork></figure>
      
      <t>Note that the preferred experience target's "type" property is only 
      required if the preferred target is not obvious within the embedded 
      experience. For instance, if the embedded experience only defines an 
      IRI value for the "gadget" property, then the preferred target type
      is "gadget". However, if both the "url" and "gadget" properties are
      specified, as in the example above, the target type in the preferred
      experience MUST be specified. Containers MUST ignore the preferred 
      experience if the target type value does not match the options specified
      within the Embedded Experience (e.g. target type specifies "url" but 
      only a "gadget" IRI is provided, etc).</t>
      
      <t>When "type" equals "gadget", the additional properties on the 
      target object are:</t>
      
      <texttable>
        <ttcol align="left" width="15%">Property</ttcol>
        <ttcol align="left">Description</ttcol>
        <c><spanx style="verb">view</spanx></c>
        <c>The preferred gadget view to render. If not specified, the value "embedded" is assumed.</c>
        <c><spanx style="verb">viewTarget</spanx></c>
        <c>Specifies where the container SHOULD render the view. Possible 
        values are "TAB", "DIALOG", "MODALDIALOG", "FLOAT", and "SIDEBAR".</c>
      </texttable>
      
      <figure><preamble>Preferring the url target:</preamble><artwork>
  {
    "gadget" : "...",
    "url" : "...",
    ...,
    "preferredExperience" : {
      "target": {
        "type" : "url",
        "viewTarget" : "_new"
      },
      "display": {
        ...
      }
    }
  }
      </artwork></figure>
      
      <t>When "type" equals "url", the additional properties on the 
      target object are:</t>
      
      <texttable>
        <ttcol align="left" width="15%">Property</ttcol>
        <ttcol align="left">Description</ttcol>
        <c><spanx style="verb">viewTarget</spanx></c>
        <c>When specifying a URL, rather than being forced to render in an 
        embedded view, the developer may wish to indicate to the container 
        that the page be opened in a new browser window. In this case, the 
        target properties for a URL match those that are defined by the 
        HTML spec, e.g. "_blank".</c>
      </texttable>
    
      <t>Implementations are free to define additional target types, 
      each with their own properties. If a container encounters an 
      embedded experience that uses an unknown or unsupported target 
      type, the container MUST ignore the target preferences.</t>
    
    </section>
  </x:incubating>	
  </section>
  
  
  <section title="Security">
    <t>Embedded experiences allow content to be rendered on the page that
    user has not necessarily requested, therefore it needs to be secured.
    The container SHOULD only ever render content that the user has
    previously approved.  This specification does not dictate how
    secure rendering of embedded experiences is to be performed.</t>
  </section>
  <section title="Embedded Experiences within Activity Streams">
  
    <t>Embedded experiences can be used within an Activity Streams 
    document in order to provide a more interactive experience. Whereas
    the core properties of the Activity provide a textual description of
    the event, an included embedded experience can provide a direct representation
    of the object involved.</t>
  
    <figure><preamble>For instance, if a user uploads a collection of photos
    and creates a new photo album, an embedded experience can be used within 
    the activity to provide a representation of the album itself:</preamble>
          <artwork xml:space="preserve">
  {
    "postedTime": "2011-02-10T15:04:55Z",
    "actor": {
      "objectType" : "person",
      "id": "tag:example.org,2011:martin",
      "displayName": "Martin Smith"
    },
    "verb": "post",
    "object" : {
      "objectType":"collection",
      "objectTypes":["image"]
      "id": "http://example.org/albums/germany-2009",
      "url": "http://example.org/albums/germany-2009",
    },
    "openSocial" : {
      "embed" : {
        "gadget" : "http://example.org/AlbumViewer.xml",
        "context" : {
          "albumName": "Germany 2009",
          "photoUrls": [
            "http://examplephotos.com/3495/3925132517_5959dac775_t.jpg",
            "http://examplephotos.com/3629/3394799776_47676abb46_t.jpg",
            "http://examplephotos.com/4009/4413640211_715d924d9b_t.jpg",
            "http://examplephotos.com/2340/3528537244_d2fb037aba_t.jpg",
            "http://examplephotos.com/36/98407782_9c4c5866d1_t.jpg",
            "http://examplephotos.com/48/180544479_bb0d0f6559_t.jpg",
            "http://examplephotos.com/2668/3858018351_1e7b73c0b7_t.jpg"
          ]
        }
      }
    }
  }</artwork></figure>
  
    <t>As illustrated in the example, when included within an activity, 
    the embedded experience MUST appear as the value of the "embed" property 
    as a child of the "openSocial" property.</t>
  
  </section>
  
  <section title="Embedded Experiences within Email">

    <t>Numerous services send email notifications to your inbox in
    order to let you know something took place that you may be
    interested in.  Most of the time however these notifications do not
    provide much useful information beyond a link back to the service's 
    website.  By leveraging embedded experiences, services can send an
    embedded representation of the object the notification is about, and
    allow the user to take action on the notification directly from within 
    an embedded experiences enabled email client.</t>

    <t>Embedded experiences serialized as either JSON or XML can be embedded 
    Multipart MIME encoded email messages. Such email messages MUST utilize 
    the "multipart/alternative" MIME variant and MUST contain at least two
    MIME parts -- one containing regular content of the email message encoded
    as text/html content, and another containing the embedded experience content 
    using either the "application/embed+json" or "application/embed+xml" MIME media type, 
    respectively representing the JSON and XML serializations. Additional
    MIME parts MAY be included </t>

    <figure>
      <preamble>For instance,</preamble>
      <artwork xml:space="preserve">
  From: notifications@socialnetwork.com
  To: johndoe@example.com
  Subject: Social Network: Mary Has Commented On Your Status
  MIME-Version: 1.0
  Content-Type: multipart/alternative;
          boundary="XXXXboundary text"

  Mary has commented on your status.
  
  --XXXXboundary text
  Content-Type: text/plain
  
  Mary has commeneted on your status. 
  
  --XXXXboundary text
  Content-Type: text/html

  &lt;html&gt;
  &lt;!-- HTML representation here --&gt;
  &lt;/html&gt;

  --XXXXboundary text
  Content-Type: application/embed+json
  {
    "gadget" : "http://www.socialnetwork.com/embedded/commentgadget.xml",
    "context" : 123
  }</artwork>
    </figure>
    
  </section>
  <section title="Method Details" anchor="methoddetails">
    <section title="registerContextListener" anchor="gadgets.ee.registerContextListener">
    
      <t>&lt;static&gt; gadgets.registerContextListener(listener)</t>
      <t>Description: Registers a function which will be called when the 
      embedded experience gadget recieves its context.</t>
      <t>Parameters:
      <texttable align="left">
       <ttcol>Name</ttcol>
       <ttcol>Type</ttcol>
       <ttcol>Description</ttcol>
       <c>listener</c>
       <c>Function</c>
       <c>A function that will be called whenever the embedded experience context is 
       set for this gadget.  The function should take one parameter which is a JSON 
       object representing the embedded experience context from the gadget.  See the 
       embedded experiences 
       <xref target="Embedded-Experiences">data model description</xref> for more 
       information on the context object.</c>
      </texttable></t>
      
      <t>Example:</t>
      <figure>
      <artwork xml:space="preserve">
         &lt;script type="text/javascript"&gt;
            gadgets.util.registerOnLoadHandler(function() {
              gadgets.ee.registerContextListener(function(context) {
                document.getElementById('contextData').innerHTML = gadgets.json.stringify(context);
              });
            });
         &lt;/script&gt;
       </artwork>
       </figure>
       <xref target="Issue-1249">Discussion</xref>
      
    </section>
  </section>
  </section> <!-- End embedded experience section -->
  </section>

  <references title="Discussion">
  <!-- Spec change issues/discussion -->
   <reference anchor='Issue-1133'
              target="http://code.google.com/p/opensocial-resources/issues/detail?id=1133">
    <front>
     <title>Proposal for View Level Features in OS 2.0</title>
    </front>
   </reference>
   <reference anchor='Issue-1142'
              target="http://code.google.com/p/opensocial-resources/issues/detail?id=1142">
    <front>
     <title>Propose fix for the 1.1 XSD schema in the core server spec</title>
    </front>
   </reference>
   <reference anchor='Issue-1139'
              target="http://code.google.com/p/opensocial-resources/issues/detail?id=1139">
    <front>
     <title>Removing Quirks Mode</title>
    </front>
   </reference>
   <reference anchor='Issue-1173'
              target="http://code.google.com/p/opensocial-resources/issues/detail?id=1173">
    <front>
     <title>Signing of URL Content requests</title>
    </front>
   </reference>
   <reference anchor='Issue-1162'
              target="http://code.google.com/p/opensocial-resources/issues/detail?id=1162">
    <front>
     <title>Proposal for Simple Gadget format support in OS 2.0 spec</title>
    </front>
   </reference>
   <reference anchor='Issue-1164'
              target="http://code.google.com/p/opensocial-resources/issues/detail?id=1164">
    <front>
     <title>Variable substitution standardized on EL</title>
    </front>
   </reference>
   <reference anchor='Issue-1171'
              target="http://code.google.com/p/opensocial-resources/issues/detail?id=1171">
    <front>
     <title>MessageBundle example missing from Core Gadget spec localization section</title>
    </front>
   </reference>
   <reference anchor='Issue-1169'
              target="http://code.google.com/p/opensocial-resources/issues/detail?id=1169">
    <front>
     <title>Add support for additional views</title>
    </front>
   </reference>
   <reference anchor='Issue-1167'
              target="http://code.google.com/p/opensocial-resources/issues/detail?id=1167">
    <front>
     <title>View Enhancements To Support Opening Of Gadgets and URLs</title>
    </front>
   </reference>
   <reference anchor='Issue-1161'
              target="http://code.google.com/p/opensocial-resources/issues/detail?id=1161">
    <front>
     <title>Declarative Actions and Selection </title>
    </front>
   </reference>
   <reference anchor='Issue-1166'
              target="http://code.google.com/p/opensocial-resources/issues/detail?id=1166">
    <front>
     <title>Proposal for OpenSearch Gadget Contributions</title>
    </front>
   </reference>
   <reference anchor='Issue-1144'
              target="http://code.google.com/p/opensocial-resources/issues/detail?id=1144">
    <front>
     <title>Embedded Experiences</title>
    </front>
   </reference>
   <reference anchor='Issue-1191'
              target="http://code.google.com/p/opensocial-resources/issues/detail?id=1191">
    <front>
     <title>gadgets.window.adjustWidth</title>
    </front>
   </reference>
   <reference anchor='Issue-1154'
              target="http://code.google.com/p/opensocial-resources/issues/detail?id=1154">
    <front>
     <title>Lifecycle events section improperly removed in 1.x</title>
    </front>
   </reference>
   <reference anchor='Issue-1143'
              target="http://code.google.com/p/opensocial-resources/issues/detail?id=1143">
    <front>
     <title>Move security policy to core gadgets</title>
    </front>
   </reference>
   <reference anchor='Issue-1178'
              target="http://code.google.com/p/opensocial-resources/issues/detail?id=1178">
    <front>
     <title>Add 'alias' to HTTP Request</title>
    </front>
   </reference>   
   <reference anchor='Issue-1179'
              target="http://code.google.com/p/opensocial-resources/issues/detail?id=1179">
    <front>
     <title>Specification Cleanup</title>
    </front>
   </reference>
   <reference anchor='Issue-1138'
              target="http://code.google.com/p/opensocial-resources/issues/detail?id=1138">
    <front>
     <title>OAuth 2.0 Support</title>
    </front>
   </reference>
   
   <reference anchor='Issue-1209'
              target="http://code.google.com/p/opensocial-resources/issues/detail?id=1209">
    <front>
     <title>OAuth 2.0 service configuration in ModulePrefs</title>
    </front>
   </reference>
   
   <reference anchor='Issue-1212'
              target="http://code.google.com/p/opensocial-resources/issues/detail?id=1212">
    <front>
     <title>Core Gadget Specification missing Content/@authz attribute in XSD</title>
    </front>
   </reference>
   
   <reference anchor='Issue-1231'
              target="http://code.google.com/p/opensocial-resources/issues/detail?id=1231">
    <front>
     <title>Enhance open-views and CommonContainer apis to allow for opening gadgets/ees/views at specific locations</title>
    </front>
   </reference>
   
   <reference anchor='Issue-1224'
              target="http://code.google.com/p/opensocial-resources/issues/detail?id=1224">
    <front>
     <title>Missing ExternalServices tag in the gadget schema</title>
    </front>
   </reference>
   
   <reference anchor='Issue-1283'
              target="http://code.google.com/p/opensocial-resources/issues/detail?id=1283">
    <front>
     <title>Add additional fields to the module section to support use in market places</title>
    </front>
   </reference>
   
   <reference anchor='Issue-1215'
              target="http://code.google.com/p/opensocial-resources/issues/detail?id=1215">
    <front>
     <title>No explanation of callback function for osapi.http methods</title>
    </front>
   </reference>
   
   <reference anchor='Issue-1321'
              target="http://code.google.com/p/opensocial-resources/issues/detail?id=1321">
    <front>
     <title>gadgets.views.openEmbeddedExperience should take the data model as a String or an Object</title>
    </front>
   </reference>
   
   <reference anchor='Issue-1300'
              target="http://code.google.com/p/opensocial-resources/issues/detail?id=1300">
    <front>
     <title>The description of the opt_params parameter for requestNavigateTo appears to be wrong</title>
    </front>
   </reference>
   
   <reference anchor='Issue-1249'
              target="http://code.google.com/p/opensocial-resources/issues/detail?id=1249">
    <front>
     <title>You have to write a large amount of code to access the embedded experience context</title>
    </front>
   </reference>
   
   <reference anchor='Issue-1207'
              target="http://code.google.com/p/opensocial-resources/issues/detail?id=1207">
    <front>
     <title>Core Gadget Section 8 - Versioning Refers To The Wrong Version Of The Spec</title>
    </front>
   </reference>
   
   <reference anchor='Issue-1234'
              target="http://code.google.com/p/opensocial-resources/issues/detail?id=1234">
    <front>
     <title>Gadget XML Schema defines a scrolling attribute for content elements</title>
    </front>
   </reference>
   
   <reference anchor='Issue-1259'
              target="http://code.google.com/p/opensocial-resources/issues/detail?id=1259">
    <front>
     <title>Error in selection spec</title>
    </front>
   </reference>
   
  </references>
  
  
  <!-- Real references -->
  <references>
   <reference anchor='RFC2119'>
    <front>
     <title>Key words for use in RFCs to Indicate Requirement Levels</title>
     <author initials='S.'
             surname='Bradner'
             fullname='Scott Bradner'>
      <organization abbrev='HarvardU'>Harvard University</organization>
     </author>
     <date month='March'
           year='1997' />
    </front>
    <seriesInfo name='RFC'
                value='2119' />
   </reference>
   <reference anchor='RFC2606'>
    <front>
     <title>Reserved Top Level DNS Names</title>
     <author initials='D.'
             surname='Eastlake'
             fullname='Donald E. Eastlake 3rd'>
      <organization abbrev='IBM'>IBM</organization>
     </author>
     <author initials='A.'
             surname='Panitz'
             fullname='Aliza R. Panitz'></author>
     <date month='June'
           year='1999' />
    </front>
    <seriesInfo name='RFC'
                value='2606' />
   </reference>
   <reference anchor='RFC2616'>
    <front>
     <title>Hypertext Transfer Protocol -- HTTP/1.1</title>
     <author initials='R.'
             surname='Fielding'>
      <organization>UC Irvine</organization>
     </author>
     <author initials='J.'
             surname='Gettys'>
      <organization>Compaq/W3C</organization>
     </author>
     <author initials='J.'
             surname='Mogul'>
      <organization>Compaq</organization>
     </author>
     <author initials='H.'
             surname='Frystyk'>
      <organization>W3C/MIT</organization>
     </author>
     <author initials='L.'
             surname='Masinter'>
      <organization>Xerox</organization>
     </author>
     <author initials='P.'
             surname='Leach'>
      <organization>Microsoft</organization>
     </author>
     <author initials='T.'
             surname='Berners-Lee'>
      <organization>W3C/MIT</organization>
     </author>
     <date month='June'
           year='1999' />
    </front>
    <seriesInfo name='RFC'
                value='2616' />
   </reference>
   <reference anchor='Caja'
              target="http://code.google.com/p/google-caja/">
    <front>
     <title>Caja Project</title>
     <date month='January'
           year='2009' />
    </front>
   </reference>
   <reference anchor="OpenSocial-Templating"
              target="./OpenSocial-Templating.xml">
    <front>
     <title>OpenSocial Templating Specification</title>
     <author fullname='OpenSocial and Gadgets Specification Group &lt;opensocial-and-gadgets-spec@googlegroups.com&gt;'>
     </author>
     <date month='August'
           year='2011' />
    </front>
   </reference>
   <reference anchor="OpenSocial-Specification"
              target="./OpenSocial-Specification.xml">
    <front>
     <title>OpenSocial Templating Specification</title>
     <author fullname='OpenSocial and Gadgets Specification Group &lt;opensocial-and-gadgets-spec@googlegroups.com&gt;'>
     </author>
     <date month='August'
           year='2011' />
    </front>
   </reference>
   <reference anchor="xsdpart1"
              target="http://www.w3.org/TR/xmlschema-1/">
    <front>
     <title>XML Schema Part 1: Structures Second Edition</title>
     <author initials='H.S.'
             surname='Thompson'
             fullname='Henry S. Thompson'>
      <organization>University of Edinburgh</organization>
     </author>
     <author initials='D.'
             surname='Beech'
             fullname='David Beech'>
      <organization>Oracle Corporation</organization>
     </author>
     <author initials='M.'
             surname='Maloney'
             fullname='Murray Maloney'>
      <organization>Commerce One</organization>
     </author>
     <author initials='N.'
             surname='Mendelsohn'
             fullname='Noah Mendelsohn'>
      <organization>Lotus Development Corporation</organization>
     </author>
     <date month='October'
           year='2004' />
    </front>
   </reference>
   <reference anchor='OAuth-Core'
              target='http://oauth.net/core/1.0/'>
    <front>
     <title>OAuth Core 1.0</title>
     <author initials='M.'
             surname='Atwood'
             fullname='Mark Atwood'></author>
     <author initials='R. M.'
             surname='Conlan'
             fullname='Richard M. Conlan'>
      <organization>Google</organization>
     </author>
     <author initials='B.'
             surname='Cook'
             fullname='Blaine Cook'>
      <organization>Twitter</organization>
     </author>
     <author initials='L.'
             surname='Culver'
             fullname='Leah Culver'>
      <organization>Pownce</organization>
     </author>
     <author initials='K.'
             surname='Elliott-McCrea'
             fullname='Kellan Elliott-McCrea'>
      <organization>Flickr</organization>
     </author>
     <author initials='L.'
             surname='Halff'
             fullname='Larry Halff'>
      <organization>ma.gnolia</organization>
     </author>
     <author initials='E.'
             surname='Hammer-Lahav'
             fullname='Eran Hammer-Lahav'></author>
     <author initials='B.'
             surname='Laurie'
             fullname='Ben Laurie'>
      <organization>Google</organization>
     </author>
     <author initials='C.'
             surname='Messina'
             fullname='Chris Messina'></author>
     <author initials='J.'
             surname='Panzer'
             fullname='John Panzer'></author>
     <author initials='S.'
             surname='Quigley'
             fullname='Sam Quigley'>
      <organization>Twitter</organization>
     </author>
     <author initials='D.'
             surname='Recordon'
             fullname='David Recordon'>
      <organization>six apart</organization>
     </author>
     <author initials='E.'
             surname='Sandler'
             fullname='Eran Sandler'>
      <organization>Yedda</organization>
     </author>
     <author initials='J.'
             surname='Sergent'
             fullname='Jonathan Sergent'>
      <organization>ma.gnolia</organization>
     </author>
     <author initials='B.'
             surname='Slesinsky'
             fullname='Brian Slesinsky'></author>
     <author initials='A.'
             surname='Smith'
             fullname='Andy Smith'>
      <organization>Jaiku</organization>
     </author>
     <date month='December'
           year='2007' />
    </front>
   </reference>
   <reference anchor="Core-API-Server"
              target="./Core-API-Server.xml">
    <front>
     <title>OpenSocial Core API Server Specification</title>
     <author fullname='OpenSocial and Gadgets Specification Group &lt;opensocial-and-gadgets-spec@googlegroups.com&gt;'>
     </author>
     <date month='August'
           year='2011' />
    </front>
   </reference>
   <reference anchor="Social-API-Server"
              target="./Social-API-Server.xml">
    <front>
     <title>OpenSocial Social API Server Specification</title>
     <author fullname='OpenSocial and Gadgets Specification Group &lt;opensocial-and-gadgets-spec@googlegroups.com&gt;'>
     </author>
     <date month='August'
           year='2011' />
    </front>
   </reference>
   <reference anchor='JSPEL'
              target="https://jsp.dev.java.net/spec/jsp-2_1-fr-spec-el.pdf">
    <front>
     <title>Java Server Pages Expression Language</title>
     <author initials='K.'
             surname='Chung'
             fullname='Kin-Man Chung'></author>
     <author initials='P.'
             surname='DeLisle'
             fullname='Pierre Delisle'></author>
     <author initials='M.'
             surname='Roth'
             fullname='Mark Roth'></author>
     <date month='May'
           year='2006' />
    </front>
   </reference>
   <reference anchor="OAHub2.0" target="http://www.openajax.org/member/wiki/OpenAjax_Hub_2.0_Specification_Introduction">
   	<front>
   		<title>OpenAjax Hub 2.0</title>
   		<author>TBD</author>
   		<date/>
   	</front>
   </reference>
   <reference anchor="draft-ietf-oauth-v2-22"
               target="http://tools.ietf.org/html/draft-ietf-oauth-v2-22">
     <front>
       <title>The OAuth 2.0 Authorization Protocol</title>
       <author initials='E.'
               surname='Hammer-Lahav'
               fullname='Eran Hammer-Lahav'>
               <organization>Yahoo !</organization>
       </author>
       <author initials='D.'
               surname='Recordon'
               fullname='David'>
               <organization>Facebook</organization>
       </author>
       <author initials='D.'
               surname='Hardt'
               fullname='Dick'>
               <organization>Microsoft</organization>
       </author>
       <date month='September'
             year='2011' />
     </front>
   </reference>
  </references>
 </back>
</rfc>

