Page tree

Old Release

This documentation covers an old version of Fedora. Looking for another version? See all documentation.

Skip to end of metadata
Go to start of metadata

Indexing transformations are stored in the repository in a well-known location.  Default transformations are inserted into the repository the first time any access is made against the Fedora 4 transformation endpoint.  Currently transformations using LDPath are supported.

Transformation locations

In order for LDPath transformations to be accessed by name, they must be stored in the repository according to the following rules:

  • they must be stored as content at the path /fedora:system/fedora:transform/fedora:ldpath/[transformation name]/[type or mixintype]
  • they should not have the name "default" as that is reserved for a default transformation

Load a custom ldpath transformation program

The following is an example of loading a LDPath program called "custom".

curl -X PUT -H "Content-Type: application/rdf+ldpath" --data-binary "@post.txt" "http://localhost:8080/rest/fedora:system/fedora:transform/fedora:ldpath/custom/fedora:Container"

post.txt:
@prefix fcrepo : <http://fedora.info/definitions/v4/repository#>
id      = . :: xsd:string ;
title_tsi = dc:title :: xsd:string;

Transform REST API Documentation

 Click here to expand...

 

Request URI:  /fcr:transform/{program}

Methods: GET, POST

GET get a resource transformed with the default transform

Request Headers:

Example:

default transform
@prefix fedora : <http://fedora.info/definitions/v4/repository#>
id      = . :: xsd:string ;
title = dc:title :: xsd:string;
uuid = fedora:uuid :: xsd:string ; 


curl "http://localhost:8080/rest/49/3d/24/41/493d2441-0541-41c7-a23b-09d1f17d4a0f/fcr:transform/default"

Response:

Status: 200 OK

Headers:

Content-Type: application/json
Transfer-Encoding: chunked
Server: Jetty(8.1.11.v20130520)

Body:

[{"id":["http://localhost:8080/rest/49/3d/24/41/493d2441-0541-41c7-a23b-09d1f17d4a0f"],"title":[],"uuid":["07630a24-5a0b-4ba7-80ab-0691f68667ce"]}]

Status:

200 OK: if the transform is applied successfully

400 Bad Request: if the program doesn't exist

404 Not Found: if the resource doesn't exist

Note

To reference a stored "program" in the GET form of the fcr:transform service, the LDPath transformation directive must be stored at the following path:

http://localhost:8080/rest/fedora:system/fedora:transform/fedora:ldpath/<program-name>/<resource-type>

Where <program-name> can be any name, and <resource-type> is the type of Fedora resource on which the transform will be applied:

  • "fedora:Container"
  • "fedora:nonRdfSourceDescription"
  • "fedora:Resource"

Example:

  1. Store a new program.
curl -i -X PUT -H "Content-Type: application/rdf+ldpath" --data-binary "@post.txt" http://localhost:8080/rest/fedora:system/fedora:transform/fedora:ldpath/newprogram/fedora:Container

Response

Status 201 Created
 
Headers:
Content-Type: text/plain
 
http://localhost:8080/rest/fedora:system/fedora:transform/fedora:ldpath/newprogram/fedora:Container

2. Get a resource transformed with the stored transform

curl -i http://localhost:8080/rest/pid5/fcr:transform/newprogram

Response

Status 200 OK


Header:
Server: Apache-Coyote/1.1
Content-Type: application/json
 
Body:
[{"id":["http://localhost:8080/rest/pid5"],"title":["some-resource-title"],"description":[],"uuid":["caa7bc6c-b80b-4e30-8ec1-15e90937e3be"]}]

 


POST get a resource transformed with the supplied transform

 

Output formats: application/json,text/tab-separated-values,text/csv,text/sse,text/plain,application/sparql-results+json,application/sparql-results+xml,application/sparql-results+bio,text/turtle,text/rdf+n3,application/N-triples,application/rdf_xml

Example:

curl -X POST -H "Content-Type: application/rdf+ldpath" --data-binary "@post.txt" "http://localhost:8080/rest/49/3d/24/41/493d2441-0541-41c7-a23b-09d1f17d4a0f/fcr:transform"

Body:
@prefix fcrepo : <http://fedora.info/definitions/v4/repository#>
id      = . :: xsd:string ;
title = dc:title :: xsd:string;
uuid = fcrepo:uuid :: xsd:string ;

Response:

Status: 200 OK

Headers:

Content-Type: application/json
Transfer-Encoding: chunked
Server: Jetty(8.1.11.v20130520)

Body:

[{"id":["http://localhost:8080/rest/49/3d/24/41/493d2441-0541-41c7-a23b-09d1f17d4a0f"],"title":[],"uuid":["07630a24-5a0b-4ba7-80ab-0691f68667ce"]}]

Status:

200 OK: if the transform is applied successfully

400 Bad Request: if there was an error parsing or processing the transform

404 Not Found: if the resources doesn't exist

  • No labels

2 Comments

  1. Are all LDPath selectors supported as of 4.5.1? Or do we need  FCREPO-2070 - Getting issue details... STATUS  for full support?

    I tried using the LDPath TEST syntax to select RDF objects described by predicate pcdm:hasMember and is of type pcdm:File but it did not work.

    @prefix pcdm : <http://pcdm.org/models#>
    has_member = pcdm:hasMember :: xsd:string;
    has_member_pcdm_file = pcdm:hasMember[^^pcdm:File] :: xsd:string;
    has_member_pcdm_file_alt = pcdm:hasMember[rdf:type is pcdm:File] :: xsd:string;

    In the transformation response json, has_member has the correct value, but the has_member_pcdm_file and the has_member_pcdm_file are empty.

    Am I missing something here?

    1. Mohamed Mohideen Abdul Rasheed, Indeed, you will need to wait for the completion of  FCREPO-2070 - Getting issue details... STATUS , which will be available soon.

      I suspect you will be delighted to see the functionality it offers. 

      Regarding your example LDPath program, everything should work except has_member_pcdm_file. 

      The LDPath syntax for [^^xsdtype] appears to mean exactly that: xsd types. The following program works for all defined fields:

      @prefix pcdm : <http://pcdm.org/models#>
      @prefix fedora: <http://fedora.info/definitions/v4/repository#>
      
      member_created = pcdm:hasMember/fedora:created[^^xsd:dateTime] :: xsd:string;
      created = fedora:created[^^xsd:dateTime] :: xsd:string;