{"id":107,"date":"2008-01-09T16:33:15","date_gmt":"2008-01-09T21:33:15","guid":{"rendered":"http:\/\/dilettantes.code4lib.org\/2008\/01\/09\/objectifying-openurl\/"},"modified":"2008-01-09T16:33:15","modified_gmt":"2008-01-09T21:33:15","slug":"objectifying-openurl","status":"publish","type":"post","link":"https:\/\/rossfsinger.me\/blog\/2008\/01\/objectifying-openurl\/","title":{"rendered":"Objectifying OpenURL"},"content":{"rendered":"<p>Sometime in November, I came to the realization that I had horribly misinterpreted the NISO Z39.88\/OpenURL 1.0 spec.&nbsp; I&#8217;m on the NISO Advisory Committee for OpenURL (which makes this even more embarrassing) and was reviewing the proposal for the <a href=\"http:\/\/\">Request Transfer Message<\/a> Community Profile and its associated metadata formats when it dawned on me that my mental model was completely wrong.&nbsp; For those of you that have primarily dealt with <abbr title=\"Key Encoded Value\">KEV<\/abbr> based OpenURLs (which is 99% of all the OpenURLs in the wild), I would wager that your mental model is probably wrong, too.<\/p>\n<p>A quick primer on OpenURL:<\/p>\n<ul>\n<li>OpenURL is a standard for transporting <span style=\"font-style: italic;\">ContextObjects<\/span> (basically a reference to something, in practice, mostly bibliographic citations)<\/li>\n<li>A ContextObject (CTX, for short from now on) is comprised of <span style=\"font-style: italic;\">Entities<\/span> that help define what it is.&nbsp; Entities can be one of six kinds:<\/li>\n<ul>\n<li><span style=\"font-weight: bold;\">Referent<\/span> &#8211; this is the meat of the CTX, what it&#8217;s about, what you&#8217;re trying to get context about.&nbsp; A CTX <span style=\"font-style: italic;\">must<\/span> have one referent and only one.\n<\/li>\n<li><span style=\"font-weight: bold;\">ReferringEntity<span style=\"font-style: italic;\"> &#8211; <\/span><\/span>defines the resource that cited the referent.&nbsp; This is optional and can only appear once.<\/li>\n<li><span style=\"font-weight: bold;\">Referrer<\/span> &#8211; the source of where the CTX came from (i.e. the A&amp;I database).&nbsp; This is optional and can only appear once.<\/li>\n<li><span style=\"font-weight: bold;\">Requester<\/span> &#8211; this is information about who is making the request (i.e. the user&#8217;s IP address).&nbsp; This is optional and can only appear once.<\/li>\n<li><span style=\"font-weight: bold;\">ServiceType<\/span> &#8211; this defines what sorts of services are being requested about the referent (i.e. getFullText, document delivery services, etc.).&nbsp; There can be zero or many ServiceType entities defined in the CTX.\n<\/li>\n<li><span style=\"font-weight: bold;\">Resolver<span style=\"font-style: italic;\"> &#8211;<\/span><\/span> these are messages specifically to the resolver about the request.&nbsp; There can be zero or more Resolver entities defined in the CTX.<\/li>\n<\/ul>\n<li>All entities are basically the same in what they can hold:<\/li>\n<ul>\n<li>Identifiers (such as DOI or IP Address)<\/li>\n<li>By-Value Metadata (the metadata is included in the Entity)<\/li>\n<li>By-Reference Metadata (the Entity has a pointer to a URL where you can retrieve the metadata, rather than including it in the CTX itself)<\/li>\n<li>Private Data (presumably data, possibly confidential, between the entity and the resolver)\n<\/li>\n<\/ul>\n<li>A CTX can also contain administrative data, which defines the version of the ContextObject, a timestamp and an identifier for the CTX (all optional)<\/li>\n<li>Community Profiles define valid configurations and constraints for a given use case (for instance, scholarly search services are defined differently than document delivery).&nbsp; Context objects don&#8217;t actually specify any community profile they conform to.&nbsp; This is a rather loose agreement between the resolver and the context object source:&nbsp;&nbsp; <span style=\"font-style: italic;\">if you provide me with a <a href=\"http:\/\/alcme.oclc.org\/openurl\/servlet\/OAIHandler?verb=GetRecord&amp;metadataPrefix=oai_dc&amp;identifier=info:ofi\/pro:sap1-2004\">SAP1<\/a>, <a href=\"http:\/\/alcme.oclc.org\/openurl\/servlet\/OAIHandler?verb=GetRecord&amp;metadataPrefix=oai_dc&amp;identifier=info:ofi\/pro:sap2-2004\">SAP2<\/a> or <a href=\"http:\/\/alcme.oclc.org\/openurl\/servlet\/OAIHandler?verb=GetRecord&amp;metadataPrefix=oai_dc&amp;identifier=info:ofi\/pro:dccp-2004\">Dublin Core<\/a> compliant OpenURL, I can return something sensible<\/span>.<\/li>\n<li>There are currently two registered serializations for OpenURL:&nbsp; Key\/Encoded Values where all of the values are output on a single string, formatted as key=value and delimited by ampersands (this is what majority of all OpenURLs that currently exist look like) and XML (which is much rarer, but also much more powerful)<\/li>\n<li>There is no standard OpenURL &#8216;response&#8217; format.&nbsp; Given the nature of OpenURL, it&#8217;s highly unlikely that one could be created that would meet all expected needs.&nbsp; A better alternative would be for a particular community profile to define a response format since the scope would be more realistic and focused.<\/li>\n<\/ul>\n<p>Looking back on this, I&#8217;m not sure how &#8220;quick&#8221; this is, but hopefully it can bootstrap those of you that have only cursory knowledge of OpenURL (or less).&nbsp; Another interesting way to look at OpenURL is <a href=\"http:\/\/q6.oclc.org\/openurl\/\">Jeff Young&#8217;s 6 questions<\/a> approach, which breaks OpenURL down to &#8220;who&#8221;, &#8220;what&#8221;, &#8220;where&#8221;, &#8220;when&#8221;, &#8220;why&#8221; and &#8220;how&#8221;.<\/p>\n<p>One of the great failings of OpenURL (in my mind, at least) is the complete and utter lack of documentation, examples, dialog or tutorials about its use or potential.&nbsp; In fact, outside of <a href=\"http:\/\/ocoins.info\/\">COinS<\/a>, maybe, there is no notion of &#8220;community&#8221; to help promote OpenURL or cultivate awareness or adoption.&nbsp; To be fair, I am as guilty as anybody for this failure, since I had proposed making a community site for OpenURL, but due to a shift in job responsibilities and then the wholesale change in employers, coupled with the hacking of the server it was to live on, left this by the wayside.&nbsp; I&#8217;m putting this back on my to do list.<\/p>\n<p>What this lack of direction leads to is that would-be implementors wind up making a lot of assumptions about OpenURL.&nbsp; The official spec published at NISO is a tough read and is generally  discouraged by the &#8220;inner core&#8221; of the OpenURL universe (the Herbert van de Sompels, the Eric Hellmans, the Karen Coyles, etc.) in favor of the &#8220;<a href=\"http:\/\/alcme.oclc.org\/openurl\/docs\/implementation_guidelines\/\">Implementation Guidelines<\/a>&#8221; documents.&nbsp; However, only the KEV Guidelines are actually posted there.&nbsp; The only other real avenue for trying to come to grips with OpenURL is to dissect the behavior of link resolvers.&nbsp; Again, in almost every instance this means you&#8217;re working with KEVs and the downside of KEVs is that they give you a very naive view of OpenURL.<\/p>\n<p>KEVs, by their very nature, are flat and expose next to nothing about the structure of the model of the context object they represent.&nbsp; Take the following, for example:<\/p>\n<div style=\"margin-left: 40px;\">url_ver=Z39.88-2004&amp;url_tim=2003-04-11T10%3A09%3A15TZD<br \/>\n&amp;url_ctx_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Actx&amp;ctx_ver=Z39.88-2004<br \/>\n&amp;ctx_enc=info%3Aofi%2Fenc%3AUTF-8&amp;ctx_id=10_8&amp;ctx_tim=2003-04-11T10%3A08%3A30TZD<br \/>\n&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.aulast=Vergnaud<br \/>\n&amp;rft.auinit=J.-R&amp;rft.btitle=D%C3%A9pendances+et+niveaux+de+repr%C3%A9sentation+en+syntaxe<br \/>\n&amp;rft.date=1985&amp;rft.pub=Benjamins&amp;rft.place=Amsterdam%2C+Philadelphia<br \/>\n&amp;rfe_id=urn%3Aisbn%3A0262531283&amp;rfe_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook<br \/>\n&amp;rfe.genre=book&amp;rfe.aulast=Chomsky&amp;rfe.auinit=N&amp;rfe.btitle=Minimalist+Program<br \/>\n&amp;rfe.isbn=0262531283&amp;rfe.date=1995&amp;rfe.pub=The+MIT+Press&amp;rfe.place=Cambridge%2C+Mass<br \/>\n&amp;svc_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Asch_svc&amp;svc.abstract=yes<br \/>\n&amp;rfr_id=info%3Asid%2Febookco.com%3Abookreader\n<\/div>\n<p>Ugly, I know, but bear with me for a moment.&nbsp; From this example, let&#8217;s focus on the Referent:<\/p>\n<div style=\"margin-left: 40px;\">rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.aulast=Vergnaud<br \/>\n&amp;rft.auinit=J.-R&amp;rft.btitle=D%C3%A9pendances+et+niveaux+de+repr%C3%A9sentation+en+syntaxe<br \/>\n&amp;rft.date=1985&amp;rft.pub=Benjamins&amp;rft.place=Amsterdam%2C+Philadelphia\n<\/div>\n<p>and then let&#8217;s make this a little more human readable:<\/p>\n<div style=\"margin-left: 40px;\">rft_val_fmt:&nbsp; info:ofi\/fmt:kev:mtx:book<br \/>\nrft.genre:&nbsp; book<br \/>\nrft.aulast:&nbsp; Vergnaud<br \/>\nrft.auinit:&nbsp; J.-R<br \/>\nrft.btitle:&nbsp; D\u00c3\u00a9pendances et niveaux de repr\u00c3\u00a9sentation en syntaxe<br \/>\nrft.date:&nbsp; 1985<br \/>\nrft.pub:&nbsp; Benjamins<br \/>\nrft.place:&nbsp; Amsterdam, Philadelphia<\/div>\n<p>Looking at this example, it&#8217;s certainly easy to draw some conclusions about the referent, the most obvious being that it&#8217;s a book.<\/p>\n<p>Actually (and this is where it gets complicated and I begin to look pedantic) it&#8217;s really only telling you, <span style=\"font-style: italic;\">I am sending some by value metadata in the info:ofi\/fmt:kev:mtx:book format<\/span>, not that the thing is actually a book (although the info:ofi\/fmt:kev:mtx:book metadata values <span style=\"font-style: italic;\">do<\/span> state that, but, ignore that for a minute since genre is optional).<\/p>\n<p>The way this actually should be thought of:<\/p>\n<div style=\"margin-left: 40px;\"><span style=\"font-weight: bold;\">ContextObject<\/span>:<br \/>\n&nbsp;&nbsp;&nbsp; <span style=\"font-weight: bold;\">Referent<\/span>:<br \/>\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  <span style=\"font-weight: bold;\">Metadata by Value<\/span>:<br \/>\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  <span style=\"font-weight: bold;\">Format<\/span>:&nbsp; info:ofi\/fmt:kev:mtx:book<br \/>\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp; <span style=\"font-weight: bold;\">Metadata<\/span>:<br \/>\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  <span style=\"font-weight: bold;\">Genre<\/span>:&nbsp; book<br \/>\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp; <span style=\"font-weight: bold;\">Btitle<\/span>:&nbsp; D\u00c3\u00a9pendances et niveaux de repr\u00c3\u00a9sentation en syntaxe<br \/>\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &#8230;<br \/>\n&nbsp;&nbsp;&nbsp; <span style=\"font-weight: bold;\">ReferringEntity<\/span>:<br \/>\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; <span style=\"font-weight: bold;\">Identifier<\/span>:&nbsp; urn:isbn:0262531283<br \/>\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  <span style=\"font-weight: bold;\">Metadata by Value<\/span>:<br \/>\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style=\"font-weight: bold;\">Format<\/span>:&nbsp; info:ofi\/fmt:kev:mtx:book<br \/>\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style=\"font-weight: bold;\">Metadata<\/span>:<br \/>\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  <span style=\"font-weight: bold;\">&nbsp;&nbsp;&nbsp; Genre<\/span>:&nbsp; book<br \/>\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  <span style=\"font-weight: bold;\">&nbsp;&nbsp;&nbsp; Isbn<\/span>:&nbsp; 0262531283<br \/>\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  <span style=\"font-weight: bold;\">&nbsp;&nbsp;&nbsp; Btitle<\/span>:&nbsp; Minimalist Progam<br \/>\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp; &#8230;<br \/>\n&nbsp;&nbsp;&nbsp; <span style=\"font-weight: bold;\">Referrer<\/span>:<br \/>\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  <span style=\"font-weight: bold;\">Identifier<\/span>:&nbsp; info:sid\/ebookco.com:bookreader<br \/>\n&nbsp;&nbsp;&nbsp; <span style=\"font-weight: bold;\">ServiceType<\/span>:<br \/>\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  <span style=\"font-weight: bold;\">Metadata By Value<\/span>:<br \/>\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style=\"font-weight: bold;\">Format<\/span>:&nbsp; info:ofi\/fmt:kev:mtx:sch_svc<br \/>\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style=\"font-weight: bold;\">Metadata<\/span>:<br \/>\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;  <span style=\"font-weight: bold;\">&nbsp;&nbsp;&nbsp; Abstract<\/span>:&nbsp; yes\n<\/div>\n<p>So, this should still seem fairly straightforward, but the hierarchy certainly isn&#8217;t evident in the KEV.&nbsp; It&#8217;s a good starting point to begin talking about the complexity of working with OpenURL, though, especially if you&#8217;re trying to create a service that consumes OpenURL context objects.<\/p>\n<p>Back to the referent metadata.&nbsp; The context object didn&#8217;t have to send the data in the &#8220;metadata by value&#8221; stanza.&nbsp; It could have just sent the identifier &#8220;urn:isbn:9027231141&#8221; (and note in the above example, it didn&#8217;t have an identifier at all).&nbsp; It could also have sent metadata in the Dublin Core format, MARC21, MODS, ONIX or <span style=\"font-style: italic;\">all of the above<\/span> (the Metadata By Value element is repeatable) if you wanted to make sure your referent could be parsed by the widest range of resolvers. While all of these are bibliographic formats, in Request Transfer Message context objects (which would be used for document delivery, which got me started down this whole path), you would conceivably have one or more of the aforementioned metadata types <span style=\"font-style: italic;\">plus<\/span> a <a href=\"http:\/\/alcme.oclc.org\/openurl\/servlet\/OAIHandler?verb=GetRecord&amp;metadataPrefix=oai_dc&amp;identifier=info:ofi\/fmt:xml:xsd:rtm_rft\">Request Transfer Profile Referent<\/a> type that describes the sorts of interlibrary loan-ish types of data that accompany the referent as well as an ISO Holdings Schema metadata element carrying the actual items a library has, their locations and status.<\/p>\n<p>If you only have run across KEVs describing journal articles or books, this may come as a bit of a surprise.&nbsp; Instead of saying the above referent <span style=\"font-style: italic;\">is a book<\/span>, it becomes important to say that the referent contains a <span style=\"font-style: italic;\">metadata package<\/span> (as <a href=\"http:\/\/bibwild.wordpress.com\/\">Jonathan Rochkind<\/a> calls it) that is in this (OpenURL specific) book format.&nbsp; In this regard, OpenURL is similar to <a href=\"http:\/\/www.loc.gov\/standards\/mets\/\">METS<\/a>.&nbsp; It wraps other metadata documents and defines the relationships between them.&nbsp; It is completely ambivalent about the data it is transporting and makes no attempt to define it or format it in any way.&nbsp; The Journal, Book, Patent and Dissertation formats were basically contrived to make compatibility with OpenURL 0.1 easier, but they are not directly associated with OpenURL and could have just as easily been replaced with, say, BibTex or RIS (although the fact that they were created alongside Z39.88 and are maintained by the same community makes the distinction difficult to see).<\/p>\n<p>What this means, then, is that in order to know anything about a given entity, you also need to know about the metadata format that is being sent about it.&nbsp; And since that metadata could literally be in any format, it means there are lot of variables that need to be addressed just to know what a thing is.<\/p>\n<p>For the Umlaut, I wrote an OpenURL library for Ruby as a means to parse and create OpenURLs.&nbsp; Needless to say, it was originally written with that naive, KEV-based, mental model (plus some other just completely errant assumptions about how context objects worked) and, because of this, I decided to completely rewrite it.&nbsp; I am still in the process of this, but am struggling with some core architectural concepts and am throwing this out to the larger world as an appeal for ideas or advice.<\/p>\n<p>Overall the design is pretty simple:&nbsp; there is a ContextObject object that contains a hash of the administrative metadata and then attributes (referent, referrer, requester, etc.) that contain Entity objects.<\/p>\n<p>The Entity object has arrays of identifiers, private data and metadata.<\/p>\n<p>And then this is where I start to run aground.<\/p>\n<p>The original (and current) plan was to populate the metadata array with native metadata objects that are generated by registering metadata classes in a MetadataFactory class.&nbsp; The problem, you see, is that I don&#8217;t want to get into the business of having to create classes to parse and access every kind of metadata format that gets approved for Z39.88.&nbsp; For example, Ed Summers&#8217; ruby-marc has already solved the problem of effectively working with MARC in Ruby, so why do I want to reinvent that wheel?&nbsp; The counter argument is, by delegating these responsibilities to third party libraries, there is no consistency of APIs between &#8220;metadata packages&#8221;.&nbsp; A method used in format <span style=\"font-style: italic;\">A<\/span> may very well raise an exception (or, worse, overwrite data) in format <span style=\"font-style: italic;\">B<\/span>.&nbsp; <\/p>\n<p>There is a secondary problem that third party libraries aren&#8217;t going have any idea that they&#8217;re in an OpenURL context object or even know what that is.&nbsp; This means there would have to be some class that handles functionality like xml serialization (since ruby-marc doesn&#8217;t know that Z39.88 refers to it as <strong><\/strong><strong style=\"font-weight: normal; font-style: italic;\">info:ofi\/fmt:xml:xsd:MARC21<\/strong><strong style=\"font-weight: normal;\">), although this can be handled by the specific metadata factory class.&nbsp; This would also be necessary when parsing an incoming OpenURL since, theoretically, every library could have a different syntax for importing XML, KEVs or whatever other serialization is devised in the future.<\/p>\n<p>So I&#8217;m looking for advice on how to proceed.&nbsp; All ideas welcome.<br \/>\n<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometime in November, I came to the realization that I had horribly misinterpreted the NISO Z39.88\/OpenURL 1.0 spec.&nbsp; I&#8217;m on the NISO Advisory Committee for OpenURL (which makes this even more embarrassing) and was reviewing the proposal for the Request Transfer Message Community Profile and its associated metadata formats when it dawned on me that [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,20,39],"tags":[],"class_list":["post-107","post","type-post","status-publish","format-standard","hentry","category-coding","category-openurl","category-ruby"],"_links":{"self":[{"href":"https:\/\/rossfsinger.me\/blog\/wp-json\/wp\/v2\/posts\/107","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rossfsinger.me\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rossfsinger.me\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rossfsinger.me\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rossfsinger.me\/blog\/wp-json\/wp\/v2\/comments?post=107"}],"version-history":[{"count":0,"href":"https:\/\/rossfsinger.me\/blog\/wp-json\/wp\/v2\/posts\/107\/revisions"}],"wp:attachment":[{"href":"https:\/\/rossfsinger.me\/blog\/wp-json\/wp\/v2\/media?parent=107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rossfsinger.me\/blog\/wp-json\/wp\/v2\/categories?post=107"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rossfsinger.me\/blog\/wp-json\/wp\/v2\/tags?post=107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}