Sign in

Managing Multiple Data Objects

The Creating Advanced Responses page discussed how you can create templates for custom results. This page shows you how you can manage large numbers of data objects, including ones created by other Subscribed Links developers.

Contents

This page includes the following sections:

Creating DataObject TSV Files

If you created a large number of data objects, you can encode them in a text file with tab-separated values (TSV). You still create ResultSpec elements in an XML file, but you can house their corresponding data objects in a TSV file. Submit both the XML file and the TSV file to Google, and Google will automatically match the data objects in the TSV files to the ResultSpec elements in the XML file. For more information about submitting files to Google, see the Publishing Your Subscribed Link page.

You can create multiple TSV files and use TSV files created by other developers. For more information about combining and reusing multiple sources, see the Combining Multiple Files section.

Elements of the DataObject TSV File

The TSV file for data objects should start with the header text: # subscribed links TSV file. The lines that follow the header define the data objects. You create two kinds of lines: type, which identifies the names of the attribute variables, and data, which defines the values of object types and attribute variables. Each line must begin with either the type or data keyword.

If you are using a plain text editor, separate each element by a single tab character. Do not try to prettify and align the lines with multiple tab characters. If you are using a spreadsheet editor, allocate a column for each of the elements.

Elements of the type Line

If you want to create a data object that contains only the query pattern but no attribute variable values (that is, the data object only has QueryName elements but no Attribute element), you don't need to create a type line.

Each type line should have the following elements in the same order as the list below:

  • Keyword: type - identifies the line as a definition for the attribute names.
  • Object type - indicates the type of data object that the line is defining. In the XML format, this would be the value of the DataObject type attribute.
  • Attribute variables - list the names of the attribute variables. In the XML format, these would be the values for the Attribute Name elements.

The following examples demonstrate how you can define the attribute variable names in a TSV file:

XML Format TSV Format
<Results>

<DataObject id="highway101" type="Highway">
  <QueryName value="highway 101"/>
  <QueryName value="us 101"/>
  <QueryName value="route 101"/>
  <Attribute name="fullname" value="US Route 101"/>
  <Attribute name="abbrev" value="US-101"/>
  <Attribute name="max_speed_limit" value="65 MPH"/>
</DataObject>

<DataObject id="montague" type="Expressway">
  <QueryName value="montague expressway"/>
  <QueryName value="montague parkway"/>
  <QueryName value="Montague"/>
  <Attribute name="fullname" value="Montague Expressway"/>
  <Attribute name="abbrev" value="G-4"/>
  <Attribute name="max_speed_limit" value="50 MPH"/>
</DataObject>

<DataObject id="goldengate" type="Bridge">
  <QueryName value="golden gate"/>
  <QueryName value="golden gate bridge"/>
</DataObject>

</Results>
   
# subscribed links TSV file

type  Highway  fullname	abbrev	max_speed_limit
type  Expressway  fullname	abbrev	max_speed_limit	
    

In the example, the third data object in the XML format, which has the ID "goldengate", does not appear in the TSV version. This is because it has only QueryName elements and does not have an Attribute element.

Elements of the data Line

Each line should have the following elements in the same order as the following list:

  • Keyword: data - identifies the line as a definition for the values of the query pattern and the attribute variables. In the XML format, this would be the values of the QueryName value and Attribute name attributes.
  • Object type - indicates the type of object that the line is defining. In the XML format, this would be the value of the DataObject type attribute.
  • ID - indicates the unique ID of the data object. In the XML format, this would be the value of the DataObject id attribute.
  • Values of the attribute variables - define the values of the attribute variables. In the XML format, this would be the value of the Attribute value attribute. The order of the values must correspond to the order of the attribute variables in the type line of the TSV file.
  • Values of the query patterns- list the query pattern. In the XML format, these would be the values of the QueryName elements.

The following examples demonstrate how you can define the values of the query patterns and attribute variables in a TSV file:

XML Format TSV Format
<Results>

<DataObject id="highway101" type="Highway">
  <QueryName value="highway 101"/>
  <QueryName value="us 101"/>
  <QueryName value="route 101"/>
  <Attribute name="fullname" value="US Route 101"/>
  <Attribute name="abbrev" value="US-101"/>
  <Attribute name="max_speed_limit" value="65 MPH"/>
</DataObject>

<DataObject id="montague" type="Expressway">
  <QueryName value="montague expressway"/>
  <QueryName value="montague parkway"/>
  <QueryName value="Montague"/>
  <Attribute name="fullname" value="Montague Expressway"/>
  <Attribute name="abbrev" value="G-4"/>
  <Attribute name="max_speed_limit" value="50 MPH"/>
</DataObject>

<DataObject id="goldengate" type="Bridge">
  <QueryName value="golden gate"/>
  <QueryName value="golden gate bridge"/>
</DataObject>

</Results>
# subscribed links TSV file

type  Highway  fullname	abbrev	max_speed_limit
type  Expressway  fullname	abbrev	max_speed_limit	
data  Highway  highway101	US Route 101	US-101	65 MPH	highway 101	us 101	route 101
data  Expressway  montague	Montague Expressway	G-4	50 MPH	montague expressway	montague parkway	
data  Bridge  goldengate  golden gate  golden gate bridge

Combining Multiple Files

You can submit multiple XML and TSV files to Google. Your subscribed link is triggered based on the combined data from all the submitted files. Combining files is particularly useful if you reuse data objects created by other developers.

If you decide to use multiple files, you must maintain the uniqueness of the following across all your subscribed link files:

  • Values of QueryName elements
  • IDs of ResultSpec elements
  • IDs of DataObject elements

If you have a DataObject element in one file that has the same ID as a different DataObject element in another file, your data might fail to load properly.

Using Other People's Subscribed Links or DataObjects

When you construct your subscribed link, you can use Subscribed Links XML and TSV files created by other developers. Simply submit the URL of the Subscribed Links file to Google, as described in the Publishing Your Subscribed Link page. However, before you do that, make sure that their data will not affect the basic operation of your subscribed link. For instance, their files might change the appearance of your custom result, add triggering patterns, or produce different custom results.

So if you want to use data maintained by other developers while retaining overall control of your subscribed link, create your own result specifications while pointing to third-party data objects. To do this, select the "Only read DataObjects from this feed." check box in http://www.google.com/coop/manage/subscribedlinks/submit.

Taking the Next Step

You have just learned how to streamline your development process by encoding numerous data objects into simple TSV files and by using already existing data objects from other developers. The Creating an Advanced Subscribed Link page shows you a few more techniques, such as restricting the set of queries that trigger a response, to further increase your development efficiency. However, if you are already satisfied with your subscribed link, you can start testing and troubleshooting them.

 

< Back to Creating Response Templates | Forward to Creating an Advanced Subscribed Link >