Sunday 21 October 2012

Source code to XML and RDF converters

I moved all the converters to one place:

http://swifc-converters.appspot.com/

I have developed two prototypes for converting PHP or Java code to XML and RDF. You can find them at the following addresses:

http://xmltranslator.appspot.com/sourcecodetoxml.html

and

http://rdfconverter.appspot.com/sourcecodetordf.html

As an extra tool, I also have running a general XML to RDF converter:

http://xmltordf.appspot.com/xmltordf.html

If you encounter any issues, please leave a comment. I would be happy to fix whatever issues..



Wednesday 17 October 2012

Apache Tomcat HTTP Status 500 - javax.servlet.ServletException: java.lang.UnsupportedClassVersionError


HTTP Status 500 - javax.servlet.ServletException: java.lang.UnsupportedClassVersionError: com/namespace/project/class : Unsupported major.minor version 51.0 (unable to load class com.namespace.project.class)


If you've seen an error like this when trying to run a Tomcat project, the problem is that the JAVA version used to compile the class mentioned in the error is different than the JAVA version Tomcat uses. You can either recompile the class or change the JAVA version Tomcat uses.

To change the settings for Tomcat, in Windows, modify the catalina.bat file by adding the following line in red. You most probably have a different location for your JDK. This version is the version used for compiling the class that gives the error. After adding the line remember to restart Tomcat (shutdown.bat and startup.bat) if it is already running.

rem set TITLE=Tomcat.Cluster#1.Server#1 [%DATE% %TIME%]
rem
rem $Id: catalina.bat 1344732 2012-05-31 14:08:02Z kkolinko $
rem -----------------------------------------------------------

set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_33

rem Suppress Terminate batch job on CTRL+C
if not ""%1"" == ""run"" goto mainEntry
if "%TEMP%" == "" goto mainEntry
if exist "%TEMP%\%~nx0.run" goto mainEntry

Wednesday 10 October 2012

Merge a branch into the trunk using Tortoise SVN

We'll assume you have done some changes in the branch that you are working on and you want to merge those changes into the trunk. Here I will outline some steps using the svn command line tool and the TortoiseSVN tool using Windows 7.

1) Checkout the branches and trunk from SVN (if you do not have a local copy) using command line for example:

    svn checkout link_to_svn_repository WRK --username your_username

2) Browse to the folder where your working copy is located (e.g, where you previously checked out) and using TortoiseSVN tool, right click on trunk and choose Merge...


After choosing Merge, next choose reintegrate a branch:




click Next and choose which one of the existing branches to reintegrate:

4) Click Next -> Merge and wait for completion

5) The trunk has now new changes, so commit the changes back into the SVN:


    svn commit -m "Reintegrate branch 1.2"







Tuesday 9 October 2012

How to run multiple python test cases

If you have the following situation: multiple python test cases in a directory and you want to automatically run them with only one command, first you need to install the discover python module, which is actually called python nose module. In Ubuntu you would typically run the following from command line:


$ sudo apt-get install python-nose

After successfully installing the discovery module, navigate to the folder where your test cases are located and just run:

$ nosetests

This will automatically find the tests and run them for you. 

Note: I believe that the test file names need to follow a convention; please consult the documentation of the module. I tried with "name_test.py" and it worked.

Monday 8 October 2012

How to run an XQuery script


First, for the XQuery processor (the one that I use in the following steps) to work you need to have Java installed.

1) Download an XQuery processor for Java. I used Saxon. If you don't have material resources (like myself) download the home edition. You'll need to pay for the commercial ones if you choose to use one. When I wrote this article I downloaded SaxonHE9-4-0-6J.zip from the following link:

http://sourceforge.net/projects/saxon/files/Saxon-HE/9.4/

2) Extract the zip file to a path you can remember. It will result in 2 jar files:
3) Run your XQuery script by adding the extracted saxon9he.jar file to your java classpath:

java -classpath C:\.....\saxon9he.jar net.sf.saxon.Query my.xquery

where my.xquery is your xquery script, e.g.


<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:bibterms="http://www.book-stuff.com/terms/">

    <rdf:Description rdf:about="http://www.book-stuff.com/bib">
    {
        for $book in doc( "bib.xml" )//book
        return 
            <bibterms:book rdf:parseType="Resource">
            </bibterms:book>
    }
    </rdf:Description>

</rdf:RDF>

This command will output the resulting RDF file on the console. If you prefer having the result in a file, just add > filename.ext to the command, e.g:


java -classpath C:\.....\saxon9he.jar net.sf.saxon.Query my.xquery > result.rdf