TEI display plugin for Omeka

249 views
Skip to first unread message

Tim Gilbert

unread,
Nov 14, 2011, 1:44:01 AM11/14/11
to Omeka Dev, laure...@gmail.com
Hi all. I'm trying to help a friend out with getting the TEI plugin
for Omeka to render TEI as HTML and we've run into some problems; I'm
hoping someone here can help me out. I am a programmer familiar with
PHP, XML and XSL, but Omeka and TEI are both terra incognito for me,
so pardon me if my questions are a little naive.

Briefly, my friend has a series of poems encoded as TEI files; their
content looks roughly like the examples given on this page:

http://tbe.kantl.be/TBE/examples/TBED04v00.htm

What we are trying to do is get the files to appear rendered as HTML
in the user view of Omeka.

I've managed to validate that the input files are proper TEI using the
online validator here:

http://tbe.kantl.be/TBE/xquery/TBEvalidator.xq

I also managed to import the files, though it took me a while to
realize that I needed to to add an ID to the root element and use <TEI.
2> instead of <TEI> as the root element (incidentally, this breaks the
validator and I can't seem to find any reference to this root element
in the TEI documentation I've seen, but as I said I'm new to all
this). As of right now, the files are being imported correctly, the
plugin is picking up the title metadata from the file, and when I view
the metadata of the XML file attached to the item I'm trying to see,
it shows up as "TEI Document". With all this being the case, I'm
reasonably confident I've got the input side of the equation working
correctly.

When I look at the item which the imported TEI file is attached to as
a user, however (eg, at mysite.com/items/show/23) what I see is just a
short list of the Dublin Core metadata in the item, along with a link
to the TEI file (as raw XML), and nothing else. I was sort of
expecting to see some rendered output there. The page is pulling in
the tei_display_toggle_toc.js file (and the jquery files), but nothing
is rendered with class="toggle_toc" - I can see where these would be
generated by the XSL in default.xsl, but it doesn't seem to be getting
processed for some reason.

Is there something I'm missing here? For instance, do the rendered
files show up a a different URL from /items/show/<id>? I do see
entries for <lg> and <l> in the XSL source contained in the plugin,
and I've traced through the PHP to some degree, but I'm at a bit of a
loss right now.

Any help would be appreciated; I'm happy to provide more detail if
that helps. TIA,
Tim

Patrick Murray-John

unread,
Nov 14, 2011, 9:58:52 AM11/14/11
to omek...@googlegroups.com
Tim,

This was originally put together by the folks at Scholars' Lab, but I tried it out and have a couple possible ideas.

My first guess is that step 8 in their documentation is missing:
  1. Edit the item display for your theme in themes/[your theme]/items/show.php . Add the following code where you wish the TEI document to be serialized (e. g., under the titles and above show_item_metadata()):

<?php if (function_exists('tei_display_installed')){ echo render_tei_files($item->id, $_GET['section']); } ?>


But that wasn't the complete story for what I had to do to get it to work.

First, depending on the theme you are using, you might need to do some hunting to the file to edit. Usually, it will be /themes/{yourtheme}/items/show.php

However, some themes, like the default theme, do not have that file. It is basically inheriting from /application/views/scripts/items/show.php

So, to override things in Omeka, copy the /items/show.php directory and file from /application/views/scripts over into your theme, if it is not there already.

Then, usually you would edit /items/show.php to add in that code.

At least for me, this is where the second major bug happened -- render_tei_files isn't defined.

To get it to work for me, here's what I used instead.
<?php if (function_exists('tei_display_installed')){ echo render_tei_file($item->Files[0]->id, $_GET['section']); } ?>

instead of render_tei_files(), the function render_tei_file is there. It looks like the render_tei_files() function, when it exists, is intended to sort through the TEI files for the item before calling render_tei_file()

That explains why I have $item->Files[0]->id instead of $item->id. What I have here assumes that the first file associated with the Item is the TEI file you want. If that's not the case, it looks like you'd need to build that code.

Hope that helps!
Patrick

wayne....@gmail.com

unread,
Nov 14, 2011, 11:38:26 AM11/14/11
to omek...@googlegroups.com
Hi Tim,

I'll start off by saying that we developed the TEI plugin as a proof-of-concept to work with our (UVA's) collection of TEI documents. I think the first thing you noticed was that we have a large collection of TEI P4 documents, which required the TEI.2 (the .2 was removed in the latest P5 version of the spec). This is a big leap with the underlying structure, and can cause all kinds of issues if you're not careful.

Another issue is that this plugin has not been tested for Omeka > 1.3.2. While I don't believe there were any major changes that would affect the TEIPlugin, work on bringing the plugin up to the latest revision hasn't bubbled up.

That said, we do have this in the queue to refactor, but right now it looks like the time frame won't start until January. In the mean time, it would actually be good to have a document that we know is causing issues for our test suite. Would you mind sending me one (off list)?

Wayne


On , Tim Gilbert <timgi...@gmail.com> wrote:
> Hi all.  I'm trying to help a friend out with getting the TEI plugin
>
> for Omeka to render TEI as HTML and we've run into some problems; I'm
>
> hoping someone here can help me out.  I am a programmer familiar with
>
> PHP, XML and XSL, but Omeka and TEI are both terra incognito for me,
>
> so pardon me if my questions are a little naive.
>
>
>
> Briefly, my friend has a series of poems encoded as TEI files; their
>
> content looks roughly like the examples given on this page:
>
>
>
>    http://tbe.kantl.be/TBE/examples/TBED04v00.htm
>
>
>
> What we are trying to do is get the files to appear rendered as HTML
>
> in the user view of Omeka.
>
>
>
> I've managed to validate that the input files are proper TEI using the
>
> online validator here:
>
>
>
>    http://tbe.kantl.be/TBE/xquery/TBEvalidator.xq
>
>
>
> I also managed to import the files, though it took me a while to
>
> realize that I needed to to add an ID to the root element and use
> 2> instead of as the root element (incidentally, this breaks the

>
> validator and I can't seem to find any reference to this root element
>
> in the TEI documentation I've seen, but as I said I'm new to all
>
> this).  As of right now, the files are being imported correctly, the
>
> plugin is picking up the title metadata from the file, and when I view
>
> the metadata of the XML file attached to the item I'm trying to see,
>
> it shows up as "TEI Document".  With all this being the case, I'm
>
> reasonably confident I've got the input side of the equation working
>
> correctly.
>
>
>
> When I look at the item which the imported TEI file is attached to as
>
> a user, however (eg, at mysite.com/items/show/23) what I see is just a
>
> short list of the Dublin Core metadata in the item, along with a link
>
> to the TEI file (as raw XML), and nothing else.  I was sort of
>
> expecting to see some rendered output there.  The page is pulling in
>
> the tei_display_toggle_toc.js file (and the jquery files), but nothing
>
> is rendered with class="toggle_toc" - I can see where these would be
>
> generated by the XSL in default.xsl, but it doesn't seem to be getting
>
> processed for some reason.
>
>
>
> Is there something I'm missing here?  For instance, do the rendered
>
> files show up a a different URL from /items/show/?  I do see
>
> entries for and in the XSL source contained in the plugin,

>
> and I've traced through the PHP to some degree, but I'm at a bit of a
>
> loss right now.
>
>
>
> Any help would be appreciated; I'm happy to provide more detail if
>
> that helps.  TIA,
>
> Tim
>
>
>
> --
>
> You received this message because you are subscribed to the Google Groups "Omeka Dev" group.
>
> To post to this group, send email to omek...@googlegroups.com.
>
> To unsubscribe from this group, send email to omeka-dev+...@googlegroups.com.
>
> For more options, visit this group at http://groups.google.com/group/omeka-dev?hl=en.
>
>
>
>

Tim Gilbert

unread,
Nov 14, 2011, 2:18:56 PM11/14/11
to Omeka Dev
Hi Patrick, thanks for the reply. Indeed, it does look as though the
problem is that the various theme templates and output files didn't
have the logic added to them to trigger the plugin hooks. I'm not
certain my friend has shell access to the server to modify the
relevant bits of PHP, but your instructions look like they will be
very helpful one she gets it. I'll keep the list posted as to our
progress in case someone else has similar problems in the future.

Wayne, thanks for your response as well. I'll send you a sample
document off-list, but the main thing that was frustrating as a user
was that if the document was not successfully recognized as TEI, it
sort of silently failed and was uploaded as a plain XML file instead.
I'm not certain that Omeka's plugin architecture would make some sort
of feedback possible (and other users will need to upload non-TEI XML
files anyways). As a feature request for your eventual refactor,
though, it would be helpful if the plugin added a checkbox to the "add
files" page which, if checked, would only add the file if it was
recognized as valid TEI and otherwise fail with an error message. It
might even be handy to run a schema validator over the file as well,
though with the existing online tools that's not necessarily a crucial
step.

In the plugin documentation, an example input document and possibly a
screenshot of the file metadata display after a successful upload
would also be helpful.

Anyways, thanks again to you both and I'll keep you posted.

Tim

On Nov 14, 9:58 am, Patrick Murray-John <patrickmjc...@gmail.com>
wrote:
> Tim,
>
> This was originally put together by the folks at Scholars' Lab, but I
> tried it out and have a couple possible ideas.
>
> My first guess is that step 8 in their documentation is missing:
>
>  8.

Jacque Wernimont

unread,
Jun 28, 2012, 1:17:32 PM6/28/12
to omek...@googlegroups.com
Just wanted to say thanks to Patrick - the php fix is what has been holding me up for two days. Your revised line worked like magic.

Jacque

mandy gagel

unread,
Nov 5, 2012, 1:14:58 PM11/5/12
to omek...@googlegroups.com
Hello all,

I am at the point where I am uploading TEI documents to my site. So far, I have been successful with uploading a file...it is recognized as TEI and the configure tab has given me options and I have set it to "entire document" and "default:xsl"

The metadata was extracted and put into Dublin Core...but there is a lot I have to add myself..like because my TEI header wasn't the best to begin with? That is fine, I can add these things.

But, it is not displaying in html, etc...just the raw xml.

I have read some of the forums here that say that there is php script I have to insert in "themes" to make things happen. I am using the "seasons" default theme which doesn't give me any options to configure the way items are displayed, etc. Is this the problem? Can I still use this theme? Any step by step instructions would be helpful as this is all new to me!...

thanks!
Mandy

mandy gagel

unread,
Nov 5, 2012, 1:39:11 PM11/5/12
to omek...@googlegroups.com
Also,

As a follow up..

under "Item Type Metadata" for the TEI doc. I added,

There is no "TEI Doc" type listed. It just tells me to "select below"

is this also indicative of a problem?

thanks
Mandy

--
You received this message because you are subscribed to the Google Groups "Omeka Dev" group.
To view this discussion on the web visit https://groups.google.com/d/msg/omeka-dev/-/BtIP4g2ag_cJ.

Sue Hemmens

unread,
Nov 5, 2012, 1:42:37 PM11/5/12
to omek...@googlegroups.com
Hi Mandy

I'm sure someone will correct me if I'm wrong but I think Seasons is one of the older themes which needs the second fix described in the thread above.

You need to go digging in  youromekadir/application/views/scripts/items

then edit show.php to include the TEI stuff: the file I've attached works with Seasons, so if you like, just rename your show.php to show.old and stick my file in instead.

(be warned, there's another wrinkle, if you need to upload a new version of your TEI file, it won't be recognised if it has the same id as an existing file. There are various ways round this but the handiest one is just to delete the old item before uploading the new one.)

For the other part, mapping the TEI goodness to Dublin Core is a bit of a shoehorn operation. It's done in plugin.php.

my version is appended: you have to customise the mapping for your schema.

good luck!

Sue

-------------------------------
//map TEI to DC
//based on CDL encoding guidelines: http://www.cdlib.org/groups/stwg/META_BPG.html#d52e344
foreach ($dc as $name){
if ($name == 'Title'){
$queries = array('//*[local-name() = "teiHeader"]/*[local-name() = "fileDesc"]/*[local-name() = "titleStmt"]/*[local-name() = "title"]');

}elseif ($name == 'Creator'){
$queries = array('//*[local-name()="teiHeader"]/*[local-name()="fileDesc"]/*[local-name()="titleStmt"]/*[local-name()="author"]');
} elseif ($name == 'Subject'){
$queries = array( '//*[local-name()="teiHeader"]/*[local-name()="profileDesc"]/*[local-name()="textClass"]/*[local-name()="keywords"]/*[local-name()="list"]/*[local-name()="item"]');
} elseif ($name == 'Description'){
$queries = array( '//*[local-name()="teiHeader"]/*[local-name()="encodingDesc"]/*[local-name()="classDecl"]/*[local-name()="taxonomy"]/*[local-name()="category"]/*[local-name()="catDesc"]/*[local-name()="rs"]');
} elseif ($name == 'Publisher'){
$queries = array('//*[local-name()="teiHeader"]/*[local-name()="fileDesc"]/*[local-name()="publicationStmt"]/*[local-name()="publisher"]',
'//*[local-name()="teiHeader"]/*[local-name()="fileDesc"]/*[local-name()="publicationStmt"]/*[local-name()="date"]');
} elseif ($name == 'Contributor'){
$queries = array( '//*[local-name()="teiHeader"]/*[local-name()="fileDesc"]/*[local-name()="titleStmt"]/*[local-name()="respStmt"]');
} elseif ($name == 'Date'){
$queries = array( '//*[local-name()="teiHeader"]/*[local-name()="fileDesc"]/*[local-name()="titleStmt"]/*[local-name()="title"]/*[local-name()="date"]/@when'); 

} elseif ($name == 'Rights'){
//type, defined with Item Type Metadata dropdown
$queries = array('//*[local-name()="teiHeader"]/*[local-name()="fileDesc"]/*[local-name()="publicationStmt"]/*[local-name()="availability"]');
} elseif ($name == 'Identifier'){
$queries = array( '//*[local-name()="teiHeader"]/*[local-name()="encodingDesc"]/*[local-name()="classDecl"]/*[local-name()="taxonomy"]/*[local-name()="category"]/*[local-name()="catDesc"]/*[local-name()="rs"]/@xml:id');
} elseif ($name == 'Source'){
$queries = array('//*[local-name()="teiHeader"]/*[local-name()="fileDesc"]/*[local-name()="sourceDesc"]');
} elseif ($name == 'Language'){
$queries = array('//*[local-name()="teiHeader"]/*[local-name()="profileDesc"]/*[local-name()="langUsage"]/*[local-name()="language"]');
 
} elseif ($name == 'Type'){
//type, defined with Item Type Metadata dropdown
$queries = array();
} elseif ($name == 'Relation'){
//type, defined with Item Type Metadata dropdown
$queries = array();
} elseif ($name == 'Format'){
//type, defined with Item Type Metadata dropdown
$queries = array();}
 elseif ($name == 'Coverage'){
//type, defined with Item Type Metadata dropdown
$queries = array();}










--
You received this message because you are subscribed to the Google Groups "Omeka Dev" group.
show.php

mandy gagel

unread,
Nov 5, 2012, 1:45:52 PM11/5/12
to omek...@googlegroups.com
Hello,

THank you so much Sue...

I can try some of this, I think.

But now of course I have switched to the Rhythm theme, which just works better for my content, but I think it still needs the new script you sent me?

Also, as I have just written, the "TEI doc" doesn't pop up in my Item Type box??

mandy

Sue Hemmens

unread,
Nov 5, 2012, 1:49:01 PM11/5/12
to omek...@googlegroups.com
Yep, it never worked for me, I'm sure it's something simple (=stupid on my part) but I never bothered to fix it. It would only matter if you wanted to do something with the items based on item type.

Sue Hemmens

unread,
Nov 5, 2012, 1:54:26 PM11/5/12
to omek...@googlegroups.com
And Rhythm is 'new style' and has its own items directory.

So just pop the <?php if (function_exists('tei_display_installed')){ echo render_tei_files($item->id, $_GET['section']); } ?> into show.php in that dir.

just before <?php echo custom_show_item_metadata(); ?> works for me

Wayne Graham

unread,
Nov 5, 2012, 3:34:22 PM11/5/12
to omek...@googlegroups.com
Just wanted to give you all a heads up that there is an major revision
of the code base currently going on which addresses several os these
issues. If you're brave, and want to try it out, check out the the
feature/new branch of https://github.com/scholarslab/TeiDisplay/. You
will need Omeka 2.0 (master branch off of
https://github.com/omeka/omeka), but there has been quite a bit of
work put in on the new version.

Wayne

/**
* @author Wayne Graham
* @link http://www.liquidfoot.com
*/

Sue Hemmens

unread,
Nov 5, 2012, 3:39:22 PM11/5/12
to omek...@googlegroups.com
Aha...

Thanks! I was just about to bite the Omeka 2.0 bullet, this gives me another incentive!

(You haven't by any remote chance done that 'construct an element set from the schema' thing I've been fantasising about?? :) )

Wayne Graham

unread,
Nov 5, 2012, 8:19:24 PM11/5/12
to omek...@googlegroups.com
That's a little beyond the scope of the TEIDisplay plugin, but I did
write something like that for the VRACore element set
(https://github.com/scholarslab/VraCoreElementSet/blob/feature/1.5/VraCoreElementSet.php#L231).
Depending on how you have the schema, you would need to convert it a
bit differently to get the rules correct, but it should be relatively
straight forward.

Wayne

/**
* @author Wayne Graham
* @link http://www.liquidfoot.com
*/


Reply all
Reply to author
Forward
0 new messages