Skip to content
jessicagutierrez edited this page Mar 2, 2014 · 3 revisions

Cases

Case 1: Count

This case count the number of appearances of the elements in xpath query.

Template

Template definition:

   <select>
       <title>Number of resources:</title>
       <action do="count">/ags:resources/ags:resource</action>
   </select>

This case indicates that it will count all the 'resource' elements.

Results

Execution time for 1000 XML is 450 seconds.

Output

  <select>
    <title>Number of resources:</title>
    <action>/ags:resources/ags:resource</action>
    <results>115041</results>
  </select>

Case 2: Count Existences

This case count if the element indicates into the xpath element exists or not. If exists adds one to the final count otherwise it continues with the next element.

Template

Template definition:

   <select>
       <title>Existence of keywords in Engligh in every resource.</title>
       <action do="count" option = "existences" element = "/ags:resources/ags:resource/dc:subject/ags:subjectThesaurus[@xml:lang = 'en']">/ags:resources/ags:resource</action>
   </select>

The following example count if there are keywords in English, indicated in element attribute, inside resource element. For each resource finds if there are any keyword in English.

Results

Execution time for 1000 XML is 443 seconds.

###Output

  <select>
    <title>Existence of keywords in Engligh in every resource.</title>
    <action>/ags:resources/ags:resource</action>
    <results>115041</results>
  </select>

Case 3: Value is URI

This case checks if the value of the element is an URI.

Template

Template definition:

     <select>
       <title>Value is an uri</title>
       <action do="count" special="valueisuri">/ags:resources/ags:resource/dc:subject/ags:subjectThesaurus</action>
   </select>

This example is looking for every element in subjectThesaurus which value is an URI.

Results

Execution time for 1000 XML is 706 seconds.

Output

  <select>
    <title>Value is an uri</title>
    <action>/ags:resources/ags:resource/dc:subject/ags:subjectThesaurus</action>
    <results>82388</results>
  </select>

The result is that the total number of elements 82388 from structure subjectThesaurus have a value of a URI. In this case, the runtime has been higher than the rest because it had to analyze the items one by one to check and see if its contents contain a URI.

Case 4: Mean

This case calculates the mean onset of elements placed on the action element. The total number of elements on which the average is to be made is in the attribute n.

Template

Template definition:

   <select>
       <title>Mean</title>
       <action do="mean" n="/ags:resources/ags:resource">/ags:resources/ags:resource/dc:subject/ags:subjectThesaurus[@xml:lang = 'en']</action>
   </select>

In the definition of the select case mean, we see that element n is the total number of resources, in this case Agris, and the action element indicates that you want to find the keywords that have the xml: English lang. Therefore this case is defined as taking the average occurrence of keywords in English there in total resources (indicated in parameter n).

Results

Execution time for 1000 XML is 676 seconds.

Output

    <select>
    <title>Mean</title>
    <action>/ags:resources/ags:resource/dc:subject/ags:subjectThesaurus[@xml:lang = 'en']</action>
    <results>1.0</results>
  </select>

The result indicates the average of English keywords per resource, in this example is 1 keyword.

Case 5: List

This case creates a list with the results obtained through xpath query.

Template

Template definition:

   <select>
       <action do="list" separator="" option="lowcase">/ags:resources/ags:resource/dc:subject/ags:subjectThesaurus[@xml:lang = 'en']</action>
   </select>

In this list case the query indicates that want to list all the values ​​from the elements set into the xpath query. In this example all the keywords in English.

Results

Execution time for 1000 XML is 503 seconds.

Output

    <select>
<action>/ags:resources/ags:resource/dc:subject/ags:subjectThesaurus[@xml:lang = 'en']</action>
    <value>flax</value>
    <value>hive management</value>
    <value>water supply</value>
    <value>barns</value>
    <value>domestication</value>
    <value>gryllidae</value>
    <value>mycoplasma gallisepticum</value>
    <value>asteraceae</value>
    <value>pteridium aquilinum</value>
    <value>lead</value>
    <value>organizations</value>
    <value>tachinidae</value>
    <value>gentiana</value>
    <value>dolycoris</value>
    <value>furoviruses</value>
    <value>weed control</value>
    <value>clay minerals</value>
    <value>cap</value>  </select>

Case 6: Frequencies

This case takes out the frequency of occurrence of the elements to be found by xpath statement.

Template

Template definition:

   <select>
       <action do="frequencies">/ags:resources/ags:resource/dc:subject/ags:subjectThesaurus[@xml:lang = 'en']</action>
   </select>

This query calculates the frequency of occurrences (in percent) of all keywords in English on the xml sample analyzed.

Results

Execution time for 1000 XML is 641 seconds.

Output

    <result>
   <value frequency="0.010541999325312043">flax</value>
    <value frequency="7.027999550208028E-4">hive management</value>
    <value frequency="0.04005959743618576">water supply</value>
    <value frequency="0.002108399865062409">barns</value>
    <value frequency="0.00491959968514562">domestication</value>
    <value frequency="7.027999550208028E-4">gryllidae</value>
    <value frequency="0.002108399865062409">mycoplasma gallisepticum</value>
    <value frequency="0.01194759923535365">asteraceae</value>
    <value frequency="0.0014055999100416057">pteridium aquilinum</value>
    <value frequency="0.03513999775104014">lead</value>
    <value frequency="0.00983919937029124">organizations</value>
    </result>

Case 7: Classify

This case classify elements by one or more criteria. The criteria is indicated in the by attribute, it could have one or more criteria.

Template

Template definition:

   <select>
       <action do="classify" option="lowcase" by="/ags:resources/ags:resource/dc:date/dcterms:dateIssued,/ags:resources/ags:resource/dc:type">/ags:resources/ags:resource/dc:subject/ags:subjectThesaurus[@xml:lang = 'en']</action>

This case is looking for all the keywords in English classified by date and type of document.

Results

Execution time for 1000 XML is 503 seconds.

Output

    <result>
      <key>2005,Field Document,</key>
      <value>LANDSCAPE CONSERVATION</value>
      <value>ORGANIC FOODS</value>
      <value>ORGANIC AGRICULTURE</value>
      <value>LAND USE PLANNING</value>
      <value>BIOPRODUCTS</value>
      <value>SOCIAL FORESTRY</value>
      <value>DEVELOPMENT PROJECTS</value>
      <value>RURAL POPULATION</value>
      <value>ALTERNATIVE AGRICULTURE</value>
      <value>RESOURCE MANAGEMENT</value>
      <value>SOCIOECONOMIC DEVELOPMENT</value>
      <value>FOREST MANAGEMENT</value>
      <value>WORLD MARKETS</value>
      <value>HUMAN FEEDING</value>
      <value>TRADITIONAL FARMING</value>
      <value>REFORESTATION</value>
      <value>RURAL AREAS</value>
      <value>LAND RESOURCES</value>
      <value>FOREST PROTECTION</value>
      <value>FORESTRY OPERATIONS</value>
      <value>FOREST REHABILITATION</value>
      <value>INTERNATIONAL TRADE</value>
    </result>

Case 8: ClassifiedCount

This case classify elements by one or more criteria. The criteria is indicated in the by attribute, it could have one or more criteria. The elements for each classification aren't repeated.

Template

Template definition:

   <select>
       <action do="classify" option="lowcase" by="/ags:resources/ags:resource/dc:date/dcterms:dateIssued,/ags:resources/ags:resource/dc:type">/ags:resources/ags:resource/dc:subject/ags:subjectThesaurus[@xml:lang = 'en']</action>

This case is looking for all the keywords in English classified by date and type of document. The keywords aren't repeated.

Results

Execution time for 1000 XML is 503 seconds.

Output:

    <result>
      <key>2005,Field Document,</key>
      <value>LANDSCAPE CONSERVATION</value>
      <value>ORGANIC FOODS</value>
      <value>ORGANIC AGRICULTURE</value>
      <value>LAND USE PLANNING</value>
      <value>BIOPRODUCTS</value>
      <value>SOCIAL FORESTRY</value>
      <value>DEVELOPMENT PROJECTS</value>
      <value>RURAL POPULATION</value>
      <value>ALTERNATIVE AGRICULTURE</value>
      <value>RESOURCE MANAGEMENT</value>
      <value>SOCIOECONOMIC DEVELOPMENT</value>
      <value>FOREST MANAGEMENT</value>
      <value>WORLD MARKETS</value>
      <value>HUMAN FEEDING</value>
      <value>TRADITIONAL FARMING</value>
      <value>REFORESTATION</value>
      <value>RURAL AREAS</value>
      <value>LAND RESOURCES</value>
      <value>FOREST PROTECTION</value>
      <value>FORESTRY OPERATIONS</value>
      <value>FOREST REHABILITATION</value>
      <value>INTERNATIONAL TRADE</value>
    </result>