Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In this Appendix you will find the following samples:

If you notice any errors or omissions, or would like to see another sample in this appendix, please submit a request on the users list, or to islandora@upei.ca.

Custom QUERY Datastream

Here is a custom QUERY Datastream that returns objects that belong to a particular collection, and are set to a particular state (active)

Code Block
select $object $title from <#ri>
where ($object <dc:title> $title
and $object <fedora-model:hasModel> $content
and $object <fedora-rels-ext:isMemberOfCollection> <info:fedora/demo:special_collection>
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)
order by $title desc

Custom COLLECTION_VIEW Datastream

Here is a sample COLLECTION_VIEW Datastream that will render your content as a bulleted list.

Code Block
languagehtml/xml
<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>
        <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>

        </li>
      </xsl:for-each>
    </ul>
  </xsl:template>
</xsl:stylesheet>

Custom Request Handler

Here is a Custom Request Handler

Code Block
<requestHandler name="RefWorks Site"><\!-\- default values for query parameters →
<lst name="defaults">
<str name="echoParams">explicit</str>
<str name="qf">
dc.title^2.5 refworks.k1^1.5 refworks.a1^5.0 refworks.u2^5.0 refworks.u1^5.0 dc.contributor^5.0 dc.source^1.0 collection^2.0 PID^0.5
refworks.ab^2.0</str>
<str name="fl">

PID, refworks.a1, refworks.a2, refworks.ar, refworks.k1, refworks.ed, refworks.fd, refworks.jf, refworks.ab, refworks.no, refworks.is,

refworks.op, refworks.pp, refworks.pb, refworks.sp, refworks.rt, refworks.t1, refworks.t2, refworks.vo, refworks.yr</str>
<str name="q.alt">*:*</str></lst><lst name="appends"><str name="fq"> PID:cyct\* </str></lst>

</requestHandler>

XACML Policy (CHILD_SECURITY Datastream)

Code Block
<Policy xmlns="urn:oasis:names:tc:xacml:1.0:policy" PolicyId="ViewAndEditByUserOrRoleOnly" RuleCombiningAlgId="urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:first-applicable">

<Description>This is an object-specific policy.  It could be stored inside the digital object in the POLICY datastream OR in the directory for object-specific policies. (The directory location is set in the Authorization module configuration in the Fedora server configuration file (fedora.fcfg). By using multiple policy Rules, this policy shows how to deny access to all raw datastreams in the object except to particular users (e.g., the object owners).  It also shows how to deny access to a particular disseminations to selected user roles.</Description>
<Target>

<Subjects>
<AnySubject></AnySubject>
</Subjects>

<Resources>
<AnyResource></AnyResource>
</Resources>

<Actions>
<AnyAction></AnyAction>
</Actions>
</Target>

<Rule RuleId="denyapi-m-except-to-user" Effect="Deny">

<Condition FunctionId="urn:oasis:names:tc:xacml:1.0:function:not">
<Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:or">
<Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-at-least-one-member-of">
<SubjectAttributeDesignator AttributeId="fedoraRole" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"></SubjectAttributeDesignator>
<Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-bag">

<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">administrator</AttributeValue>

<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Any Drupal Role

</AttributeValue>
</Apply>
</Apply>
<Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-at-least-one-member-of">
<SubjectAttributeDesignator AttributeId="urn:fedora:names:fedora:2.1:subject:loginId" MustBePresent="false" DataType="http://www.w3.org/2001/XMLSchema#string"></SubjectAttributeDesignator>
<Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-bag">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">fedoraAdmin</AttributeValue>
</Apply>
</Apply>
</Apply>
</Condition>

</Rule>

<Rule RuleId="3" Effect="Permit"></Rule>

</Policy>

Sample XML Form Definition

Code Block
<definition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="./XMLFormDefinition.xsd">
<properties>
<document>

<root>
<local_name>root</local_name>
<prefix>prefix</prefix>
<uri>http://localhost/</uri>
</root>

<namespaces>
<namespace prefix="xsi">http://www.w3.org/2001/XMLSchema-instance</namespace>
<namespace prefix="xmlns">http://www.w3.org/2000/xmlns</namespace>
</namespaces>

<schema>http://localhost/schema/schema.xsd</schema>

</document>
</properties>

<form>
<properties>
<type>form</type>
<tree>true</tree>
</properties>

<children>
<element name="first">
<properties>
<title>first</title>
<type>fieldset</type>
<actions>
<create>
<path>/root/</path>
<context>document</context>
<schema>/xsd:schema/xsd:complexType\[@name='rootType'\]/xsd:sequence/xsd:element\[@ref='first'\]</schema>
<type>element</type>
<value>first</value>
</create>

<read>
<path>/root/first</path>
<context>document</context>
</read>
</actions>
</properties>

<children>
<element name="second">
<properties>
<title>second</title>
<type>textfield</type>
<actions>
<create>
<path>self::node()</path>
<context>parent</context>
<schema>/xsd:schema/xsd:complexType\[@name='rooType'\]/xsd:sequence/xsd:element\[@ref='second'\]</schema>
<type>element</type>
<value>second</value>
</create>

<read>
<path>second</path>
<context>parent</context>
</read>
</actions>
</properties>
</element>
</children>
</element>

<element name="submit">
<properties>
<type>submit</type>
<value>Submit</value>
</properties>
</element>
</children>
</form>
</definition>