Your Search Results


    XUL テンプレートは、クエリや、それに似た操作からのそれぞれの結果を、コンテンツのブロックとして提供します。データベースクエリの結果と、よく似ています。クエリからのそれぞれの結果の為に、いくつかのコンテンツを生成します。テンプレート構文は、返ってきた結果から属性値を適切に設定し、特定基準ベースの異なったコンテンツを生成するためのルールを、許容しています。その他のいくつかのシステムでも、このデータバインディングを呼び出しています。実際に、XUL テンプレートは、XUL のやり方でデータバインディングを行っています。どんなテンプレートでも、二つの制約があります。一つ目は、クエリーの結果から一つのコンテンツだけを生成できる事です。一片のデータとそれに割当てられた値は取得することができず、テンプレートからの繰り返されたデータのブロックとしてデザインされます。二つ目は、RDF データソースと結び付けられる事です。これらの制限は、いずれ無くなるでしょう。

    XUL の中で、RDF データソースは 一つのエレメントの 'datasources' 値が順位付けされたものです。XUL パーサがこの値を一つのエレメントとしてみる時、テンプレートビルダーはエレメントとそれに添えられたエレメントとして構成される。それは、それらがテンプレートの内部エレメントだろうと、期待されているものです。テンプレートビルダーがデータソースを読み込み、データソース上のクエリを実行しそれぞれの結果からコンテンツを生成します。このコンテンツは、ちょうどあなた自身が行うように、 XUL の中に挿入されます。ここに見本を表示します。

    <vbox datasources="">

    この見本は、'' データソースを指定しています。

    The template builder loads the datasource using the RDF service in the same way as you would create a datasource through the RDF service directly. The datasource is loaded via its URL. Some RDF datasources are provided with Mozilla -- their URL's start with 'rdf:'. Otherwise, the datasource is loaded as any other URL is loaded. If the datasource is already loaded and cached, the template builder can begin work right away. Otherwise, there isn't anything to do until the data is loaded. Actually, this isn't quite true. The RDF service starts the load of the datasource in the background and the template builder goes through the process of building content anyway. Naturally, since there is no data yet, no results will be available so the builder ends up building nothing.

    Once some data starts arriving, the template builder scans its information to see if some results can be created. If so, some content can be generated. If not, nothing gets generated again. An interesting thing to note is that due to the nature of the RDF parsing process, the builder generates results and builds content incrementally while the data arrives. Of course, since the data arrives so quickly from the network, you really don't notice this. If the datasource is already loaded, the builder can construct content all in one step, although even this isn't completely true as we'll see later.

    The template builder can also use multiple datasources which are all combined into a single datasource as if they were all in one datasource to begin with. An nsIRDFCompositeDataSource is used for this purpose. You can get this composite datasource in a script by using an element's 'database' property if you want to add or remove datasources from it.

    As mentioned, the template builder loads the datasources by passing the URLs to the RDF service. However, the special URL rdf:null is used to indicate that you mean no datasources, or an empty datasource. The composite datasource will still be created but no datasources will be added to it. This is used when you need to specify the datasource dynamically with a script.

    In addition, for chrome XUL (such as extensions), the datasource rdf:local-store is always included in the composite. The local store is a datasource which is usually used to hold state information such as window sizes, which columns in a tree are showing and which tree items are open. You can query for any data in the local store in a template although this is rarely done.

    When multiple datasources are used the RDF is combined as if it was one large datasource. That means that a template query can grab data from anywhere in all of the datasources. This combining of datasources is often termed aggregation. This can be quite a useful feature and works regardless of the datasource. For instance, you might use the built-in bookmarks datasource which holds the user's browser bookmarks and use your own datasource to add custom data about those bookmarks.

    <vbox datasources="rdf:bookmarks">


    RDF is, in mathematical terms, a labeled directed graph. That means that RDF is a graph of nodes and arrows between them where each node and arrow has some label. Since it's a graph, arrows can point all over the place and nodes can have any number of arrows pointing out of them and pointing at them. And also because it is a graph, there is no real starting point or root node so you can just start anywhere. In the picture below, you can see that node A at the top has arcs pointing to B, C and D. As well, C has an arc pointing to D. You could have arcs pointing elsewhere, for example node D could have an arc pointing back to A. To navigate around, you could start at node A and navigate around the graph following the arrows to B, C or D. Or you could start at B and go to A and then go to C and D. No requirement exists to follow the arrows in the direction they point; you can easily go the other way. The picture was generated from the W3C's RDF validator, a good place to go to check if your RDF is valid.


    The text in red are the labels for the arrows, called predicates. In this example, all the arrows have the same label. Usually, this won't be the case. Templates provide a means of navigating around using only arrows with specific labels. Here is one serialization of RDF/XML for this graph, though there are many others.

    <?xml version="1.0"?>
    <rdf:RDF xmlns:rdf=""
      <rdf:Description rdf:about="">
        <rel:relatedItem rdf:resource=""/>
        <rel:relatedItem rdf:resource=""/>
        <rel:relatedItem rdf:resource=""/>
      <rdf:Description rdf:about="">
        <rel:relatedItem rdf:resource=""/>

    For a XUL template query, you first need to select a starting point in the RDF graph. Once you have selected a starting point, you use a number of statements which indicate where to go next when navigating the graph. Eventually, you will end up with a set of nodes you consider the endpoints of your query. These become the results and content would be generated for each of these results. Say you start at A. You could navigate to B, C and D and generate three blocks of output. Or, you could start at D and follow two arrows back. This will get one result, A. Look at the graph to see if you can see why one result would be generated in this case.

    In XUL template terminology, the starting point is called the container or reference point and the endpoint is called the member. It is so called because it is most common to gather the list of the members, or children, of a container. But this doesn't have to be the case. Any starting point and ending points will do.

    Nodes in RDF are identified by a string value. There are two types of nodes in RDF, resources which usually represent 'things', and literals which are values like the names of things, the dates of things, the sizes of things, and so on. A literal's value is, for example, the name of the thing, such as 'Fred'. A resource's value is a URI which for your own RDF data you can just make up. We'll use the URI of the resource nodes in a template. In the image, the resource URI's are the blue labels of each node. There are no literals in this example, but we'll see some later.

    Let's say we want the starting point to be A from the above example graph. We will use A's URI ( as the reference starting point. In a XUL template, you specify the starting point using the 'ref' attribute. Here is an example:

    <vbox datasources=""
             ref="" flex="1">

    This is an indicator that we want to construct a XUL template using the reference point with the URI ''.

    Interwiki Language Links


    Contributors to this page: Mole, Mgjbot
    最終更新者: Mgjbot,