1. Transfrmatin Example 1.1. Example: BibTeXML DcBk The BibTeXML t DcBk example describes a transfrmatin f a BibTeXML mdel t a DcBk cmpsed dcument. BibTeXML [1] is an XML-based frmat fr the BibTeX bibligraphic tl. DcBk [2], as fr it, is an XML-based frmat fr dcument cmpsitin. The aim f this transfrmatin is t generate, frm a BibTeXML file, a DcBk dcument that presents the different entries f the bibligraphic file within fur different sectins. The first sectin prvides the full list f bibligraphic entries. The secnd sectin prvides the srted list f the different authrs referenced in the bibligraphy. The third sectin presents the titles f the bibligraphy titled entries (in a srted way. Finally, the last sectin prvides the list f referenced jurnals (in article entries. 1.1.1. Metamdels This transfrmatin is based n a simplified BibTeXML metamdel which nly deals with the mandatry fields f each BibTeX entries (fr instance, authr, year, title and jurnal fr an article entry. The cnsidered metamdel is presented in Figure 1, and prvided, in km3 frmat [3], in Appendix I. It has been designed in such a way that it shuld be easily extensible t handle ptinal fields (with minr mdificatins. Figure 1. The BibTeXML metamdel A bibligraphy is mdelized by a BibTeX File element. This element is cmpsed f BibTeX Entries which are each assciated with an id. All entries inherit, directly r indirectly, f the abstract BibTeX Page 1/12
Entry element. The abstract classes Authred Entry, Dated Entry, Titled Entry and Bk Titled Entry, as well as the Misc entry, directly inherit f BibTeX Entry. There are 13 pssible entry types: PhD Thesis, Master Thesis, Article, Tech Reprt, Unpublished, Manual, In Prceedings, Prceedings, Bklet, In Cllectin, Bk, In Bk and Misc. Cncrete BibTeX entries inherits frm sme f these abstract classes accrding t their set f mandatry fields. An authred entry may have several authrs (at least ne. It is pssible t nte that the Misc entry has n mandatry field. The transfrmatin als relies n a limited subset f the DcBk definitin. The metamdel cnsidered here is described in Figure 2, and prvided in Appendix II in km3 frmat. DcBk 1 * -dcbk -bks Bk 1 * -bk -articles Article TitleElement +title 1 * -article -sectins Sect1 -sectin-paras 1 * Para +cntent Figure 2. The DcBk metamdel Within this metamdel, a DcBk dcument is assciated with a DcBk element. Such an element is cmpsed f several Bks that, in their turn, are cmpsed f several Articles. An Article is cmpsed f Sectins ( Sect1 that are rdered. A Sectin is cmpsed f Paragraphs ( Para that are als rdered within each sectin. Bth Article and Sectin inherit frm the TitledElement abstract class. 1.1.2. Rules Specificatin These are the rules t transfrm a BibTeXML mdel t a DcBk mdel: Fr the rt BibTeX File element, the fllwing elements are created: A DcBk element; A Bk element (linked t the DcBk; Page 2/12
An Article element (linked t the Bk which title is BibTeXML t DcBk ; 4 Sectins elements (linked t the Article which titles respectively are References List fr Sectin 1 Authr List Sectin 2 Titles List Sectin 3 Jurnals List Sectin 4 Fr each distinct Authr, a Paragraph is created Its cntent is the authr name; It is linked t Sectin 2; Fr each untitled BibTeX Entry (entries that des nt inherit frm the Titled Entry class a Paragraph is created Its cntent cntains all available infrmatin n the Entry; It is linked t Sectin 1; Fr each Titled Entry, except Articles, the fllwing elements have t be created A Paragraph, linked t Sectin 1, that cntains all infrmatin n the Titled Entry; A Paragraph, linked t Sectin 3, that cntains the title f the Entry (each title nly appears nce; Fr each Article, the fllwing elements have t be created A Paragraph, linked t Sectin 1, that cntains all infrmatin n the Titled Entry; A Paragraph, linked t Sectin 3, that cntains the title f the Entry (each title nly appears nce; A Paragraph linked t Sectin 4, which cntains the name f the jurnal (each jurnal nly appears nce. 1.1.3. Cde This cde fr the BibTeXML t DcBk transfrmatin cnsists f 4 helpers and 9 rules. Amng helpers, authrset prvides a subset f Authr elements in which a same authr name appears nly nce. In the same way, titledentryset prvides a subset f TitledEntry elements in which a same title appears nly nce. Finally, articleset prvides a subset f Article elements in which a same jurnal name appears nly nce. Accrding t the type f each entry, the last helper, buildentrypara, builds the cntent f the paragraph that will be assciated, in the first sectin, with the entry. The rule Main allcates the structure f the DcBk mdel. This rule makes use f the thismdule.reslvetemp(e, str methd (in utputs se3 and se4. In the se3 utput, this methd makes it pssible t handle the utput elements generated in the titled_para utput f rule TitledEntry_NArticle (the ne matching the titledentryset elements. The methd is used in the same way in utput se4 t handle the utput elements generated in the jurnal_para utput f rule Article. The rule Authr allcates the DcBk paragraphs that cmpse the secnd sectin (list f the distinct authrs. Page 3/12
Since, with, a same surce element cannt be matched mre than nce, cntents f sectins 1, 3 and 4 are generated by the 7 fllwing rules: UntitledEntry, TitledEntry_Title_NArticle, TitledEntry_NTitle_NArticle, Article_Title_Jurnal, Article_NTitle_Jurnal, Article_Title_NJurnal and Article_NTitle_NJurnal. The rule UntitledEntry allcates a part f the first sectin (fr all untitled entries. The rule TitledEntry_Title_NArticle deals with titled entries that belng t the titledentryset set and are nt Articles. It allcates the crrespnding paragraphs in the first sectin, as well as the paragraphs f the third sectin that cntains distinct titles. TitledEntry_NTitle_NArticle is a similar rule that applies t entries that d nt belng t the titledentryset set and are nt Articles. As a cnsequence, it nly creates paragraph in the first sectin. The rule Article_Title_Jurnal allcates paragraphs in the first, the third and the frth sectins. This rule cnsiders Article entries that belng bth t articleset and titledentryset sets. Article_NTitle_Jurnal is a similar rule that nly applies t articles that belng t the articleset set, but nt t the titledentryset ne. It therefre creates paragraphs in the first and the frth sectins, but nt in the third ne. In the same way, Article_Title_NJurnal applies t articles that belng t the titledentryset set, but nt t the articleset ne. As a cnsequence, it nly creates paragraphs in the first and the third sectins. Finally, Article_NTitle_NJurnal deals with articles that belng neither t the titledentryset set, nr t the articleset ne. It creates a single paragraph in the first sectin. mdule BibTeX2DcBk; create OUT : DcBk frm IN : BibTeX; ------------------------------------------------------------------------------- -- HELPERS -------------------------------------------------------------------- ------------------------------------------------------------------------------- -- This helper builds the set f distinct authrs referenced in the input BibTeX -- mdel. -- Built set is srted by authr name. -- RETURN: Sequence(BibTeX!Authr helper def: authrset : Sequence(BibTeX!Authr = BibTeX!Authr.allInstances(- >iterate(e; ret : Sequence(BibTeX!Authr = Sequence { if ret->cllect(e e.authr->includes(e.authr then ret else ret->including(e endif ->srtedby(e e.authr; -- This helper builds the set f distinct titles referenced in the input BibTeX -- mdel. -- Built set is srted by title. -- RETURN: Sequence(BibTeX!TitledEntry helper def: titledentryset : Sequence(BibTeX!TitledEntry = BibTeX!TitledEntry.allInstances(->iterate(e; ret : Sequence(BibTeX!TitledEntry = Sequence { if ret->cllect(e e.title->includes(e.title then ret else ret->including(e endif ->srtedby(e e.title; -- This helper builds the set f distinct jurnals referenced in the input BibTeX -- mdel. -- Built set is srted by jurnal name. -- RETURN: Sequence(BibTeX!Article Page 4/12
helper def: articleset : Sequence(BibTeX!Article = BibTeX!Article.allInstances(- >iterate(e; ret : Sequence(BibTeX!Article = Sequence { if ret->cllect(e e.jurnal->includes(e.jurnal then ret else ret->including(e endif ->srtedby(e e.jurnal; -- This helper builds a string cntaining all infrmatin n a given BibTeXEntry. -- Cntent f the generated string depends n the entry type. -- IN: BibTeX!BibTeXEntry -- RETURN: Sequence(BibTeX!Authr helper cntext BibTeX!BibTeXEntry def: buildentrypara( : String = '[' + self.id + ']' + ' ' + self.cltype(.name + (if self.cliskindof(bibtex!titledentry then ' ' + self.title else '' endif + (if self.cliskindof(bibtex!authredentry then self.authrs->iterate(e; str : String = '' str + ' ' + e.authr else '' endif + (if self.cliskindof(bibtex!datedentry then ' ' + self.year else '' endif + (if self.cliskindof(bibtex!bktitledentry then ' ' + self.bktitle else '' endif + (if self.cliskindof(bibtex!thesisentry then ' ' + self.schl else '' endif + (if self.cliskindof(bibtex!article then ' ' + self.jurnal else '' endif + (if self.cliskindof(bibtex!unpublished then ' ' + self.nte else '' endif + (if self.cliskindof(bibtex!bk then ' ' + self.publisher else '' endif + (if self.cliskindof(bibtex!inbk then ' ' + self.chapter.tstring( else '' endif ; ------------------------------------------------------------------------------- -- RULES ---------------------------------------------------------------------- ------------------------------------------------------------------------------- -- Rule 'Main' -- This rule generates the structure f the DcBk mdel frm a BibTeXFile element rule Main { frm bib : BibTeX!BibTeXFile t dc : DcBk!DcBk ( bks <- b b : DcBk!Bk ( articles <- art art : DcBk!Article ( title <- 'BibTeXML t DcBk', sectins_1 <- Sequence{se1, se2, se3, se4 se1 : DcBk!Sect1 ( title <- 'References List', paras <- BibTeX!BibTeXEntry.allInstances(->srtedBy(e e.id se2 : DcBk!Sect1 ( title <- 'Authrs list', Page 5/12
paras <- thismdule.authrset se3 : DcBk!Sect1 ( title <- 'Titles List', paras <- thismdule.titledentryset->cllect(e thismdule.reslvetemp(e, 'title_para' se4 : DcBk!Sect1 ( title <- 'Jurnals List', paras <- thismdule.articleset->cllect(e thismdule.reslvetemp(e, 'jurnal_para' -- Rule 'Authr' -- This rule generates a sectin_2 paragraph fr each distinct authr. rule Authr { frm a : BibTeX!Authr ( thismdule.authrset->includes(a t p1 : DcBk!Para ( cntent <- a.authr -- Rule 'UntitledEntry' -- This rule generates a sectin_1 paragraph fr each untitled entry. rule UntitledEntry { frm e : BibTeX!BibTeXEntry ( nt e.cliskindof(bibtex!titledentry t p : DcBk!Para ( cntent <- e.buildentrypara( -- Rule 'TitledEntry_Title_NArticle' -- [titledentryset cntains a subset f TitledEntry, s that each title -- appears nly nce in the set] -- Fr each "n article" titled entry that belngs t titledentryset, -- this rule generates: -- * a sectin_1 paragraph; -- * a sectin_3 paragraph. rule TitledEntry_Title_NArticle { frm e : BibTeX!TitledEntry ( thismdule.titledentryset->includes(e and nt e.cliskindof(bibtex!article t entry_para : DcBk!Para ( cntent <- e.buildentrypara( title_para : DcBk!Para ( cntent <- e.title Page 6/12
-- Rule 'TitledEntry_NTitle_NArticle' -- [titledentryset cntains a subset f TitledEntry, s that each title -- appears nly nce in the set] -- Fr each "n article" titled entry that des nt belng t titledentryset, -- this rule generates: -- * a sectin_1 paragraph; rule TitledEntry_NTitle_NArticle { frm e : BibTeX!TitledEntry ( nt thismdule.titledentryset->includes(e and nt e.cliskindof(bibtex!article t entry_para : DcBk!Para ( cntent <- e.buildentrypara( -- Rule 'Article_Title_Jurnal' -- [titledentryset cntains a subset f TitledEntry, s that each title -- appears nly nce in the set] -- [articleset cntains a subset f Article, s that each jurnal -- appears nly nce in the set] -- Fr each article entry that belngs t articleset, this rule generates: -- * a sectin_1 paragraph; -- * a sectin_3 paragraph; -- * a sectin_4 paragraph. rule Article_Title_Jurnal { frm e : BibTeX!Article ( thismdule.titledentryset->includes(e and thismdule.articleset->includes(e t entry_para : DcBk!Para ( cntent <- e.buildentrypara( title_para : DcBk!Para ( cntent <- e.title jurnal_para : DcBk!Para ( cntent <- e.jurnal -- Rule 'Article_NTitle_Jurnal' -- [titledentryset cntains a subset f TitledEntry, s that each title -- appears nly nce in the set] -- [articleset cntains a subset f Article, s that each jurnal -- appears nly nce in the set] -- Fr each article entry that belngs t articleset, this rule generates: -- * a sectin_1 paragraph; -- * a sectin_4 paragraph. rule Article_NTitle_Jurnal { frm e : BibTeX!Article ( nt thismdule.titledentryset->includes(e and thismdule.articleset->includes(e t entry_para : DcBk!Para ( cntent <- e.buildentrypara( Page 7/12
jurnal_para : DcBk!Para ( cntent <- e.jurnal -- Rule 'Article_Title_NJurnal' -- [titledentryset cntains a subset f TitledEntry, s that each title -- appears nly nce in the set] -- [articleset cntains a subset f Article, s that each jurnal -- appears nly nce in the set] -- Fr each article entry that belngs t articleset, this rule generates: -- * a sectin_1 paragraph; -- * a sectin_3 paragraph. rule Article_Title_NJurnal { frm e : BibTeX!Article ( thismdule.titledentryset->includes(e and nt thismdule.articleset->includes(e t entry_para : DcBk!Para ( cntent <- e.buildentrypara( title_para : DcBk!Para ( cntent <- e.title -- Rule 'Article_NTitle_NJurnal' -- [titledentryset cntains a subset f TitledEntry, s that each title -- appears nly nce in the set] -- [articleset cntains a subset f Article, s that each jurnal -- appears nly nce in the set] -- Fr each article entry that belngs t articleset, this rule generates: -- * a sectin_1 paragraph; rule Article_NTitle_NJurnal { frm e : BibTeX!Article ( nt thismdule.titledentryset->includes(e and nt thismdule.articleset->includes(e t entry_para : DcBk!Para ( cntent <- e.buildentrypara( Page 8/12
I. BibTeXML metamdel in km3 frmat package BibTeX { class BibTeXFile { reference entries[*] cntainer : BibTeXEntry; class Authr { attribute authr : String; abstract class BibTeXEntry { attribute id : String; abstract class AuthredEntry extends BibTeXEntry { reference authrs[1-*] cntainer : Authr; abstract class DatedEntry extends BibTeXEntry { attribute year : String; abstract class TitledEntry extends BibTeXEntry { attribute title : String; abstract class BkTitledEntry extends BibTeXEntry { attribute bktitle : String; class Article extends AuthredEntry, DatedEntry, TitledEntry { attribute jurnal : String; class TechReprt extends AuthredEntry, DatedEntry, TitledEntry { class Unpublished extends AuthredEntry, TitledEntry { attribute nte : String; class Manual extends TitledEntry { class Prceedings extends DatedEntry, TitledEntry { class InPrceedings extends Prceedings, AuthredEntry, BkTitledEntry { class Bklet extends DatedEntry { Page 9/12
class Bk extends AuthredEntry, DatedEntry, TitledEntry { attribute publisher : String; class InCllectin extends Bk, BkTitledEntry { class InBk extends Bk { attribute chapter : Integer; class Misc extends BibTeXEntry { { abstract class ThesisEntry extends AuthredEntry, DatedEntry, TitledEntry attribute schl : String; class PhDThesis extends ThesisEntry { class MasterThesis extends ThesisEntry { package PrimitiveTypes { datatype String; datatype Integer; Page 10/12
II. DcBk metamdel in km3 frmat package DcBk { class DcBk { reference bks [1-*] rdered cntainer: Bk; class Bk { reference articles [1-*] rdered cntainer: Article; abstract class TitledElement { attribute title : String; class Article extends TitledElement { reference sectins_1 [1-*] rdered cntainer : Sect1; class Sect1 extends TitledElement { reference paras [1-*] rdered cntainer: Para; class Para { attribute cntent : String; package PrimitiveTypes { datatype String; Page 11/12
References [1] BibTeXML, BibTeX as XML markup, http://bibtexml.surcefrge.net/. [2] DcBk: The Definitive Guide. Nrman Walsh. O Reilly & Assciates, Inc. Octber 1999. [3] KM3: Kernel MetaMetaMdel. Available at http://dev.eclipse.rg/viewcvs/indextech.cgi/~checkut~/gmthme/dc/atl/index.html. Page 12/12