Florian Reuter's Weblog

Florian Reuter's Weblog

Florian Reuter's Weblog

Alle | Breakpoint | General

« loading a document | Main
20051216 Freitag Dezember 16, 2005

The community and me / The OpenBib project.

Bruce D'Arcus contacted me for help in the OpenBib project. In order to help Bruce to find some programmers who will help him coding in the project I will post here some first steps. The goal for me is not to do all the programming by myself --- in case I would do this everybody with an idea would contact me to do the work :-) --- but to teach people some basic knowledge, so that they could do the programming themselves.

In this column I would like to show how the citation data can be read and stored in a DOM instance. So lets hope you mastered the CWS creation... We will go in medias res:

Lets be more precise about what we want to do. Consider for example the OpenDocument fragment which includes citation data:

<bib:citation>
    <bib:citation-source>
        <bib:biblio-ref bib:linked="token" bib:citation-style="string"?>
        <bib:detail bib:begin="string"
                         bib:end="string"?
                         bib:units="pages|chapters|lines|paragraphs|figures|sections|formulas"/>?
        <bib:caption bin:position="before|after">paragraph-content*</bib:caption>?
    </bib:citation-source>
    <bib:citation-body>paragraph-content*</bib:citation-body>?
</bib:citation>

On loading we --- first --- want to store the information within a DOM tree. I know that there is a lot more to do; but lets just start with this task.

You can get a blueprint for storing data in a DOM instance in the file http://www.go-oo.org/lxr/source/xml/xmloff/source/xforms/XFormsInstanceContext.cxx#111. Obviously there already exists a DomBuilderContext (thanks dvo). OK; everything is there --- the question is, where to create the context.

Your debugger will tell you that http://www.go-oo.org/lxr/source/xml/xmloff/source/text/txtparai.cxx#1322 is the right place to create the child context.

OK; then we need to insert a case statement like in http://www.go-oo.org/lxr/source/xml/xmloff/source/text/txtparai.cxx#1322:

       case XML_TOK_BIB_CITATION:
            DomBuilderContext* pInstance = new DomBuilderContext( GetImport(), nPrefix, rLocalName );
            // the resulting tree will be stored in: pInstance->getTree();
            pContext = pInstance;
            break;

This won't compile, since we have not yet defined what XML_TOK_TEXT_CITATION is. Looking e.g. for XML_TOK_TEXT_SPAN (http://www.go-oo.org/lxr/ident?i=XML_TOK_TEXT_SPAN) we can figure out what to do: We will add XML_TOK_CITATION to the end of http://www.go-oo.org/lxr/ident?i=XMLTextPElemTokens (but before XML_TOK_TEXT_P_ELEM_END) and then we will add

{ XML_NAMESPACE_BIB, XML_CITATION, XML_TOK_TEXT_CITATION },
to http://www.go-oo.org/lxr/source/xml/xmloff/source/text/txtimp.cxx#245. Having done so we need to define XML_CITATION and XML_NAMESPACE_BIB. I'm sure you will figure out what to do...

Now we have the complete citation information stored within a DOM instance. Isn't that great AND easy. Stay tuned for the next steps.

Hope you had as much fun as I had.

Florian

( Dez 16 2005, 09:25:50 AM PST ) Permalink

Kommentare:

Senden Sie einen Kommentar:

Kommentare sind ausgeschaltet.

Page Hits heute: 9