Microsummary XML grammar reference

  • Revision slug: Microsummary_XML_grammar_reference
  • Revision title: Microsummary XML grammar reference
  • Revision id: 87578
  • Created:
  • Creator: Enaeseth
  • Is current revision? No
  • Comment /* The <code>&lt;template&gt;</code> element */ typo fix

Revision Content

Introduction

A microsummary generator is an XML document that describes how to pull specific information from a web page to be presented in summary form as a bookmark whose title changes based on the content of the page it targets.

This article provides detailed information about the XML grammar used to build microsummary generators, describing each element and their attributes. For an introduction to how to create a microsummary, read the article Creating a Microsummary.

Example

The microsummary generator created in the Creating a Microsummary tutorial:

<?xml version="1.0" encoding="UTF-8"?>
<generator xmlns="http://www.mozilla.org/microsummaries/0.1" name="Firefox Download Count">
  <template>
    <transform xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">
      <output method="text"/>
      <template match="/">
        <value-of select="id('download-count')"/>
        <text> Fx downloads</text>
      </template>
    </transform>
  </template>
  <pages>
    <include>http://(www\.)?spreadfirefox\.com/(index\.php)?</include>
  </pages>
</generator>

Namespace

The namespace URI for microsummary generator XML documents is:

http://www.mozilla.org/microsummaries/0.1

All elements in a microsummary generator document should be in this namespace except the descendants of the <template> element, which should be in the XSLT namespace:

http://www.w3.org/1999/XSL/Transform

The <generator> element

The <generator> element is the root tag for all microsummary generators, and should contain the remainder of the XML code describing the generator.

Attributes:

name (required)
A descriptive, human-readable name for the microsummary created by the generator.
uri (optional)
A valid URI uniquely identifying the generator. Only relevant for generators dynamically created by Firefox code and extensions. Generators installed from the web via nsSidebar::addMicrosummaryGenerator are identified by the remote URL from which they were downloaded, and Firefox ignores the value of this attribute for them.

Child Elements:

<template> (required)
Defines how to transform pages into their microsummaries.
<pages> (required)
Identifies the set of pages that the generator is able to summarize.
<update> (optional)
Specifies how frequently Firefox should update the microsummaries.

The <template> element

The <template> element contains the XSLT stylesheet which transforms web pages into their microsummaries.

Attributes:

None.

Child Elements:

<stylesheet> or <transform> (required)
The XSLT stylesheet which performs the transformation.

Per XSLT, you may specify the stylesheet child element using either the <stylesheet> or the <transform> tag, which are interchangeable.

Note: Although the <template> element must be in the microsummaries namespace (http://www.mozilla.org/microsummaries/0.1), its <stylesheet>/<transform> child element must be in the XSLT namespace (http://www.w3.org/1999/XSL/Transform).

The <pages> element

The <pages> element identifies the set of pages that the generator is able to summarize.

Attributes:

None.

Child Elements:

<include> (optional)
A regular expression matching the URLs of pages that the generator is able to summarize.
<exclude> (optional)
A regular expression matching the URLs of pages that the generator is not able to summarize.

The <pages> element can contain zero or more <include> and <exclude> child elements, each of which must contain a valid JavaScript-compatible regular expression. It must not contain any other elements, and it does not have any attributes.

When a generator is examined to determine whether or not it is able to summarize a page, the regular expressions provided by the child elements are evaluated against the URL of the page. A generator is considered to be able to summarize a page if at least one of the <include> expressions matches the URL of the page and none of the <exclude> expressions match the URL of the page.

The order in which child elements appear within the <pages> element is not significant. White space between the child element tags and the regular expressions they contain is also not significant; it is not considered part of the regular expression, and it does not affect evaluation of the expressions.

The following example identifies a generator as being able to summarize all pages on the www.example.com web site except pages named about.html:

<pages>
  <include>
    ^http://www\.example\.com/
  </include>
  <exclude>/about\.html</exclude>
</pages>
Note: Regular expressions intended to match the beginnings of page URLs should start with the caret (^) to ensure they do not inadvertently match URLs which merely contain the URLs they intend to match. For example, the regular expression http://www\.example\.com/ matches both the URL http://www.example.com/ and the URL http://www.evil.com/http://www.example.com/, but the regular expression ^http://www\.example\.com/ matches only the first of those two URLs.

See the reference Core_JavaScript_1.5_Reference:Global_Objects:RegExp for the details of the regular expression syntax valid for generators and the tutorial Creating regular expressions for a microsummary generator for step by step instructions to writing regular expressions that match URLs.

The <include> element

The <include> element identifies a set of pages that the generator is able to summarize. It must be a child of the <pages> element, and it must contain a JavaScript-compatible regular expression.

For more information about the use of this element, see the entry for #The_<pages>_element.

The <exclude> element

The <exclude> element identifies a set of pages that the generator is not able to summarize. It must be a child of the <pages> element, and it must contain a JavaScript-compatible regular expression.

For more information about the use of this element, see the entry for #The_<pages>_element.

The <update> element

The optional <update> element specifies how frequently Firefox should update microsummaries generated by the generator. The element can be used to specify both an absolute update interval and a series of conditional intervals based on the content of the page being summarized.

Attributes:

interval (optional)
An absolute interval of time, in minutes, that must elapse between updates.

Child Elements:

<condition> (optional)
An XPath boolean expression along with a conditional interval of time, in minutes, that must elapse between updates if the expression evaluates to true.

The interval attribute defines an absolute interval in minutes. Its value must be a number greater than or equal to 1. Fractional values (e.g. 5.5 minutes) are permitted, although they probably aren't useful.

The <update> element may contain any number of <condition> child elements.

Firefox determines which interval to apply to a microsummary generated by a generator according to the following rules:

  1. Firefox processes each <condition> child element in document order. For each one, Firefox evaluates the element's XPath boolean expression against the page being summarized. If the expression evaluates to true, Firefox applies that element's interval and stops processing child elements. Thus, the first matching <condition> determines the update interval.
  2. If there are no <condition> child elements, or if none of their expressions evaluate to true, Firefox applies the value of the <update> element's interval attribute.
  3. If the <update> element does not include an interval attribute, Firefox applies the interval specified by the browser.microsummary.updateInterval preference.
  4. If that preference has not been set, Firefox applies its default update interval, which is 30 minutes.

Notes:

  • regardless of the absolute or conditional update interval specified by this element, Firefox will never update microsummaries more frequently than once per minute;
  • because Firefox checks for expired microsummaries every 15 seconds, it is possible for a microsummary update to begin up to 15 seconds later than its interval indicates;
  • Firefox respects the browser cache when updating microsummaries, so it will not reload a page to update its microsummary if the cache contains a fresh copy of the page.

The <condition> element

The optional <condition> element specifies an XPath boolean expression along with a conditional interval of time, in minutes, that must elapse between updates if the expression evaluates to true when evaluated against the page being summarized. It must be a child of the <update> element.

Attributes:

expression (required)
An XPath boolean expression to be evaluated against the page being summarized.
interval (required)
An interval of time, in minutes, that must elapse between updates if the expression evaluates to true.

Child Elements:

None.

For more information about the use of this element, see the entry for the <update> element.

See also

{{ languages( { "fr": "fr/R\u00e9f\u00e9rence_grammaticale_XML_d\'un_micror\u00e9sum\u00e9", "ja": "ja/Microsummary_XML_grammar_reference" } ) }}

Revision Source

<p>
</p>
<h2 name="Introduction">Introduction</h2>
<p>A microsummary generator is an XML document that describes how to pull specific information from a web page to be presented in summary form as a bookmark whose title changes based on the content of the page it targets.
</p><p>This article provides detailed information about the XML grammar used to build microsummary generators, describing each element and their attributes. For an introduction to how to create a microsummary, read the article <a href="en/Creating_a_Microsummary">Creating a Microsummary</a>.
</p>
<h2 name="Example">Example</h2>
<p>The microsummary generator created in the <a href="en/Creating_a_Microsummary">Creating a Microsummary</a> tutorial:
</p>
<pre class="eval">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;generator xmlns="<span class="nowiki">http://www.mozilla.org/microsummaries/0.1</span>" name="Firefox Download Count"&gt;
  &lt;template&gt;
    &lt;transform xmlns="<span class="nowiki">http://www.w3.org/1999/XSL/Transform</span>" version="1.0"&gt;
      &lt;output method="text"/&gt;
      &lt;template match="/"&gt;
        &lt;value-of select="id('download-count')"/&gt;
        &lt;text&gt; Fx downloads&lt;/text&gt;
      &lt;/template&gt;
    &lt;/transform&gt;
  &lt;/template&gt;
  &lt;pages&gt;
    &lt;include&gt;<span class="nowiki">http://(www\.)?spreadfirefox\.com/(index\.php)?</span>&lt;/include&gt;
  &lt;/pages&gt;
&lt;/generator&gt;
</pre>
<h2 name="Namespace">Namespace</h2>
<p>The namespace URI for microsummary generator XML documents is:
</p>
<pre class="eval"><span class="nowiki">http://www.mozilla.org/microsummaries/0.1</span>
</pre>
<p>All elements in a microsummary generator document should be in this namespace except the descendants of the <code><a href="#The_.3Ctemplate.3E_element">&lt;template&gt;</a></code> element, which should be in the XSLT namespace:
</p>
<pre class="eval"><span class="nowiki">http://www.w3.org/1999/XSL/Transform</span>
</pre>
<h2 name="The_.3Cgenerator.3E_element">The <code>&lt;generator&gt;</code> element</h2>
<p>The <code>&lt;generator&gt;</code> element is the root tag for all microsummary generators, and should contain the remainder of the XML code describing the generator.
</p><p><b>Attributes:</b>
</p>
<dl><dt> <code>name</code> (required)
</dt><dd> A descriptive, human-readable name for the microsummary created by the generator.
</dd><dt> <code>uri</code> (optional)
</dt><dd> A valid URI uniquely identifying the generator. Only relevant for generators dynamically created by Firefox code and extensions. Generators installed from the web via <code>nsSidebar::addMicrosummaryGenerator</code> are identified by the remote URL from which they were downloaded, and Firefox ignores the value of this attribute for them.
</dd></dl>
<p><b>Child Elements:</b>
</p>
<dl><dt> <code><a href="#The_.3Ctemplate.3E_element">&lt;template&gt;</a></code> (required)
</dt><dd> Defines how to transform pages into their microsummaries.
</dd><dt> <code><a href="#The_.3Cpages.3E_element">&lt;pages&gt;</a></code> (required)
</dt><dd> Identifies the set of pages that the generator is able to summarize.
</dd><dt> <code><a href="#The_.3Cupdate.3E_element">&lt;update&gt;</a></code> (optional)
</dt><dd> Specifies how frequently Firefox should update the microsummaries.
</dd></dl>
<h2 name="The_.3Ctemplate.3E_element">The <code>&lt;template&gt;</code> element</h2>
<p>The <code>&lt;template&gt;</code> element contains the XSLT stylesheet which transforms web pages into their microsummaries.
</p><p><b>Attributes:</b>
</p><p><i>None.</i>
</p><p><b>Child Elements:</b>
</p>
<dl><dt> <code>&lt;stylesheet&gt;</code> or <code>&lt;transform&gt;</code> (required)
</dt><dd> The XSLT stylesheet which performs the transformation.
</dd></dl>
<p>Per <a href="en/XSLT">XSLT</a>, you may specify the stylesheet child element using either the <code>&lt;stylesheet&gt;</code> or the <code>&lt;transform&gt;</code> tag, which are interchangeable.
</p>
<div class="note">
<p><b>Note:</b> Although the &lt;template&gt; element must be in the microsummaries namespace (<span class="nowiki">http://www.mozilla.org/microsummaries/0.1</span>), its <code>&lt;stylesheet&gt;</code>/<code>&lt;transform&gt;</code> child element must be in the XSLT namespace (<span class="nowiki">http://www.w3.org/1999/XSL/Transform</span>).
</p>
</div>
<h2 name="The_.3Cpages.3E_element">The <code>&lt;pages&gt;</code> element</h2>
<p>The <code>&lt;pages&gt;</code> element identifies the set of pages that the generator is able to summarize.
</p><p><b>Attributes:</b>
</p><p><i>None.</i>
</p><p><b>Child Elements:</b>
</p>
<dl><dt> <code><a href="#The_.3Cinclude.3E_element">&lt;include&gt;</a></code> (optional)
</dt><dd> A regular expression matching the URLs of pages that the generator is able to summarize.
</dd><dt> <code><a href="#The_.3Cexclude.3E_element">&lt;exclude&gt;</a></code> (optional)
</dt><dd> A regular expression matching the URLs of pages that the generator is not able to summarize.
</dd></dl>
<p>The <code>&lt;pages&gt;</code> element can contain zero or more <code>&lt;include&gt;</code> and <code>&lt;exclude&gt;</code> child elements, each of which must contain a valid JavaScript-compatible regular expression. It must not contain any other elements, and it does not have any attributes.
</p><p>When a generator is examined to determine whether or not it is able to summarize a page, the regular expressions provided by the child elements are evaluated against the URL of the page. A generator is considered to be able to summarize a page if at least one of the <code>&lt;include&gt;</code> expressions matches the URL of the page and none of the <code>&lt;exclude&gt;</code> expressions match the URL of the page.
</p><p>The order in which child elements appear within the <code>&lt;pages&gt;</code> element is not significant. White space between the child element tags and the regular expressions they contain is also not significant; it is not considered part of the regular expression, and it does not affect evaluation of the expressions.
</p><p>The following example identifies a generator as being able to summarize all pages on the <code>www.example.com</code> web site except pages named <code>about.html</code>:
</p>
<pre class="eval">&lt;pages&gt;
  &lt;include&gt;
    <span class="nowiki">^http://www\.example\.com/</span>
  &lt;/include&gt;
  &lt;exclude&gt;/about\.html&lt;/exclude&gt;
&lt;/pages&gt;
</pre>
<div class="note"><b>Note:</b> Regular expressions intended to match the beginnings of page URLs should start with the caret (^) to ensure they do not inadvertently match URLs which merely contain the URLs they intend to match. For example, the regular expression <code><span class="nowiki">http://www\.example\.com/</span></code> matches both the URL <code><span class="nowiki">http://www.example.com/</span></code> and the URL <code><span class="nowiki">http://www.evil.com/http://www.example.com/</span></code>, but the regular expression <code><span class="nowiki">^http://www\.example\.com/</span></code> matches only the first of those two URLs.</div>
<p>See the reference <a href="en/Core_JavaScript_1.5_Reference/Global_Objects/RegExp">Core_JavaScript_1.5_Reference:Global_Objects:RegExp</a> for the details of the regular expression syntax valid for generators and the tutorial <a href="en/Creating_regular_expressions_for_a_microsummary_generator">Creating regular expressions for a microsummary generator</a> for step by step instructions to writing regular expressions that match URLs.
</p>
<h2 name="The_.3Cinclude.3E_element">The <code>&lt;include&gt;</code> element</h2>
<p>The <code>&lt;include&gt;</code> element identifies a set of pages that the generator is able to summarize. It must be a child of the <code>&lt;pages&gt;</code> element, and it must contain a JavaScript-compatible regular expression.
</p><p>For more information about the use of this element, see the entry for <a href="#The_.3Cpages.3E_element">#The_&lt;pages&gt;_element</a>.
</p>
<h2 name="The_.3Cexclude.3E_element">The <code>&lt;exclude&gt;</code> element</h2>
<p>The <code>&lt;exclude&gt;</code> element identifies a set of pages that the generator is not able to summarize. It must be a child of the <code>&lt;pages&gt;</code> element, and it must contain a JavaScript-compatible regular expression.
</p><p>For more information about the use of this element, see the entry for <a href="#The_.3Cpages.3E_element">#The_&lt;pages&gt;_element</a>.
</p>
<h2 name="The_.3Cupdate.3E_element">The <code>&lt;update&gt;</code> element</h2>
<p>The optional <code>&lt;update&gt;</code> element specifies how frequently Firefox should update microsummaries generated by the generator. The element can be used to specify both an absolute update interval and a series of conditional intervals based on the content of the page being summarized.
</p><p><b>Attributes:</b>
</p>
<dl><dt> <code>interval</code> (optional)
</dt><dd> An absolute interval of time, in minutes, that must elapse between updates.
</dd></dl>
<p><b>Child Elements:</b>
</p>
<dl><dt> <code><a href="#The_.3Ccondition.3E_element">&lt;condition&gt;</a></code> (optional)
</dt><dd> An XPath boolean expression along with a conditional interval of time, in minutes, that must elapse between updates if the expression evaluates to true.
</dd></dl>
<p>The <code>interval</code> attribute defines an absolute interval in minutes. Its value must be a number greater than or equal to 1. Fractional values (e.g. 5.5 minutes) are permitted, although they probably aren't useful.
</p><p>The <code>&lt;update&gt;</code> element may contain any number of <code>&lt;condition&gt;</code> child elements.
</p><p>Firefox determines which interval to apply to a microsummary generated by a generator according to the following rules:
</p>
<ol><li> Firefox processes each <code>&lt;condition&gt;</code> child element in document order. For each one, Firefox evaluates the element's XPath boolean expression against the page being summarized. If the expression evaluates to <code>true</code>, Firefox applies that element's interval and stops processing child elements. Thus, the first matching <code>&lt;condition&gt;</code> determines the update interval.
</li><li> If there are no <code>&lt;condition&gt;</code> child elements, or if none of their expressions evaluate to <code>true</code>, Firefox applies the value of the <code>&lt;update&gt;</code> element's <code>interval</code> attribute.
</li><li> If the <code>&lt;update&gt;</code> element does not include an <code>interval</code> attribute, Firefox applies the interval specified by the browser.microsummary.updateInterval preference.
</li><li> If that preference has not been set, Firefox applies its default update interval, which is 30 minutes.
</li></ol>
<p><b>Notes:</b>
</p>
<ul><li> regardless of the absolute or conditional update interval specified by this element, Firefox will never update microsummaries more frequently than once per minute;
</li><li> because Firefox checks for expired microsummaries every 15 seconds, it is possible for a microsummary update to begin up to 15 seconds later than its interval indicates;
</li><li> Firefox respects the browser cache when updating microsummaries, so it will not reload a page to update its microsummary if the cache contains a fresh copy of the page.
</li></ul>
<h2 name="The_.3Ccondition.3E_element">The <code>&lt;condition&gt;</code> element</h2>
<p>The optional <code>&lt;condition&gt;</code> element specifies an XPath boolean expression along with a conditional interval of time, in minutes, that must elapse between updates if the expression evaluates to true when evaluated against the page being summarized. It must be a child of the <code>&lt;update&gt;</code> element.
</p><p><b>Attributes:</b>
</p>
<dl><dt> <code>expression</code> (required)
</dt><dd> An XPath boolean expression to be evaluated against the page being summarized.
</dd><dt> <code>interval</code> (required)
</dt><dd> An interval of time, in minutes, that must elapse between updates if the expression evaluates to <code>true</code>.
</dd></dl>
<p><b>Child Elements:</b>
</p><p><i>None.</i>
</p><p>For more information about the use of this element, see the entry for <a href="#The_.3Cupdate.3E_element">the <code>&lt;update&gt;</code> element</a>.
</p>
<h2 name="See_also">See also</h2>
<ul><li> <a href="en/Creating_a_Microsummary">Creating a Microsummary</a>
</li><li> <a href="en/XSLT">XSLT</a>
</li></ul>
{{ languages( { "fr": "fr/R\u00e9f\u00e9rence_grammaticale_XML_d\'un_micror\u00e9sum\u00e9", "ja": "ja/Microsummary_XML_grammar_reference" } ) }}
Revert to this revision