gdocs:fetch

Purpose

Retrieves the contents of a single document from Google Docs™.

Note:

An XDIME fragment returned by the pipeline operation must be targeted at a region. Note that if the layout is not specified explicitly, then the current container is automatically set to the anonymous region. Refer to the topic entitled XDIME 2 in layouts for more information.

Contained by

Contains

Attributes

Attribute Description Type Default Options Use
category The category of documents to return. The value of this attribute must be set to 'document'. xs:string document  document  required 
href

The URL of a document to retrieve from Google Docs.

Note:

The format of this URL is determined solely by Google Docs. It is recommended to use a URL returned in the response from a previous use of the gdocs:list-docs operation.

xs:string     required 
xml:id It is used by the pipeline:errorSourceID function to identify the gdocs:fetch element. Refer to Handling pipeline errors for further information. xs:ID     optional 

Examples

<?xml version="1.0" encoding="utf-8"?>
<html xmlns="http://www.w3.org/2002/06/xhtml2"
  xmlns:mcs="http://www.volantis.com/xmlns/2006/01/xdime/mcs"
  xmlns:pipeline="http://www.volantis.com/xmlns/marlin-pipeline"
  xmlns:gdocs="http://www.volantis.com/xmlns/2008/08/gdocs">
  <head>
    <title>gdocs:fetch</title>
    <link rel="mcs:layout" href="test.mlyt"/>
  </head>
  <body>
    <div style="mcs-container:'gdoccontainer'">
      <pipeline:transform href="fetch2xdime.xsl">
        <gdocs:fetch xml:id="first fetch"
          href="https://docs.google.com/feeds/download/documents/Export?docID=dcg224t7_2d92rmb64&amp;exportFormat=html">
          <gdocs:authenticate user-id="antennatests@gmail.com" password="1antenna1"/>
        </gdocs:fetch>
      </pipeline:transform>
    </div>
  </body>
</html>

The test.mlyt layout must contain a region named 'gdoccontainer'. The mcs-container style property targets the XDIME fragment returned by the pipeline operation at that region.

The Google Docs service returns the contents of the requested document as HTML. The fetch2xdime.xsl transform shows how one can handle text documents returned by Google Docs. It transforms the response to XDIME.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
  xmlns="http://www.w3.org/2002/06/xhtml2"
  xmlns:mcs="http://www.volantis.com/xmlns/2006/01/xdime/mcs">
  <!-- By default all elements are copied into xhtml2 namespace -->
  <xsl:template match="*">
    <xsl:element name="{local-name()}" namespace="http://www.w3.org/2002/06/xhtml2">
      <xsl:copy-of select="@*"/>
      <xsl:apply-templates/>
    </xsl:element>
  </xsl:template>
  <xsl:template match="head">
    <xsl:element name="{local-name()}" namespace="http://www.w3.org/2002/06/xhtml2">
      <xsl:copy-of select="@*"/>
      <xsl:apply-templates select="title"/>
      <xsl:apply-templates select="style"/>
    </xsl:element>
  </xsl:template>
  <xsl:template match="body">
    <xsl:element name="{local-name()}" namespace="http://www.w3.org/2002/06/xhtml2">
      <xsl:copy-of select="@*"/>
      <div>
        <xsl:apply-templates select="*"/>
      </div>
    </xsl:element>
  </xsl:template>
  <!-- I tag converted to style -->
  <xsl:template match="i">
    <span>
      <xsl:attribute name="style">font-style: italic</xsl:attribute>
      <xsl:apply-templates/>
    </span>
  </xsl:template>
  <!-- B tag converted to style -->
  <xsl:template match="b">
    <span>
      <xsl:attribute name="style">font-weight: bold</xsl:attribute>
      <xsl:apply-templates/>
    </span>
  </xsl:template>
  <!-- U tag converted to style -->
  <xsl:template match="u">
    <span>
      <xsl:attribute name="mcs-text-underline-style">solid</xsl:attribute>
      <xsl:apply-templates/>
    </span>
  </xsl:template>
  <!-- FONT tag converted to styled span -->
  <xsl:template match="font">
    <span>
      <xsl:attribute name="style">
        <xsl:value-of select="@style"/>
      </xsl:attribute>
      <xsl:apply-templates/>
    </span>
  </xsl:template>
  <!--BR tag converted to mcs:br -->
  <xsl:template match="br">
    <mcs:br/>
  </xsl:template>
  <!--IMG tag converted to object -->
  <xsl:template match="img">
    <object>
      <xsl:attribute name="srctype">image/*</xsl:attribute>
      <xsl:attribute name="src">http://docs.google.com/<xsl:value-of select="@src"/></xsl:attribute>
      <xsl:apply-templates/>
    </object>
  </xsl:template>
</xsl:stylesheet>

Related topics