This is an old revision of the document!


Collection object for custom query and view

  • Create Islandora standard collectionCModel object (islandora:collectionCModel).
  • Add custom query in datastream QUERY
  • Add custom view in datastream COLLECTION_VIEW
  • Link repository object to drupal menu item



Example:

List all collections of books (not collections of collections) and count total pages and books

  • DSID QUERY
select $object $title $memberofd
count(select $libri from <#ri>
where $libri <fedora-rels-ext:isMemberOfCollection> $object
)
count(select $pagine from <#ri>
where $pagine <fedora-rels-ext:isMemberOf> $member3
)
from <#ri>
where walk($object <fedora-rels-ext:isMemberOfCollection> <info:fedora/islandora:root>
and $member3 <fedora-rels-ext:isMemberOfCollection> $object)
and $member3 <fedora-model:hasModel> <info:fedora/islandora:bookCModel>
and $object <dc:title> $title
and $object <fedora-rels-ext:isMemberOfCollection> $memberof
and $memberof <dc:title> $memberofd
order by $memberofd $title
  • DSID QUERYCOLLECTION_VIEW
<xsl:stylesheet xmlns:s="http://www.w3.org/2001/sw/DataAccess/rf1/result" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:template match="/">
    <xsl:variable name="BASEURL">
      <xsl:value-of select="$baseUrl"></xsl:value-of>
    </xsl:variable>
    <ul>
      <xsl:for-each select="/s:sparql/s:results/s:result">
        <xsl:variable name="pid" select="substring-after(s:object/@uri,&apos;/&apos;)"></xsl:variable>
        <xsl:variable name="npage" select="s:k1"></xsl:variable>
        <li>
          <a>
            <xsl:attribute name="href">
              <xsl:value-of select="$BASEURL"></xsl:value-of>
              <xsl:text>/fedora/repository/</xsl:text>
              <xsl:value-of select="$pid"></xsl:value-of>/-/ <xsl:value-of select="$pid"></xsl:value-of>
            </xsl:attribute>
            <xsl:value-of select="s:title"></xsl:value-of>
          </a> (<xsl:value-of select="s:memberofd"></xsl:value-of>) [<xsl:value-of select="s:k0"></xsl:value-of>]
        </li>
      </xsl:for-each>
    </ul>
    <em>Repository contains <b>
        <xsl:value-of select="/s:sparql/s:results/s:result/s:k1"></xsl:value-of>
      </b> pages.</em>
  </xsl:template>
</xsl:stylesheet>

List all parents of collections of books and count total pages and books

  • DSID QUERY
select $memberof $title
count(select $member3 from <#ri>
where walk($object <fedora-rels-ext:isMemberOfCollection> <info:fedora/islandora:root>
and $member3 <fedora-rels-ext:isMemberOfCollection> $object)
and $member3 <fedora-model:hasModel> <info:fedora/islandora:bookCModel>
and $object <fedora-rels-ext:isMemberOfCollection> $memberof)
count(select $pagine from <#ri>
where $pagine <fedora-rels-ext:isMemberOf> $member3
)
from <#ri>
where walk($object <fedora-rels-ext:isMemberOfCollection> <info:fedora/islandora:root>
and $member3 <fedora-rels-ext:isMemberOfCollection> $object)
and $member3 <fedora-model:hasModel> <info:fedora/islandora:bookCModel>
and $object <fedora-rels-ext:isMemberOfCollection> $memberof
and $memberof <dc:title> $title
order by $title
  • DSID QUERYCOLLECTION_VIEW
<xsl:stylesheet xmlns:s="http://www.w3.org/2001/sw/DataAccess/rf1/result" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:template match="/">
    <xsl:variable name="BASEURL">
      <xsl:value-of select="$baseUrl"></xsl:value-of>
    </xsl:variable>
    <table class="tocnr_collection">
      <xsl:for-each select="/s:sparql/s:results/s:result">
        <xsl:variable name="pid" select="substring-after(s:memberof/@uri,&apos;/&apos;)"></xsl:variable>
        <xsl:variable name="npage" select="s:k1"></xsl:variable>
        <tr>
          <td class="label">
            <a>
              <xsl:attribute name="href">
                <xsl:value-of select="$BASEURL"></xsl:value-of>
                <xsl:text>/fedora/repository/</xsl:text>
                <xsl:value-of select="$pid"></xsl:value-of>/-/collection
              </xsl:attribute>
              <img>
                <xsl:attribute name="src">
                  <xsl:value-of select="$BASEURL"></xsl:value-of>
                  <xsl:text>/fedora/repository/</xsl:text>
                  <xsl:value-of select="$pid"></xsl:value-of>
                  <xsl:text>/TN</xsl:text>
                </xsl:attribute>
              </img>
            </a>
          </td>
          <td class="value">
            <b>
              <xsl:value-of select="s:title"></xsl:value-of>
            </b>
            <br></br>
            <br></br> [<xsl:value-of select="s:k0"></xsl:value-of> books]
            </td>
        </tr>
      </xsl:for-each>
    </table>
    <em>Repository contains <b>
        <xsl:value-of select="/s:sparql/s:results/s:result/s:k1"></xsl:value-of>
      </b> pages.</em>
  </xsl:template>
</xsl:stylesheet>

List all parents and collections of books and count total pages, books and collections

  • DSID QUERY
select $memberof $title $id1 $title1
count(select $member3 from <#ri>
where walk($object <fedora-rels-ext:isMemberOfCollection> <info:fedora/islandora:root>
and $member3 <fedora-rels-ext:isMemberOfCollection> $object)
and $member3 <fedora-model:hasModel> <info:fedora/islandora:bookCModel>
and $object <fedora-rels-ext:isMemberOfCollection> $memberof)
count(select $pagine from <#ri>
where $pagine <fedora-rels-ext:isMemberOf> $member3
)
count(select $child from <#ri>
where $child <fedora-rels-ext:isMemberOfCollection> $memberof
)
count(select $bchild from <#ri>
where $bchild <fedora-rels-ext:isMemberOfCollection> $member3
and $bchild <fedora-model:hasModel> <info:fedora/islandora:bookCModel>
)
count(select $object from <#ri>
where walk($object <fedora-rels-ext:isMemberOfCollection> <info:fedora/islandora:root>
and $member3 <fedora-rels-ext:isMemberOfCollection> $object)
and $member3 <fedora-model:hasModel> <info:fedora/islandora:bookCModel>
)
from <#ri>
where walk($object <fedora-rels-ext:isMemberOfCollection> <info:fedora/islandora:root>
and $member3 <fedora-rels-ext:isMemberOfCollection> $object)
and $member3 <fedora-model:hasModel> <info:fedora/islandora:bookCModel>
and $object <fedora-rels-ext:isMemberOfCollection> $memberof
and $memberof <dc:title> $title
and $object <dc:title> $title1
and $object <dc:identifier> $id1
order by $title $title1
  • DSID QUERYCOLLECTION_VIEW
<?xml version="1.0"?>
<xsl:stylesheet xmlns:s="http://www.w3.org/2001/sw/DataAccess/rf1/result" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:template match="/">
    <xsl:variable name="BASEURL">
      <xsl:value-of select="$baseUrl"/>
    </xsl:variable>
    <xsl:variable name="totcolle" select="count(/s:sparql/s:results/s:result)"/>
    <table class="tocnr_collection">
      <xsl:for-each select="/s:sparql/s:results/s:result">
        <xsl:variable name="pid" select="substring-after(s:memberof/@uri,'/')"/>
        <xsl:variable name="npage" select="s:k1"/>
        <xsl:variable name="posm" select="position()-1"/>
        <xsl:variable name="pidm" select="substring-after(/s:sparql/s:results/s:result[$posm]/s:memberof/@uri,'/')"/>
        <xsl:choose>
          <xsl:when test="$pid!=$pidm or $posm=0">
            <tr>
              <td class="label">
                <xsl:attribute name="rowspan">
                  <xsl:value-of select="2"/>
                </xsl:attribute>
                <a>
                  <xsl:attribute name="href"><xsl:value-of select="$BASEURL"/><xsl:text>/fedora/repository/</xsl:text><xsl:value-of select="$pid"/>/-/collection
		  </xsl:attribute>
                  <img>
                    <xsl:attribute name="src">
                      <xsl:value-of select="$BASEURL"/>
                      <xsl:text>/fedora/repository/</xsl:text>
                      <xsl:value-of select="$pid"/>
                      <xsl:text>/TN</xsl:text>
                    </xsl:attribute>
                  </img>
                </a>
              </td>
              <td class="value">
                <h3>
                  <xsl:value-of select="s:title"/>
                </h3>
                <xsl:choose>
                  <xsl:when test="s:k2=1 and s:k0=1">
[<xsl:value-of select="s:k2"/> collection / <xsl:value-of select="s:k0"/> book]
                </xsl:when>
                  <xsl:when test="s:k2&gt;1 and s:k0=1">
[<xsl:value-of select="s:k2"/> collections / <xsl:value-of select="s:k0"/> book]
                </xsl:when>
                  <xsl:when test="s:k2=1 and s:k0&gt;1">
[<xsl:value-of select="s:k2"/> collection / <xsl:value-of select="s:k0"/> books]
                </xsl:when>
                  <xsl:otherwise>
[<xsl:value-of select="s:k2"/> collections / <xsl:value-of select="s:k0"/> books]
                </xsl:otherwise>
                </xsl:choose>
              </td>
            </tr>
            <tr>
              <td class="value1">
                <xsl:call-template name="elecolle">
                  <xsl:with-param name="start" select="1"/>
                </xsl:call-template>
              </td>
            </tr>
          </xsl:when>
        </xsl:choose>
      </xsl:for-each>
    </table>
    <em>Repository contains <b><xsl:value-of select="/s:sparql/s:results/s:result/s:k1"/></b> pages, <b><xsl:value-of select="/s:sparql/s:results/s:result/s:k3"/></b> books, <b><xsl:value-of select="/s:sparql/s:results/s:result/s:k4"/></b> collections.
    </em>
  </xsl:template>
  <xsl:template name="elecolle">
    <xsl:param name="start"/>
    <xsl:variable name="indizero" select="position()"/>
    <xsl:variable name="indi" select="position() + $start -1"/>
    <xsl:variable name="pidzero" select="substring-after(/s:sparql/s:results/s:result[$indizero]/s:memberof/@uri,'/')"/>
    <xsl:variable name="pidindi" select="substring-after(/s:sparql/s:results/s:result[$indi]/s:memberof/@uri,'/')"/>
    <xsl:choose>
      <xsl:when test="$pidindi=$pidzero">
        <a>
          <xsl:attribute name="href"><xsl:value-of select="$baseUrl"/><xsl:text>/fedora/repository/</xsl:text><xsl:value-of select="/s:sparql/s:results/s:result[$indi]/s:id1"/>/-/collection
	  </xsl:attribute>
          <xsl:value-of select="/s:sparql/s:results/s:result[$indi]/s:title1"/>
        </a>
        <xsl:value-of select="' | '"/>
        <xsl:if test="$start != s:k2">
          <xsl:call-template name="elecolle">
            <xsl:with-param name="start" select="$start + 1"/>
          </xsl:call-template>
        </xsl:if>
      </xsl:when>
    </xsl:choose>
  </xsl:template>
</xsl:stylesheet>

Repository statistics

  • DSID QUERY
select $ordine $colle $titlecolle
count(
	select $object
	from <#ri>
	where walk($object <fedora-rels-ext:isMemberOfCollection> $colle
	and $libro <fedora-rels-ext:isMemberOfCollection> $object)
	and $pagine <fedora-rels-ext:isMemberOf> $libro)
count(
	select $libro
	from <#ri>
	where walk($object <fedora-rels-ext:isMemberOfCollection> $colle
	and $libro <fedora-rels-ext:isMemberOfCollection> $object)
	and $libro <fedora-model:hasModel> <info:fedora/islandora:bookCModel>)
count(
	select $pagine
	from <#ri>
	where walk($object <fedora-rels-ext:isMemberOfCollection> $colle
	and $libro <fedora-rels-ext:isMemberOfCollection> $object)
	and $pagine <fedora-rels-ext:isMemberOf> $libro)
from <#ri>
where ((($colle <fedora-rels-ext:isMemberOfCollection> <info:fedora/islandora:root>
minus
$colle <mulgara:is> <info:fedora/openbess:collezioni>)
and $ordine <mulgara:is> '3')
or ($colle <fedora-rels-ext:isMemberOfCollection> <info:fedora/openbess:collezioni>
and $ordine <mulgara:is> '2')
or ($colle <mulgara:is> <info:fedora/islandora:root>
and $ordine <mulgara:is> '1'))
and $colle <dc:title> $titlecolle
order by $ordine $titlecolle
  • DSID QUERYCOLLECTION_VIEW
 
 
 
model/customcoll.1357836557.txt.gz ยท Last modified: 2013/01/10 17:49 by giancarlo

Developers: CNR IRCrES IT Office and Library
Giancarlo Birello (giancarlo.birello _@_ ircres.cnr.it) and Anna Perin (anna.perin _@_ ircres.cnr.it)
DigiBess is licensed under: Creative Commons License
Recent changes RSS feed Creative Commons License Valid XHTML 1.0 Valid CSS Driven by DokuWiki
Drupal Garland Theme for Dokuwiki