<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>LIXR: Quick, succinct conversion of XML to RDF</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>John P. McCrae</string-name>
          <email>john@mccr.ae</email>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Philipp Cimiano</string-name>
          <email>cimiano@cit-ec.uni-bielefeld.de</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Cognitive Interaction Technology, Cluster of Excellence, Bielefeld University</institution>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Insight Centre for Data Analytics, National University of Ireland</institution>
          ,
          <addr-line>Galway</addr-line>
        </aff>
      </contrib-group>
      <abstract>
        <p>This paper presents LIXR, a system for converting between RDF and XML. LIXR is based on domain-speci c language embedded into the Scala programming language. It supports the de nition of transformations of datasets from RDF to XML in a declarative fashion, while still maintaining the exibility of a full programming language environment. We directly compare this system to other systems programmed in Java and XSLT and show that the LIXR implementations are signi cantly shorter in terms of lines of code, in addition to being conceptually simple to understand.</p>
      </abstract>
      <kwd-group>
        <kwd>RDF</kwd>
        <kwd>XML</kwd>
        <kwd>Scala</kwd>
        <kwd>format conversion</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>
        An important aspect towards realizing a web of data is the conversion of legacy
resources into the Resource Description Framework [2, RDF]. There are tools and
W3C recommendations1 supporting the transformation of relational databases
into RDF (e.g. D2RQ [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]), and even declaratively languages such as R2RML2.
Besides the relational model, legacy data represented in XML is quite frequent.
While there exist generic mechanisms for transforming XML data into some
other form, such as Extensible Stylesheet Language Transformations (XSLT),
these mechanisms are not ideal for the conversion into RDF for the following
reasons:
1. The generated RDF typically contains more triples than necessary due to
the fact that generic converters create both a property and a node for each
individual element in the XML.
2. It is uncommon for XML documents to reuse URLs from other resources.
      </p>
      <p>
        For example it is typical for a resource to reuse the data categories of Dublin
Core [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ], but to recast them under a new namespace, that is not compatible
with RDF.
      </p>
      <sec id="sec-1-1">
        <title>1 http://www.w3.org/TR/rdb-direct-mapping/ 2 http://www.w3.org/TR/r2rml/</title>
        <p>
          3. XML provides no generic mechanisms for the representation of external links
by URIs, using a proprietary linking schema instead such as XLink [
          <xref ref-type="bibr" rid="ref3">3</xref>
          ].
        </p>
        <p>
          Further, transformation from XML to some other format are typically
speci ed by means of XSLT, an extension of XSLT such as Krextor [
          <xref ref-type="bibr" rid="ref5">5</xref>
          ], a speci c
mapping language such as RML [
          <xref ref-type="bibr" rid="ref4">4</xref>
          ] or by writing a short script in some
programming language. Thus, these transformations are generally very verbose, as
they must repeat many standard RDF modelling structures, and unidirectional,
as they are not well-formulated to cope with the polymorphic nature of RDF.
        </p>
        <p>In order to meet these shortcomings, we developed a new system for
specifying the translation of XML documents into RDF and vica versa, which we call
the Lightweight Invertible XML and RDF language (LIXR, pronounced `elixir').
LIXR is signi cantly more compact than existing systems and allows for
transformation in both the direction of RDF to XML and from XML to RDF.
2</p>
      </sec>
    </sec>
    <sec id="sec-2">
      <title>The LIXR Language</title>
      <p>The LIXR language was created as a domain-speci c language based on the
Scala Language. This choice was made as Scala has an exceptional amount of
freedom in expression, allowing us to compactly and clearly state
transformations, although there would be some learning curve for those not familiar with
the Scala language.</p>
      <p>The basic structure of LIXR is inspired by XSLT and is based around
handlers, which describe the action that should be taken when a speci c XML
element is encountered. These handlers are stated by linking an XML element
name to a list of generators with the --&gt; operator. For example the following
LIXR expression can be used:
xml.language --&gt; (</p>
      <p>dc.language &gt; content
)</p>
      <p>This associates the XML element &lt;xml:language&gt; to generating the triple s
dc:language "c", where s is the current subject node, and c is the text content
of the node3 More typically the converter works by means of two features: rstly,
nodes instruct the RDF generation to create a new node in the RDF graph and
use it as subject for all triples from this point in the generation. Secondly, the
handle tells the XML parser to look for all children matching a given element
and call the appropriate handler for each matching case. For example:
xml.metadata --&gt; (</p>
      <p>node("http://.../metadata")(
3 Note that for technical reasons the . is used to conjoin the namespace to the local
name instead of the customary :. This, in fact, is a dynamic call, a relatively recent
feature of the Scala language.
)
)</p>
      <p>This code asks the RDF generator to create a new root node with the given
URI. The parser then looks for matching children and calls the appropriate
handlers (such as in the rst example). More detail of the language can be found
on Github4.</p>
      <p>Name
TBX
CMDI
CMDI
CMDI
CMDI
CMDI
TBX
MetaShare</p>
      <p>
        Tags Implementation LoC LoC/Tag
48 Java 2,752 57.33
79 XSLT 404 5.11
79 XSLT (No closing tags) 255 3.22
79 XSLT (Using Krextor [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]) 454 5.75
79 RML [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] 339 4.29
79 LIXR 176 2.23
48 LIXR 197 4.10
730 LIXR 2,487 3.41
To evaluate the e ectiveness of our approach we compared directly with four
other XML to RDF transformations in terms of an objective measure, that is
lines of code. The other transformation programs were written by the lead author
of the project5, and reimplemented using the LIXR language. In particular, lines
of code is easily measured and it has been claimed [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] that the average number of
errors made per lines of code is approximately constant for a given programmer,
regardless of what language he or she is programming in. As such, lines of code
can be a good proxy not only for ease of development but also for software
quality. As such, we measure the code in terms of non-trivial lines of code,
where a line of code is considered trivial if it only contains closing brackets or
braces or is empty.
      </p>
      <p>We consider three existing XML schemas as targets to be converted into RDF:
the TermBase eXchange format (TBX, ISO 30042:2008), the META-SHARE
schema6 for representing very rich metadata about language resource, and the
Component Metadata Initiative (CMDI) used by CLARIN7.</p>
      <sec id="sec-2-1">
        <title>4 https://github.com/liderproject/lixr</title>
        <p>5 The lead author has over 5 years experience in all languages
6 http://metashare.ilsp.gr/META-XMLSchema/v3.0/
7 http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/profiles/
clarin.eu:cr1:p\_1288172614026/xsd</p>
        <p>The results of the comparison in terms of lines of code for the datasets and the
di erent transformations is given in Table 1. The results show that LIXR leads
to signi cantly shorter code in terms of lines-of-code than the other methods we
attempted. In fact, we observe a 10-fold reduction of e ort over directly writing
a converter in a general purpose programming language (Java) and we see a
halving of e ort in comparison to using a specialist language (XSLT, Krextor
or RML). In addition, we note that the reduction is such that only a few lines
of code are needed for each element class. We note that all of the systems ran
quickly over the data we tested and thus we do not believe that processing time
or memory are radically di erent between these implementations.
4</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>Conclusion</title>
      <p>We have presented a declarative yet exible approach supporting the
conversation of XML to RDF. The approach is based on a domain-speci c language
embedded in the Scala programming language. We have shown that this
converter supports the implementation of concise and shorter conversion programs
than with other transformation languages.</p>
      <p>In addition to the reduction in e ort using this approach, we also note several
other advantages of the LIXR approach that could easily be added, due to its
declarative nature, including stream processing of XML, reverse mapping from
RDF to XML and extraction of an ontology from the mapping.</p>
    </sec>
    <sec id="sec-4">
      <title>Acknowledgments References</title>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Bizer</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Seaborne</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          :
          <article-title>D2RQ-treating non-RDF databases as virtual RDF graphs</article-title>
          .
          <source>In: Proceedings of the 3rd international semantic web conference (ISWC2004)</source>
          . vol.
          <year>2004</year>
          (
          <year>2004</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Cyganiak</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Wood</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Lanthaler</surname>
            ,
            <given-names>M.:</given-names>
          </string-name>
          <article-title>RDF 1.1 concepts and abstract syntax</article-title>
          .
          <source>W3C recommendation, World Wide Web Consortium</source>
          (
          <year>2014</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>DeRose</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Maler</surname>
            ,
            <given-names>E.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Orchard</surname>
            ,
            <given-names>D.:</given-names>
          </string-name>
          <article-title>XML linking language (XLink) version 1.0</article-title>
          . W3C recommendation,
          <source>World Wide Web Consortium</source>
          (
          <year>2001</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Dimou</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Vander</surname>
            <given-names>Sande</given-names>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            ,
            <surname>Colpaert</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            ,
            <surname>Verborgh</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            ,
            <surname>Mannens</surname>
          </string-name>
          , E., Van de Walle, R.:
          <article-title>RML: A generic language for integrated RDF mappings of heterogeneous data</article-title>
          .
          <source>In: Linked Data on the Web</source>
          (
          <year>2014</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Lange</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          :
          <article-title>Krextor{an extensible XML ! RDF extraction framework</article-title>
          .
          <source>Scripting and Development for the Semantic Web (449)</source>
          ,
          <volume>38</volume>
          (
          <year>2009</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>McConnell</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          :
          <article-title>Code Complete: A Practical Handbook of Software Construction, Second Edition</article-title>
          . Microsoft Press (
          <year>2014</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Weibel</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kunze</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Lagoze</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Wolf</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          :
          <article-title>Dublin core metadata for resource discovery</article-title>
          .
          <source>Request for Comments</source>
          <volume>2413</volume>
          (
          <issue>198</issue>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>