Menu

Home

Curt Selak

The Home page for this Wiki serves as a general introduction to the project. The other Wiki pages currently available are:

X-definition is an open-source Java API found at www.xdefinice.cz and made available by its developers, Syntea Software Group, under the Apache License Version 2.0. The project you are viewing isn't affiliated with Syntea Software Group.

I learned about X-definition a couple weeks ago from a paper that the developers had presented at the XML Prague conference in 2017. It took a little effort to locate X-definition's website using Google: a further search didn't really find anything save an article or two on www.dzone.com.

Using X-definition in the form in which it's downloaded from the official site requires, at a minimum, an understanding of the Java programming language's syntax as it pertains to packages. By contrast, the download offered through the project presented here simply lets you run X-definition using your system's Java command, like this:

java -jar xdef-beginner.jar xdeffile xmlfile

Let's say you have downloaded and unzipped the British National Bibliography in its entirety from the British Library. It's split up into 71 files, but each is still fairly large.

You can write code like this and save it with a name like BNBTest.xdef:

<?xml version="1.0" encoding="UTF-8"?>
<xd:def xmlns:xd="http://www.xdef.org/xdef/4.0" name="rdf" root="rdf:RDF" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:isbd="http://iflastandards.info/ns/isbd/elements/" xmlns:owlt="http://www.w3.org/2006/time#" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xmlns:bibo="http://purl.org/ontology/bibo/" xmlns:rda="http://rdvocab.info/Elements/" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<xd:declaration>
String a;
boolean b;
</xd:declaration>
<rdf:RDF>
<rdf:Description xd:script="occurs +;options ignoreOther;
init {a='';b=false;}finally {if (b EQ true) outln(a)} forget;">
<dcterms:title xd:script="occurs +;">
onTrue a = getText() + ': ';
</dcterms:title>
<dcterms:abstract>
onTrue {a= a + getText();b=true;}
</dcterms:abstract>
</rdf:Description>
</rdf:RDF>
</xd:def>

Then you can run X-definition, and read the abstracts (bzw. blurbs!) that the last of the 71 British National Bibliography XML files contains all day:

java -jar xdef-beginner.jar BNBTest.xdef BNBBasic_202207_f68.rdf | less

You will note that I'm using a Linux terminal: the alternative on Windows would be to use the redirection operator (>) to save X-definition's output to a file.

There are other ways to accomplish what the above code does.

One could use an XSL transformation. That can be onerous for some, because it entails using X-Path. Also, not all of XSLT is necessarily available should one's XML document prove too large: I'm not sure whether version 3.0's facilities for streaming processing of big documents are offered anywhere for free quite yet.

One also could use the .NET or Open JDK APIs. Using either obviously requires code of one's own. I found X-definition to be considerably less demanding where furnishing logic is concerned. A completely different API for very large XML documents, VTD-XML, is available for C, C++, and C# (in version 2.11), and for Java (later versions) on SourceForge.

Finally, even on XML documents that are pretty big, one can just use grep, provided that one has experience with regular expressions.

It seems to me that X-definition is a rather good means of taking advantage of XML's ability to bind data, particularly when one has lots and lots of XML, but relatively little going in the way of coding technique. This project includes a tutorial introduction to using X-definition with XML source documents that are really huge. As I do elsewhere in this project, I strongly recommend following the links above until you've downloaded the official distribution of X-definition, because the user documentation included in the .zip archive really merits being perused, and consulted.

Questions or comments can be sent to curtthomasselak@gmail.com . Something to bear in mind is that while I can really only write English, I'll still be able to understand email that is in German, French, or Italian without a translator.
.

Project Members:


Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.