[libfolia] 50/53: Imported Upstream version 0.10

Joost van Baal joostvb at moszumanska.debian.org
Sat Sep 6 10:46:10 UTC 2014


This is an automated email from the git hooks/post-receive script.

joostvb pushed a commit to branch master
in repository libfolia.

commit 2432dec0bb30d2dcc05175c206782812fb2f4005
Author: Joost van Baal-Ilić <joostvb at nusku.mdcc.cx>
Date:   Sat Sep 6 12:29:39 2014 +0200

    Imported Upstream version 0.10
---
 ChangeLog                               |  359 ++++++++++
 INSTALL                                 |    9 +-
 Makefile.in                             |   76 ++-
 NEWS                                    |   10 +
 aclocal.m4                              |   68 +-
 bootstrap                               |    4 +-
 config.guess                            |   49 +-
 config.sub                              |   65 +-
 configure                               |  174 ++++-
 configure.ac                            |   21 +-
 depcomp                                 |   74 +-
 include/Makefile.am                     |    2 +-
 include/Makefile.in                     |   23 +-
 include/folia/foliautils.h              |  324 ---------
 include/{folia => libfolia}/Makefile.am |    0
 include/{folia => libfolia}/Makefile.in |   37 +-
 include/{folia => libfolia}/document.h  |   58 +-
 include/{folia => libfolia}/folia.h     |  481 +++++++++----
 include/libfolia/foliautils.h           |  262 ++++++++
 ltmain.sh                               |   95 +--
 m4/Makefile.in                          |   21 +-
 m4/ltversion.m4                         |   10 +-
 m4/pkg.m4                               |   14 +-
 missing                                 |   53 +-
 src/Makefile.am                         |    9 +-
 src/Makefile.in                         |  152 +++--
 src/document.cxx                        |  259 +++++--
 src/folia.cxx                           | 1122 ++++++++++++++++++++++---------
 src/folialint.cxx                       |   64 ++
 src/foliautils.cxx                      |  816 ++++++++++++++--------
 src/simpletest.cxx                      |   18 +-
 31 files changed, 3280 insertions(+), 1449 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c6b8a78..d2d5c2d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,362 @@
+2013-04-03 08:50  sloot
+
+	* [r15893] include/folia/foliautils.h, src/document.cxx,
+	  src/foliautils.cxx: XPath stuff is moved to ticcutils
+
+2013-04-02 16:09  sloot
+
+	* [r15884] configure.ac: also most recent ticcutils needed
+
+2013-04-02 15:44  sloot
+
+	* [r15873] configure.ac, include/folia/document.h,
+	  include/folia/folia.h, include/folia/foliautils.h,
+	  src/Makefile.am, src/document.cxx, src/folia.cxx,
+	  src/foliautils.cxx: changed install directory!
+	  moved some XML stuff to ticcutils
+
+2013-04-02 10:31  sloot
+
+	* [r15861] src/foliautils.cxx: numb change
+
+2013-04-02 08:14  sloot
+
+	* [r15850] include/folia/Makefile.am, src/Makefile.am,
+	  src/folialint.cxx: tags
+
+2013-04-02 08:13  sloot
+
+	* [r15849] include/folia/foliautils.h, src/folialint.cxx: removed
+	  unused functions
+	  added copyright stuff
+
+2013-03-28 17:41  sloot
+
+	* [r15845] include/folia/foliautils.h, src/folia.cxx,
+	  src/foliautils.cxx: removed stuff that is present in ticcutils
+
+2013-03-07 15:10  sloot
+
+	* [r15786] include/folia/folia.h: oesp, parameter is const
+
+2013-03-07 15:06  sloot
+
+	* [r15784] include/folia/folia.h, src/folia.cxx,
+	  src/foliautils.cxx: implemeneted _lang attribute for TextContent
+
+2013-03-07 09:32  sloot
+
+	* [r15778] src/folia.cxx: be more picky on the 'type' atribute in
+	  AlignReference
+
+2013-03-07 09:13  sloot
+
+	* [r15777] src/foliautils.cxx: fixed NCname checking. A ':' may not
+	  be part of it.
+
+2013-03-06 09:21  sloot
+
+	* [r15763] src/folia.cxx: added some comments
+
+2013-02-28 14:54  sloot
+
+	* [r15747] src/folia.cxx: add xlink support for href in Alignment
+
+2013-02-28 13:27  sloot
+
+	* [r15745] include/folia/folia.h, include/folia/foliautils.h,
+	  src/folia.cxx, src/foliautils.cxx: String class updated. it an
+	  Annotation now
+
+2013-02-26 16:49  sloot
+
+	* [r15733] include/folia/folia.h, include/folia/foliautils.h,
+	  src/folia.cxx, src/foliautils.cxx: New Substring class. Not
+	  finished
+
+2013-01-07 14:53  sloot
+
+	* [r15570] include/folia/document.h, include/folia/folia.h,
+	  include/folia/foliautils.h, src/document.cxx, src/folia.cxx,
+	  src/foliautils.cxx, src/simpletest.cxx: Bump year
+
+2012-12-05 22:21  sloot
+
+	* [r15527] src/document.cxx: added 'now()' default for datetime
+	  declaration
+
+2012-12-05 13:43  sloot
+
+	* [r15517] src/document.cxx: fixed a problem with NO_ANN nodes
+
+2012-12-05 08:55  sloot
+
+	* [r15515] include/folia/folia.h, include/folia/foliautils.h,
+	  src/folia.cxx: adapted to some of Maarten's changed. not all
+	  yet..
+
+2012-11-29 13:21  sloot
+
+	* [r15482] include/folia/foliautils.h, src/foliautils.cxx: add
+	  convenient function
+
+2012-11-13 10:14  sloot
+
+	* [r15420] include/folia/folia.h, src/folia.cxx: added a (set)
+	  parameter to pos() and lemma() functions
+
+2012-10-30 12:50  mvgompel
+
+	* [r15368] bootstrap: bootstrap fix
+
+2012-10-30 09:55  sloot
+
+	* [r15354] include/folia/document.h, src/document.cxx: improved
+	  handling of style-sheet processing instructions
+	  for now we REJECT multiple test/xsl types.
+
+2012-10-29 14:46  sloot
+
+	* [r15348] src/folia.cxx: relax constraints on Content node
+
+2012-10-22 15:08  sloot
+
+	* [r15303] include/folia/folia.h: modified addAlternative()
+
+2012-10-22 14:23  sloot
+
+	* [r15301] include/folia/folia.h, src/folia.cxx: fiddle with
+	  addable atletnatives and morhological layers.
+	  It is a bit messy!
+
+2012-10-10 12:50  sloot
+
+	* [r15276] include/folia/document.h, include/folia/foliautils.h:
+	  safeguards
+
+2012-10-08 14:20  sloot
+
+	* [r15259] src/document.cxx: make sure we produce UTF-8
+
+2012-10-02 09:33  sloot
+
+	* [r15239] NEWS: some NEWS
+
+2012-10-02 09:18  sloot
+
+	* [r15237] include/folia/folia.h, src/folia.cxx: some fixes to get
+	  all working
+
+2012-10-01 15:44  sloot
+
+	* [r15234] include/folia/folia.h, include/folia/foliautils.h,
+	  src/document.cxx, src/folia.cxx, src/foliautils.cxx: started
+	  implementing new FoLiA features like coreference etc.
+
+2012-09-27 12:34  sloot
+
+	* [r15225] include/folia/folia.h, include/folia/foliautils.h,
+	  src/folia.cxx, src/foliautils.cxx: small fixes in Metric stuff
+
+2012-09-27 12:14  sloot
+
+	* [r15223] include/folia/folia.h, include/folia/foliautils.h,
+	  src/folia.cxx, src/foliautils.cxx: added metric stuff
+
+2012-09-27 10:00  sloot
+
+	* [r15222] include/folia/folia.h, include/folia/foliautils.h,
+	  src/folia.cxx, src/foliautils.cxx: added ValueFeature. Not
+	  completed yet.
+
+2012-09-04 14:45  sloot
+
+	* [r15159] src/folia.cxx: added comment
+
+2012-08-09 12:44  sloot
+
+	* [r15090] configure.ac, include/folia/document.h,
+	  include/folia/foliautils.h, src/document.cxx, src/folia.cxx,
+	  src/foliautils.cxx: more TiCC suff used
+
+2012-08-08 09:05  sloot
+
+	* [r15063] src/folia.cxx: accept more
+
+2012-07-12 15:24  sloot
+
+	* [r14982] src/folia.cxx: fix
+
+2012-07-11 15:14  sloot
+
+	* [r14977] include/folia/foliautils.h, src/document.cxx,
+	  src/folia.cxx, src/foliautils.cxx: added validity check for
+	  xml:id's
+	  Also ALL libxml2 Parser warnings wil handled as an eror!
+
+2012-07-11 08:13  sloot
+
+	* [r14974] src/folia.cxx: small change in PlaceHolder stuff
+
+2012-07-09 13:11  sloot
+
+	* [r14967] include/folia/folia.h, src/folia.cxx: fixed PlaceHolder
+	  stuff
+
+2012-07-04 09:11  sloot
+
+	* [r14948] include/folia/document.h, include/folia/folia.h,
+	  src/document.cxx, src/folia.cxx: added methods to extract all
+	  sentenceParts from a document. And to extract Words and
+	  Placeholders from sentences.
+
+2012-07-02 10:04  sloot
+
+	* [r14938] include/folia/folia.h, src/folia.cxx: added
+	  abstractionlayer. alloe N attribute foro suggestion.
+
+2012-06-20 10:24  sloot
+
+	* [r14899] include/folia/foliautils.h, src/document.cxx,
+	  src/folia.cxx, src/foliautils.cxx: cleaner datetime handling, and
+	  without leaks!
+
+2012-06-19 08:20  sloot
+
+	* [r14887] include/folia/folia.h, src/folia.cxx: simplified
+	  datetime handling
+
+2012-06-18 16:36  sloot
+
+	* [r14885] include/folia/document.h, include/folia/foliautils.h,
+	  src/document.cxx, src/folia.cxx, src/foliautils.cxx: added
+	  datetime defaults
+
+2012-06-14 14:22  sloot
+
+	* [r14870] include/folia/document.h, include/folia/folia.h,
+	  include/folia/foliautils.h, src/document.cxx, src/folia.cxx,
+	  src/foliautils.cxx: revoked smart idea about accept
+	  added a canonical option to xml generation, to make comparisions
+	  easy
+
+2012-06-13 15:53  sloot
+
+	* [r14859] src/folia.cxx: more generic and less error-prone
+	  solution for filling _accepted_data
+	  (until everyone has a modern compiler)
+
+2012-06-13 15:08  sloot
+
+	* [r14857] include/folia/folia.h, src/folia.cxx: some fixes.
+
+2012-06-13 09:30  sloot
+
+	* [r14855] src/document.cxx, src/folia.cxx: fixed timedevent stuff
+
+2012-06-12 15:55  sloot
+
+	* [r14854] include/folia/folia.h, src/folia.cxx: a bit of cleaning
+	  done
+
+2012-06-12 15:27  sloot
+
+	* [r14852] include/folia/folia.h, include/folia/foliautils.h,
+	  src/folia.cxx, src/foliautils.cxx: first, somewhat clumsy,
+	  implementation of Alignment
+
+2012-06-12 11:01  sloot
+
+	* [r14851] include/folia/folia.h, src/folia.cxx: implemented
+	  toktext()
+
+2012-06-12 09:08  sloot
+
+	* [r14848] include/folia/folia.h, src/document.cxx, src/folia.cxx:
+	  removed error attribute from ErrorDetection
+
+2012-04-23 12:14  sloot
+
+	* [r14680] src/folia.cxx, src/foliautils.cxx: headfeat ==>
+	  headfeature
+
+2012-04-23 09:49  sloot
+
+	* [r14679] include/folia/folia.h, src/folia.cxx: so we postpone
+	  checking of required attributes until we append the node.
+	  This makes construction more flexible
+
+2012-04-23 08:07  sloot
+
+	* [r14677] src/folia.cxx: reverted change because Maarten reverted
+	  his thoughts
+
+2012-04-20 12:40  sloot
+
+	* [r14673] src/folia.cxx: avoid appending nodes without ID. same
+	  should be done voor _set and maybe more.
+	  later...
+
+2012-04-18 16:14  sloot
+
+	* [r14667] include/folia/document.h, src/document.cxx: improved
+	  namespace handling
+
+2012-04-18 15:45  sloot
+
+	* [r14666] src/document.cxx: attempt to fix identation of
+	  annotations.
+
+2012-04-18 14:54  sloot
+
+	* [r14665] src/document.cxx, src/folia.cxx: more maarten-compliant
+
+2012-04-18 14:12  sloot
+
+	* [r14664] include/folia/document.h, src/document.cxx,
+	  src/folialint.cxx: no real change, except for folialint
+
+2012-04-18 11:11  sloot
+
+	* [r14663] include/folia/foliautils.h, src/folia.cxx,
+	  src/foliautils.cxx: DOMAIN ==> DOMEIN
+	  It seems to be a 'special' or 'reserved' word
+
+2012-04-18 10:52  sloot
+
+	* [r14662] src/folialint.cxx: fix 1
+
+2012-04-18 10:44  sloot
+
+	* [r14660] include/folia/folia.h, src/Makefile.am, src/folia.cxx,
+	  src/folialint.cxx: lots of adaptations to new insights.
+	  started to implement a 'folialint' program for simple checking.
+
+2012-04-17 16:13  sloot
+
+	* [r14659] include/folia/folia.h, include/folia/foliautils.h,
+	  src/document.cxx, src/foliautils.cxx: beterder
+
+2012-04-17 16:00  sloot
+
+	* [r14658] include/folia/folia.h, include/folia/foliautils.h,
+	  src/folia.cxx, src/foliautils.cxx: some cleanup and refactoring
+
+2012-04-17 14:25  sloot
+
+	* [r14656] include/folia/folia.h, include/folia/foliautils.h,
+	  src/document.cxx, src/folia.cxx, src/foliautils.cxx,
+	  src/simpletest.cxx: added some sanity tests, an used them to weed
+	  out problems that were never a problem yet
+
+2012-03-29 08:42  sloot
+
+	* [r14584] configure.ac: bump version after release
+
+2012-03-29 08:23  sloot
+
+	* [r14582] NEWS: get ready for release
+
 2012-03-19 15:48  sloot
 
 	* [r14476] include/folia/folia.h, src/folia.cxx: cleaning up the
diff --git a/INSTALL b/INSTALL
index 7d1c323..a1e89e1 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,8 +1,8 @@
 Installation Instructions
 *************************
 
-Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
-2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+Copyright (C) 1994-1996, 1999-2002, 2004-2011 Free Software Foundation,
+Inc.
 
    Copying and distribution of this file, with or without modification,
 are permitted in any medium without royalty provided the copyright
@@ -226,6 +226,11 @@ order to use an ANSI C compiler:
 
 and if that doesn't work, install pre-built binaries of GCC for HP-UX.
 
+   HP-UX `make' updates targets which have the same time stamps as
+their prerequisites, which makes it generally unusable when shipped
+generated files such as `configure' are involved.  Use GNU `make'
+instead.
+
    On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
 parse its `<wchar.h>' header file.  The option `-nodtk' can be used as
 a workaround.  If GNU CC is not installed, it is therefore recommended
diff --git a/Makefile.in b/Makefile.in
index 8d1a1b8..8029cff 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,9 +1,9 @@
-# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# Makefile.in generated by automake 1.11.3 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
-# Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -87,6 +87,12 @@ am__nobase_list = $(am__nobase_strip_setup); \
 am__base_list = \
   sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
   sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+  test -z "$$files" \
+    || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+    || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+         $(am__cd) "$$dir" && rm -f $$files; }; \
+  }
 am__installdirs = "$(DESTDIR)$(pkgconfigdir)"
 DATA = $(pkgconfig_DATA)
 RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive	\
@@ -101,9 +107,11 @@ DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 distdir = $(PACKAGE)-$(VERSION)
 top_distdir = $(distdir)
 am__remove_distdir = \
-  { test ! -d "$(distdir)" \
-    || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
-         && rm -fr "$(distdir)"; }; }
+  if test -d "$(distdir)"; then \
+    find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
+      && rm -rf "$(distdir)" \
+      || { sleep 5 && rm -rf "$(distdir)"; }; \
+  else :; fi
 am__relativize = \
   dir0=`pwd`; \
   sed_first='s,^\([^/]*\)/.*$$,\1,'; \
@@ -132,6 +140,8 @@ am__relativize = \
 DIST_ARCHIVES = $(distdir).tar.gz
 GZIP_ENV = --best
 distuninstallcheck_listfiles = find . -type f -print
+am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
+  | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
 distcleancheck_listfiles = find . -type f -print
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -262,6 +272,8 @@ sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
 sysconfdir = @sysconfdir@
 target_alias = @target_alias@
+ticcutils_CFLAGS = @ticcutils_CFLAGS@
+ticcutils_LIBS = @ticcutils_LIBS@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
@@ -274,7 +286,7 @@ all: config.h
 	$(MAKE) $(AM_MAKEFLAGS) all-recursive
 
 .SUFFIXES:
-am--refresh:
+am--refresh: Makefile
 	@:
 $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
@@ -310,10 +322,8 @@ $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 $(am__aclocal_m4_deps):
 
 config.h: stamp-h1
-	@if test ! -f $@; then \
-	  rm -f stamp-h1; \
-	  $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \
-	else :; fi
+	@if test ! -f $@; then rm -f stamp-h1; else :; fi
+	@if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi
 
 stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
 	@rm -f stamp-h1
@@ -353,9 +363,7 @@ uninstall-pkgconfigDATA:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \
 	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
-	test -n "$$files" || exit 0; \
-	echo " ( cd '$(DESTDIR)$(pkgconfigdir)' && rm -f" $$files ")"; \
-	cd "$(DESTDIR)$(pkgconfigdir)" && rm -f $$files
+	dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir)
 
 # This directory's subdirectories are mostly independent; you can cd
 # into them and run `make' without going through this Makefile.
@@ -564,7 +572,11 @@ dist-gzip: distdir
 	$(am__remove_distdir)
 
 dist-bzip2: distdir
-	tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
+	tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2
+	$(am__remove_distdir)
+
+dist-lzip: distdir
+	tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz
 	$(am__remove_distdir)
 
 dist-lzma: distdir
@@ -572,7 +584,7 @@ dist-lzma: distdir
 	$(am__remove_distdir)
 
 dist-xz: distdir
-	tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz
+	tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
 	$(am__remove_distdir)
 
 dist-tarZ: distdir
@@ -603,6 +615,8 @@ distcheck: dist
 	  bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
 	*.tar.lzma*) \
 	  lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\
+	*.tar.lz*) \
+	  lzip -dc $(distdir).tar.lz | $(am__untar) ;;\
 	*.tar.xz*) \
 	  xz -dc $(distdir).tar.xz | $(am__untar) ;;\
 	*.tar.Z*) \
@@ -622,6 +636,7 @@ distcheck: dist
 	  && am__cwd=`pwd` \
 	  && $(am__cd) $(distdir)/_build \
 	  && ../configure --srcdir=.. --prefix="$$dc_install_base" \
+	    $(AM_DISTCHECK_CONFIGURE_FLAGS) \
 	    $(DISTCHECK_CONFIGURE_FLAGS) \
 	  && $(MAKE) $(AM_MAKEFLAGS) \
 	  && $(MAKE) $(AM_MAKEFLAGS) dvi \
@@ -650,8 +665,16 @@ distcheck: dist
 	  list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
 	  sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
 distuninstallcheck:
-	@$(am__cd) '$(distuninstallcheck_dir)' \
-	&& test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
+	@test -n '$(distuninstallcheck_dir)' || { \
+	  echo 'ERROR: trying to run $@ with an empty' \
+	       '$$(distuninstallcheck_dir)' >&2; \
+	  exit 1; \
+	}; \
+	$(am__cd) '$(distuninstallcheck_dir)' || { \
+	  echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \
+	  exit 1; \
+	}; \
+	test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \
 	   || { echo "ERROR: files left after uninstall:" ; \
 	        if test -n "$(DESTDIR)"; then \
 	          echo "  (check DESTDIR support)"; \
@@ -685,10 +708,15 @@ install-am: all-am
 
 installcheck: installcheck-recursive
 install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
-	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
-	  `test -z '$(STRIP)' || \
-	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+	if test -z '$(STRIP)'; then \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	      install; \
+	else \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+	fi
 mostlyclean-generic:
 
 clean-generic:
@@ -776,8 +804,8 @@ uninstall-am: uninstall-pkgconfigDATA
 .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
 	all all-am am--refresh check check-am clean clean-generic \
 	clean-libtool ctags ctags-recursive dist dist-all dist-bzip2 \
-	dist-gzip dist-lzma dist-shar dist-tarZ dist-xz dist-zip \
-	distcheck distclean distclean-generic distclean-hdr \
+	dist-gzip dist-lzip dist-lzma dist-shar dist-tarZ dist-xz \
+	dist-zip distcheck distclean distclean-generic distclean-hdr \
 	distclean-libtool distclean-tags distcleancheck distdir \
 	distuninstallcheck dvi dvi-am html html-am info info-am \
 	install install-am install-data install-data-am install-dvi \
diff --git a/NEWS b/NEWS
index 14a6b4a..1d143a2 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,13 @@
+0.10
+  * some XML stuff is moved to ticcutils
+  * also use some other goodies form ticcutils
+  * now implements new nodes like Metric, Coreferences and Semroles
+    (follwing the FoLiA 0.9 specs)
+  * a lot of code improvement too, including some bug fixes
+
+0.9 
+  * lost in tranistion
+
 0.8 2012-03-29
   * reworked and improved handling of (default) annotation sets.
     We are more strict now.
diff --git a/aclocal.m4 b/aclocal.m4
index d59b196..cef13c0 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,7 +1,8 @@
-# generated automatically by aclocal 1.11.1 -*- Autoconf -*-
+# generated automatically by aclocal 1.11.3 -*- Autoconf -*-
 
 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-# 2005, 2006, 2007, 2008, 2009  Free Software Foundation, Inc.
+# 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation,
+# Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -19,12 +20,15 @@ You have another version of autoconf.  It may work, but is not guaranteed to.
 If you have problems, you may need to regenerate the build system entirely.
 To do so, use the procedure documented by the package, typically `autoreconf'.])])
 
-# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008, 2011 Free Software
+# Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
+# serial 1
+
 # AM_AUTOMAKE_VERSION(VERSION)
 # ----------------------------
 # Automake X.Y traces this macro to ensure aclocal.m4 has been
@@ -34,7 +38,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION],
 [am__api_version='1.11'
 dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
 dnl require some minimum version.  Point them to the right macro.
-m4_if([$1], [1.11.1], [],
+m4_if([$1], [1.11.3], [],
       [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
 ])
 
@@ -50,19 +54,21 @@ m4_define([_AM_AUTOCONF_VERSION], [])
 # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
 # This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-[AM_AUTOMAKE_VERSION([1.11.1])dnl
+[AM_AUTOMAKE_VERSION([1.11.3])dnl
 m4_ifndef([AC_AUTOCONF_VERSION],
   [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
 _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
 
 # AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
 
-# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
+# Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
+# serial 1
+
 # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
 # $ac_aux_dir to `$srcdir/foo'.  In other projects, it is set to
 # `$srcdir', `$srcdir/..', or `$srcdir/../..'.
@@ -144,14 +150,14 @@ AC_CONFIG_COMMANDS_PRE(
 Usually this means the macro was only invoked conditionally.]])
 fi])])
 
-# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009
-# Free Software Foundation, Inc.
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009,
+# 2010, 2011 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 10
+# serial 12
 
 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
 # written in clear, in which case automake, when reading aclocal.m4,
@@ -191,6 +197,7 @@ AC_CACHE_CHECK([dependency style of $depcc],
   # instance it was reported that on HP-UX the gcc test will end up
   # making a dummy file named `D' -- because `-MD' means `put the output
   # in D'.
+  rm -rf conftest.dir
   mkdir conftest.dir
   # Copy depcomp to subdir because otherwise we won't find it if we're
   # using a relative directory.
@@ -255,7 +262,7 @@ AC_CACHE_CHECK([dependency style of $depcc],
 	break
       fi
       ;;
-    msvisualcpp | msvcmsys)
+    msvc7 | msvc7msys | msvisualcpp | msvcmsys)
       # This compiler won't grok `-c -o', but also, the minuso test has
       # not run yet.  These depmodes are late enough in the game, and
       # so weak that their functioning should not be impacted.
@@ -320,10 +327,13 @@ AC_DEFUN([AM_DEP_TRACK],
 if test "x$enable_dependency_tracking" != xno; then
   am_depcomp="$ac_aux_dir/depcomp"
   AMDEPBACKSLASH='\'
+  am__nodep='_no'
 fi
 AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
 AC_SUBST([AMDEPBACKSLASH])dnl
 _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
+AC_SUBST([am__nodep])dnl
+_AM_SUBST_NOTMAKE([am__nodep])dnl
 ])
 
 # Generate code to set up dependency tracking.              -*- Autoconf -*-
@@ -545,12 +555,15 @@ for _am_header in $config_headers :; do
 done
 echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
 
-# Copyright (C) 2001, 2003, 2005, 2008  Free Software Foundation, Inc.
+# Copyright (C) 2001, 2003, 2005, 2008, 2011 Free Software Foundation,
+# Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
+# serial 1
+
 # AM_PROG_INSTALL_SH
 # ------------------
 # Define $install_sh.
@@ -682,12 +695,15 @@ else
 fi
 ])
 
-# Copyright (C) 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# Copyright (C) 2003, 2004, 2005, 2006, 2011 Free Software Foundation,
+# Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
+# serial 1
+
 # AM_PROG_MKDIR_P
 # ---------------
 # Check for `mkdir -p'.
@@ -710,13 +726,14 @@ esac
 
 # Helper functions for option handling.                     -*- Autoconf -*-
 
-# Copyright (C) 2001, 2002, 2003, 2005, 2008  Free Software Foundation, Inc.
+# Copyright (C) 2001, 2002, 2003, 2005, 2008, 2010 Free Software
+# Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 4
+# serial 5
 
 # _AM_MANGLE_OPTION(NAME)
 # -----------------------
@@ -724,13 +741,13 @@ AC_DEFUN([_AM_MANGLE_OPTION],
 [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
 
 # _AM_SET_OPTION(NAME)
-# ------------------------------
+# --------------------
 # Set option NAME.  Presently that only means defining a flag for this option.
 AC_DEFUN([_AM_SET_OPTION],
 [m4_define(_AM_MANGLE_OPTION([$1]), 1)])
 
 # _AM_SET_OPTIONS(OPTIONS)
-# ----------------------------------
+# ------------------------
 # OPTIONS is a space-separated list of Automake options.
 AC_DEFUN([_AM_SET_OPTIONS],
 [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
@@ -806,12 +823,14 @@ Check your system clock])
 fi
 AC_MSG_RESULT(yes)])
 
-# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
+# Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
+# serial 1
+
 # AM_PROG_INSTALL_STRIP
 # ---------------------
 # One issue with vendor `install' (even GNU) is that you can't
@@ -834,13 +853,13 @@ fi
 INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
 AC_SUBST([INSTALL_STRIP_PROGRAM])])
 
-# Copyright (C) 2006, 2008  Free Software Foundation, Inc.
+# Copyright (C) 2006, 2008, 2010 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 2
+# serial 3
 
 # _AM_SUBST_NOTMAKE(VARIABLE)
 # ---------------------------
@@ -849,13 +868,13 @@ AC_SUBST([INSTALL_STRIP_PROGRAM])])
 AC_DEFUN([_AM_SUBST_NOTMAKE])
 
 # AM_SUBST_NOTMAKE(VARIABLE)
-# ---------------------------
+# --------------------------
 # Public sister of _AM_SUBST_NOTMAKE.
 AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
 
 # Check how to create a tarball.                            -*- Autoconf -*-
 
-# Copyright (C) 2004, 2005  Free Software Foundation, Inc.
+# Copyright (C) 2004, 2005, 2012 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -877,10 +896,11 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
 # a tarball read from stdin.
 #     $(am__untar) < result.tar
 AC_DEFUN([_AM_PROG_TAR],
-[# Always define AMTAR for backward compatibility.
-AM_MISSING_PROG([AMTAR], [tar])
+[# Always define AMTAR for backward compatibility.  Yes, it's still used
+# in the wild :-(  We should find a proper way to deprecate it ...
+AC_SUBST([AMTAR], ['$${TAR-tar}'])
 m4_if([$1], [v7],
-     [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'],
+     [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'],
      [m4_case([$1], [ustar],, [pax],,
               [m4_fatal([Unknown tar format])])
 AC_MSG_CHECKING([how to create a $1 tar archive])
diff --git a/bootstrap b/bootstrap
index 8f69e7c..395ae1f 100644
--- a/bootstrap
+++ b/bootstrap
@@ -64,7 +64,7 @@ EOT
    fi
 
 
-if $automake --version|head -1 |grep '1\.[4-8]'; then
+if $automake --version|head -1 |grep ' 1\.[4-8]'; then
     echo "automake 1.4-1.8 is active. You should use automake 1.9 or later"
     if test -f /etc/debian_version; then
         echo " sudo apt-get install automake1.9"
@@ -73,7 +73,7 @@ if $automake --version|head -1 |grep '1\.[4-8]'; then
     exit 1
 fi
 
-if $aclocal --version|head -1 |grep '1\.[4-8]'; then
+if $aclocal --version|head -1 |grep ' 1\.[4-8]'; then
     echo "aclocal 1.4-1.8 is active. You should use aclocal 1.9 or later"
     if test -f /etc/debian_version; then	
         echo " sudo apt-get install aclocal1.9"
diff --git a/config.guess b/config.guess
index 40eaed4..d622a44 100755
--- a/config.guess
+++ b/config.guess
@@ -2,9 +2,9 @@
 # Attempt to guess a canonical system name.
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
 #   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
-#   2011 Free Software Foundation, Inc.
+#   2011, 2012 Free Software Foundation, Inc.
 
-timestamp='2011-05-11'
+timestamp='2012-02-10'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -17,9 +17,7 @@ timestamp='2011-05-11'
 # General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
-# 02110-1301, USA.
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
 #
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -57,8 +55,8 @@ GNU config.guess ($timestamp)
 
 Originally written by Per Bothner.
 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free
-Software Foundation, Inc.
+2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
+Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -145,7 +143,7 @@ UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
 case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
     *:NetBSD:*:*)
 	# NetBSD (nbsd) targets should (where applicable) match one or
-	# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+	# more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
 	# *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
 	# switched to ELF, *-*-netbsd* would select the old
 	# object file format.  This provides both forward
@@ -792,13 +790,12 @@ EOF
 	echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
 	exit ;;
     *:FreeBSD:*:*)
-	case ${UNAME_MACHINE} in
-	    pc98)
-		echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+	UNAME_PROCESSOR=`/usr/bin/uname -p`
+	case ${UNAME_PROCESSOR} in
 	    amd64)
 		echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
 	    *)
-		echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+		echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
 	esac
 	exit ;;
     i*:CYGWIN*:*)
@@ -807,6 +804,9 @@ EOF
     *:MINGW*:*)
 	echo ${UNAME_MACHINE}-pc-mingw32
 	exit ;;
+    i*:MSYS*:*)
+	echo ${UNAME_MACHINE}-pc-msys
+	exit ;;
     i*:windows32*:*)
 	# uname -m includes "-pc" on this system.
 	echo ${UNAME_MACHINE}-mingw32
@@ -861,6 +861,13 @@ EOF
     i*86:Minix:*:*)
 	echo ${UNAME_MACHINE}-pc-minix
 	exit ;;
+    aarch64:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    aarch64_be:Linux:*:*)
+	UNAME_MACHINE=aarch64_be
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
     alpha:Linux:*:*)
 	case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
 	  EV5)   UNAME_MACHINE=alphaev5 ;;
@@ -895,13 +902,16 @@ EOF
 	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit ;;
     cris:Linux:*:*)
-	echo cris-axis-linux-gnu
+	echo ${UNAME_MACHINE}-axis-linux-gnu
 	exit ;;
     crisv32:Linux:*:*)
-	echo crisv32-axis-linux-gnu
+	echo ${UNAME_MACHINE}-axis-linux-gnu
 	exit ;;
     frv:Linux:*:*)
-	echo frv-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    hexagon:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit ;;
     i*86:Linux:*:*)
 	LIBC=gnu
@@ -943,7 +953,7 @@ EOF
 	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
 	;;
     or32:Linux:*:*)
-	echo or32-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit ;;
     padre:Linux:*:*)
 	echo sparc-unknown-linux-gnu
@@ -978,13 +988,13 @@ EOF
 	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit ;;
     tile*:Linux:*:*)
-	echo ${UNAME_MACHINE}-tilera-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit ;;
     vax:Linux:*:*)
 	echo ${UNAME_MACHINE}-dec-linux-gnu
 	exit ;;
     x86_64:Linux:*:*)
-	echo x86_64-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit ;;
     xtensa*:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-gnu
@@ -1315,6 +1325,9 @@ EOF
     i*86:AROS:*:*)
 	echo ${UNAME_MACHINE}-pc-aros
 	exit ;;
+    x86_64:VMkernel:*:*)
+	echo ${UNAME_MACHINE}-unknown-esx
+	exit ;;
 esac
 
 #echo '(No uname command or uname output not recognized.)' 1>&2
diff --git a/config.sub b/config.sub
index 30fdca8..c894da4 100755
--- a/config.sub
+++ b/config.sub
@@ -2,9 +2,9 @@
 # Configuration validation subroutine script.
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
 #   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
-#   2011 Free Software Foundation, Inc.
+#   2011, 2012 Free Software Foundation, Inc.
 
-timestamp='2011-03-23'
+timestamp='2012-02-10'
 
 # This file is (in principle) common to ALL GNU software.
 # The presence of a machine in this file suggests that SOME GNU software
@@ -21,9 +21,7 @@ timestamp='2011-03-23'
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
-# 02110-1301, USA.
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
 #
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -76,8 +74,8 @@ version="\
 GNU config.sub ($timestamp)
 
 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free
-Software Foundation, Inc.
+2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
+Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -132,6 +130,10 @@ case $maybe_os in
     os=-$maybe_os
     basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
     ;;
+  android-linux)
+    os=-linux-android
+    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
+    ;;
   *)
     basic_machine=`echo $1 | sed 's/-[^-]*$//'`
     if [ $basic_machine != $1 ]
@@ -247,17 +249,22 @@ case $basic_machine in
 	# Some are omitted here because they have special meanings below.
 	1750a | 580 \
 	| a29k \
+	| aarch64 | aarch64_be \
 	| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
 	| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
 	| am33_2.0 \
 	| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
+        | be32 | be64 \
 	| bfin \
 	| c4x | clipper \
 	| d10v | d30v | dlx | dsp16xx \
+	| epiphany \
 	| fido | fr30 | frv \
 	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+	| hexagon \
 	| i370 | i860 | i960 | ia64 \
 	| ip2k | iq2000 \
+	| le32 | le64 \
 	| lm32 \
 	| m32c | m32r | m32rle | m68000 | m68k | m88k \
 	| maxq | mb | microblaze | mcore | mep | metag \
@@ -291,7 +298,7 @@ case $basic_machine in
 	| pdp10 | pdp11 | pj | pjl \
 	| powerpc | powerpc64 | powerpc64le | powerpcle \
 	| pyramid \
-	| rx \
+	| rl78 | rx \
 	| score \
 	| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
 	| sh64 | sh64le \
@@ -300,7 +307,7 @@ case $basic_machine in
 	| spu \
 	| tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
 	| ubicom32 \
-	| v850 | v850e \
+	| v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
 	| we32k \
 	| x86 | xc16x | xstormy16 | xtensa \
 	| z8k | z80)
@@ -315,8 +322,7 @@ case $basic_machine in
 	c6x)
 		basic_machine=tic6x-unknown
 		;;
-	m6811 | m68hc11 | m6812 | m68hc12 | picochip)
-		# Motorola 68HC11/12.
+	m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip)
 		basic_machine=$basic_machine-unknown
 		os=-none
 		;;
@@ -329,7 +335,10 @@ case $basic_machine in
 	strongarm | thumb | xscale)
 		basic_machine=arm-unknown
 		;;
-
+	xgate)
+		basic_machine=$basic_machine-unknown
+		os=-none
+		;;
 	xscaleeb)
 		basic_machine=armeb-unknown
 		;;
@@ -352,11 +361,13 @@ case $basic_machine in
 	# Recognize the basic CPU types with company name.
 	580-* \
 	| a29k-* \
+	| aarch64-* | aarch64_be-* \
 	| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
 	| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
 	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
 	| arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
 	| avr-* | avr32-* \
+	| be32-* | be64-* \
 	| bfin-* | bs2000-* \
 	| c[123]* | c30-* | [cjt]90-* | c4x-* \
 	| clipper-* | craynv-* | cydra-* \
@@ -365,8 +376,10 @@ case $basic_machine in
 	| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
 	| h8300-* | h8500-* \
 	| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+	| hexagon-* \
 	| i*86-* | i860-* | i960-* | ia64-* \
 	| ip2k-* | iq2000-* \
+	| le32-* | le64-* \
 	| lm32-* \
 	| m32c-* | m32r-* | m32rle-* \
 	| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
@@ -400,7 +413,7 @@ case $basic_machine in
 	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
 	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
 	| pyramid-* \
-	| romp-* | rs6000-* | rx-* \
+	| rl78-* | romp-* | rs6000-* | rx-* \
 	| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
 	| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
 	| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
@@ -408,10 +421,11 @@ case $basic_machine in
 	| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
 	| tahoe-* \
 	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
-	| tile-* | tilegx-* \
+	| tile*-* \
 	| tron-* \
 	| ubicom32-* \
-	| v850-* | v850e-* | vax-* \
+	| v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
+	| vax-* \
 	| we32k-* \
 	| x86-* | x86_64-* | xc16x-* | xps100-* \
 	| xstormy16-* | xtensa*-* \
@@ -711,7 +725,6 @@ case $basic_machine in
 	i370-ibm* | ibm*)
 		basic_machine=i370-ibm
 		;;
-# I'm not sure what "Sysv32" means.  Should this be sysv3.2?
 	i*86v32)
 		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
 		os=-sysv32
@@ -808,10 +821,18 @@ case $basic_machine in
 	ms1-*)
 		basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
 		;;
+	msys)
+		basic_machine=i386-pc
+		os=-msys
+		;;
 	mvs)
 		basic_machine=i370-ibm
 		os=-mvs
 		;;
+	nacl)
+		basic_machine=le32-unknown
+		os=-nacl
+		;;
 	ncr3000)
 		basic_machine=i486-ncr
 		os=-sysv4
@@ -1120,13 +1141,8 @@ case $basic_machine in
 		basic_machine=t90-cray
 		os=-unicos
 		;;
-	# This must be matched before tile*.
-	tilegx*)
-		basic_machine=tilegx-unknown
-		os=-linux-gnu
-		;;
 	tile*)
-		basic_machine=tile-unknown
+		basic_machine=$basic_machine-unknown
 		os=-linux-gnu
 		;;
 	tx39)
@@ -1336,7 +1352,7 @@ case $os in
 	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
 	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
 	      | -chorusos* | -chorusrdb* | -cegcc* \
-	      | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+	      | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
 	      | -mingw32* | -linux-gnu* | -linux-android* \
 	      | -linux-newlib* | -linux-uclibc* \
 	      | -uxpv* | -beos* | -mpeix* | -udk* \
@@ -1548,9 +1564,6 @@ case $basic_machine in
 		;;
 	m68000-sun)
 		os=-sunos3
-		# This also exists in the configure program, but was not the
-		# default.
-		# os=-sunos4
 		;;
 	m68*-cisco)
 		os=-aout
diff --git a/configure b/configure
index 5530d59..92f7ab1 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.68 for libfolia 0.9.
+# Generated by GNU Autoconf 2.68 for libfolia 0.10.
 #
 # Report bugs to <timbl at uvt.nl>.
 #
@@ -569,8 +569,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='libfolia'
 PACKAGE_TARNAME='libfolia'
-PACKAGE_VERSION='0.9'
-PACKAGE_STRING='libfolia 0.9'
+PACKAGE_VERSION='0.10'
+PACKAGE_STRING='libfolia 0.10'
 PACKAGE_BUGREPORT='timbl at uvt.nl'
 PACKAGE_URL=''
 
@@ -615,6 +615,8 @@ ac_subst_vars='am__EXEEXT_FALSE
 am__EXEEXT_TRUE
 LTLIBOBJS
 LIBOBJS
+ticcutils_LIBS
+ticcutils_CFLAGS
 ICU_IOLIBS
 ICU_LIBS
 ICU_LIBPATH
@@ -669,6 +671,7 @@ RANLIB
 am__fastdepCXX_FALSE
 am__fastdepCXX_TRUE
 CXXDEPMODE
+am__nodep
 AMDEPBACKSLASH
 AMDEP_FALSE
 AMDEP_TRUE
@@ -755,6 +758,7 @@ with_gnu_ld
 with_sysroot
 enable_libtool_lock
 with_icu
+with_ticcutils
 '
       ac_precious_vars='build_alias
 host_alias
@@ -773,7 +777,9 @@ PKG_CONFIG
 PKG_CONFIG_PATH
 PKG_CONFIG_LIBDIR
 XML2_CFLAGS
-XML2_LIBS'
+XML2_LIBS
+ticcutils_CFLAGS
+ticcutils_LIBS'
 
 
 # Initialize some variables set by options.
@@ -1316,7 +1322,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures libfolia 0.9 to adapt to many kinds of systems.
+\`configure' configures libfolia 0.10 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1386,7 +1392,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of libfolia 0.9:";;
+     short | recursive ) echo "Configuration of libfolia 0.10:";;
    esac
   cat <<\_ACEOF
 
@@ -1411,6 +1417,9 @@ Optional Packages:
   --with-sysroot=DIR Search for dependent libraries within DIR
                         (or the compiler's sysroot if not specified).
   --with-icu=DIR       use ICU installed in <DIR>
+  --with-ticcutils=DIR       use ticcutils installed in <DIR>;
+               note that you can install ticcutils in a non-default directory with
+               ./configure --prefix=<DIR> in the ticcutils installation directory
 
 Some influential environment variables:
   CXX         C++ compiler command
@@ -1431,6 +1440,10 @@ Some influential environment variables:
               path overriding pkg-config's built-in search path
   XML2_CFLAGS C compiler flags for XML2, overriding pkg-config
   XML2_LIBS   linker flags for XML2, overriding pkg-config
+  ticcutils_CFLAGS
+              C compiler flags for ticcutils, overriding pkg-config
+  ticcutils_LIBS
+              linker flags for ticcutils, overriding pkg-config
 
 Use these variables to override the choices made by `configure' or to help
 it to find libraries and programs with nonstandard names/locations.
@@ -1498,7 +1511,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-libfolia configure 0.9
+libfolia configure 0.10
 generated by GNU Autoconf 2.68
 
 Copyright (C) 2010 Free Software Foundation, Inc.
@@ -1951,7 +1964,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by libfolia $as_me 0.9, which was
+It was created by libfolia $as_me 0.10, which was
 generated by GNU Autoconf 2.68.  Invocation command line was
 
   $ $0 $@
@@ -2766,7 +2779,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='libfolia'
- VERSION='0.9'
+ VERSION='0.10'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -2796,11 +2809,11 @@ MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
 
 # We need awk for the "check" target.  The system "awk" is bad on
 # some platforms.
-# Always define AMTAR for backward compatibility.
-
-AMTAR=${AMTAR-"${am_missing_run}tar"}
+# Always define AMTAR for backward compatibility.  Yes, it's still used
+# in the wild :-(  We should find a proper way to deprecate it ...
+AMTAR='$${TAR-tar}'
 
-am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'
+am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'
 
 
 
@@ -3377,6 +3390,7 @@ fi
 if test "x$enable_dependency_tracking" != xno; then
   am_depcomp="$ac_aux_dir/depcomp"
   AMDEPBACKSLASH='\'
+  am__nodep='_no'
 fi
  if test "x$enable_dependency_tracking" != xno; then
   AMDEP_TRUE=
@@ -3401,6 +3415,7 @@ else
   # instance it was reported that on HP-UX the gcc test will end up
   # making a dummy file named `D' -- because `-MD' means `put the output
   # in D'.
+  rm -rf conftest.dir
   mkdir conftest.dir
   # Copy depcomp to subdir because otherwise we won't find it if we're
   # using a relative directory.
@@ -3460,7 +3475,7 @@ else
 	break
       fi
       ;;
-    msvisualcpp | msvcmsys)
+    msvc7 | msvc7msys | msvisualcpp | msvcmsys)
       # This compiler won't grok `-c -o', but also, the minuso test has
       # not run yet.  These depmodes are late enough in the game, and
       # so weak that their functioning should not be impacted.
@@ -3621,8 +3636,8 @@ esac
 
 
 
-macro_version='2.4'
-macro_revision='1.3293'
+macro_version='2.4.2'
+macro_revision='1.3337'
 
 
 
@@ -4331,6 +4346,7 @@ else
   # instance it was reported that on HP-UX the gcc test will end up
   # making a dummy file named `D' -- because `-MD' means `put the output
   # in D'.
+  rm -rf conftest.dir
   mkdir conftest.dir
   # Copy depcomp to subdir because otherwise we won't find it if we're
   # using a relative directory.
@@ -4390,7 +4406,7 @@ else
 	break
       fi
       ;;
-    msvisualcpp | msvcmsys)
+    msvc7 | msvc7msys | msvisualcpp | msvcmsys)
       # This compiler won't grok `-c -o', but also, the minuso test has
       # not run yet.  These depmodes are late enough in the game, and
       # so weak that their functioning should not be impacted.
@@ -15211,6 +15227,7 @@ fi
 
 
 
+
 if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
 	if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
@@ -15339,6 +15356,7 @@ if test -n "$XML2_CFLAGS"; then
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
   pkg_cv_XML2_CFLAGS=`$PKG_CONFIG --cflags "libxml-2.0 >= 2.6.16 " 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
 else
   pkg_failed=yes
 fi
@@ -15355,6 +15373,7 @@ if test -n "$XML2_LIBS"; then
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
   pkg_cv_XML2_LIBS=`$PKG_CONFIG --libs "libxml-2.0 >= 2.6.16 " 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
 else
   pkg_failed=yes
 fi
@@ -15374,9 +15393,9 @@ else
         _pkg_short_errors_supported=no
 fi
         if test $_pkg_short_errors_supported = yes; then
-	        XML2_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "libxml-2.0 >= 2.6.16 " 2>&1`
+	        XML2_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libxml-2.0 >= 2.6.16 " 2>&1`
         else
-	        XML2_PKG_ERRORS=`$PKG_CONFIG --print-errors "libxml-2.0 >= 2.6.16 " 2>&1`
+	        XML2_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libxml-2.0 >= 2.6.16 " 2>&1`
         fi
 	# Put the nasty error message in config.log where it belongs
 	echo "$XML2_PKG_ERRORS" >&5
@@ -15568,7 +15587,116 @@ else
   as_fn_error $? "\"ICU support is required\"" "$LINENO" 5
 fi
 
-ac_config_files="$ac_config_files Makefile folia.pc m4/Makefile src/Makefile include/Makefile include/folia/Makefile"
+# ugly hack when PKG_CONFIG_PATH isn't defined.
+# couldn't get it to work otherwise
+if test "x$PKG_CONFIG_PATH" = x; then
+     export PKG_CONFIG_PATH=""
+fi
+
+# Check whether --with-ticcutils was given.
+if test "${with_ticcutils+set}" = set; then :
+  withval=$with_ticcutils; PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$withval/lib/pkgconfig"
+else
+  PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$prefix/lib/pkgconfig"
+fi
+
+#  AC_MSG_NOTICE( [pkg-config search path: $PKG_CONFIG_PATH] )
+
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ticcutils" >&5
+$as_echo_n "checking for ticcutils... " >&6; }
+
+if test -n "$ticcutils_CFLAGS"; then
+    pkg_cv_ticcutils_CFLAGS="$ticcutils_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"ticcutils >= 0.4 \""; } >&5
+  ($PKG_CONFIG --exists --print-errors "ticcutils >= 0.4 ") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_ticcutils_CFLAGS=`$PKG_CONFIG --cflags "ticcutils >= 0.4 " 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
+fi
+ else
+    pkg_failed=untried
+fi
+if test -n "$ticcutils_LIBS"; then
+    pkg_cv_ticcutils_LIBS="$ticcutils_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"ticcutils >= 0.4 \""; } >&5
+  ($PKG_CONFIG --exists --print-errors "ticcutils >= 0.4 ") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_ticcutils_LIBS=`$PKG_CONFIG --libs "ticcutils >= 0.4 " 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
+fi
+ else
+    pkg_failed=untried
+fi
+
+
+
+if test $pkg_failed = yes; then
+   	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi
+        if test $_pkg_short_errors_supported = yes; then
+	        ticcutils_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "ticcutils >= 0.4 " 2>&1`
+        else
+	        ticcutils_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "ticcutils >= 0.4 " 2>&1`
+        fi
+	# Put the nasty error message in config.log where it belongs
+	echo "$ticcutils_PKG_ERRORS" >&5
+
+	as_fn_error $? "Package requirements (ticcutils >= 0.4 ) were not met:
+
+$ticcutils_PKG_ERRORS
+
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
+
+Alternatively, you may set the environment variables ticcutils_CFLAGS
+and ticcutils_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details." "$LINENO" 5
+elif test $pkg_failed = untried; then
+     	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+	{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "The pkg-config script could not be found or is too old.  Make sure it
+is in your PATH or set the PKG_CONFIG environment variable to the full
+path to pkg-config.
+
+Alternatively, you may set the environment variables ticcutils_CFLAGS
+and ticcutils_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details.
+
+To get pkg-config, see <http://pkg-config.freedesktop.org/>.
+See \`config.log' for more details" "$LINENO" 5; }
+else
+	ticcutils_CFLAGS=$pkg_cv_ticcutils_CFLAGS
+	ticcutils_LIBS=$pkg_cv_ticcutils_LIBS
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+fi
+CXXFLAGS="$CXXFLAGS $ticcutils_CFLAGS"
+LIBS="$LIBS $ticcutils_LIBS"
+
+
+ac_config_files="$ac_config_files Makefile folia.pc m4/Makefile src/Makefile include/Makefile include/libfolia/Makefile"
 
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
@@ -16108,7 +16236,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by libfolia $as_me 0.9, which was
+This file was extended by libfolia $as_me 0.10, which was
 generated by GNU Autoconf 2.68.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -16174,7 +16302,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-libfolia config.status 0.9
+libfolia config.status 0.10
 configured by $0, generated by GNU Autoconf 2.68,
   with options \\"\$ac_cs_config\\"
 
@@ -16688,7 +16816,7 @@ do
     "m4/Makefile") CONFIG_FILES="$CONFIG_FILES m4/Makefile" ;;
     "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
     "include/Makefile") CONFIG_FILES="$CONFIG_FILES include/Makefile" ;;
-    "include/folia/Makefile") CONFIG_FILES="$CONFIG_FILES include/folia/Makefile" ;;
+    "include/libfolia/Makefile") CONFIG_FILES="$CONFIG_FILES include/libfolia/Makefile" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
   esac
diff --git a/configure.ac b/configure.ac
index ab42411..c4023ed 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,7 +4,7 @@
 # $URL: https://ilk.uvt.nl/svn/sources/ucto/trunk/configure.ac $
 
 AC_PREREQ(2.59)
-AC_INIT([libfolia], [0.9], [timbl at uvt.nl])
+AC_INIT([libfolia], [0.10], [timbl at uvt.nl])
 AM_INIT_AUTOMAKE
 AC_CONFIG_SRCDIR([configure.ac])
 AC_CONFIG_MACRO_DIR([m4])
@@ -72,11 +72,28 @@ else
   AC_MSG_ERROR("ICU support is required")
 fi
 
+# ugly hack when PKG_CONFIG_PATH isn't defined.
+# couldn't get it to work otherwise
+if test "x$PKG_CONFIG_PATH" = x; then
+     export PKG_CONFIG_PATH=""
+fi
+AC_ARG_WITH(ticcutils,
+       [  --with-ticcutils=DIR       use ticcutils installed in <DIR>; 
+               note that you can install ticcutils in a non-default directory with
+               ./configure --prefix=<DIR> in the ticcutils installation directory],
+       [PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$withval/lib/pkgconfig"],
+       [PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$prefix/lib/pkgconfig"])
+#  AC_MSG_NOTICE( [pkg-config search path: $PKG_CONFIG_PATH] )
+PKG_CHECK_MODULES([ticcutils], [ticcutils >= 0.4] )
+CXXFLAGS="$CXXFLAGS $ticcutils_CFLAGS"
+LIBS="$LIBS $ticcutils_LIBS"
+
+
 AC_OUTPUT([
   Makefile
   folia.pc
   m4/Makefile
   src/Makefile
   include/Makefile
-  include/folia/Makefile
+  include/libfolia/Makefile
 ])
diff --git a/depcomp b/depcomp
index df8eea7..bd0ac08 100755
--- a/depcomp
+++ b/depcomp
@@ -1,10 +1,10 @@
 #! /bin/sh
 # depcomp - compile a program generating dependencies as side-effects
 
-scriptversion=2009-04-28.21; # UTC
+scriptversion=2011-12-04.11; # UTC
 
-# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free
-# Software Foundation, Inc.
+# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010,
+# 2011 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -44,7 +44,7 @@ Environment variables:
   object      Object file output by `PROGRAMS ARGS'.
   DEPDIR      directory where to store dependencies.
   depfile     Dependency file to output.
-  tmpdepfile  Temporary file to use when outputing dependencies.
+  tmpdepfile  Temporary file to use when outputting dependencies.
   libtool     Whether libtool is used (yes/no).
 
 Report bugs to <bug-automake at gnu.org>.
@@ -90,10 +90,18 @@ if test "$depmode" = msvcmsys; then
    # This is just like msvisualcpp but w/o cygpath translation.
    # Just convert the backslash-escaped backslashes to single forward
    # slashes to satisfy depend.m4
-   cygpath_u="sed s,\\\\\\\\,/,g"
+   cygpath_u='sed s,\\\\,/,g'
    depmode=msvisualcpp
 fi
 
+if test "$depmode" = msvc7msys; then
+   # This is just like msvc7 but w/o cygpath translation.
+   # Just convert the backslash-escaped backslashes to single forward
+   # slashes to satisfy depend.m4
+   cygpath_u='sed s,\\\\,/,g'
+   depmode=msvc7
+fi
+
 case "$depmode" in
 gcc3)
 ## gcc 3 implements dependency tracking that does exactly what
@@ -158,10 +166,12 @@ gcc)
 ' < "$tmpdepfile" |
 ## Some versions of gcc put a space before the `:'.  On the theory
 ## that the space means something, we add a space to the output as
-## well.
+## well.  hp depmode also adds that space, but also prefixes the VPATH
+## to the object.  Take care to not repeat it in the output.
 ## Some versions of the HPUX 10.20 sed can't process this invocation
 ## correctly.  Breaking it into two sed invocations is a workaround.
-    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+    sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
+      | sed -e 's/$/ :/' >> "$depfile"
   rm -f "$tmpdepfile"
   ;;
 
@@ -405,6 +415,52 @@ tru64)
    rm -f "$tmpdepfile"
    ;;
 
+msvc7)
+  if test "$libtool" = yes; then
+    showIncludes=-Wc,-showIncludes
+  else
+    showIncludes=-showIncludes
+  fi
+  "$@" $showIncludes > "$tmpdepfile"
+  stat=$?
+  grep -v '^Note: including file: ' "$tmpdepfile"
+  if test "$stat" = 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  # The first sed program below extracts the file names and escapes
+  # backslashes for cygpath.  The second sed program outputs the file
+  # name when reading, but also accumulates all include files in the
+  # hold buffer in order to output them again at the end.  This only
+  # works with sed implementations that can handle large buffers.
+  sed < "$tmpdepfile" -n '
+/^Note: including file:  *\(.*\)/ {
+  s//\1/
+  s/\\/\\\\/g
+  p
+}' | $cygpath_u | sort -u | sed -n '
+s/ /\\ /g
+s/\(.*\)/	\1 \\/p
+s/.\(.*\) \\/\1:/
+H
+$ {
+  s/.*/	/
+  G
+  p
+}' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+msvc7msys)
+  # This case exists only to let depend.m4 do its work.  It works by
+  # looking at the text of this script.  This case will never be run,
+  # since it is checked for above.
+  exit 1
+  ;;
+
 #nosideeffect)
   # This comment above is used by automake to tell side-effect
   # dependency tracking mechanisms from slower ones.
@@ -503,7 +559,9 @@ makedepend)
   touch "$tmpdepfile"
   ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
   rm -f "$depfile"
-  cat < "$tmpdepfile" > "$depfile"
+  # makedepend may prepend the VPATH from the source file name to the object.
+  # No need to regex-escape $object, excess matching of '.' is harmless.
+  sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
   sed '1,2d' "$tmpdepfile" | tr ' ' '
 ' | \
 ## Some versions of the HPUX 10.20 sed can't process this invocation
diff --git a/include/Makefile.am b/include/Makefile.am
index 4016c4b..2aad594 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -1,4 +1,4 @@
 
 #AUTOMAKE_OPTIONS = foreign 
 
-SUBDIRS = folia
+SUBDIRS = libfolia
diff --git a/include/Makefile.in b/include/Makefile.in
index 32871e6..37432de 100644
--- a/include/Makefile.in
+++ b/include/Makefile.in
@@ -1,9 +1,9 @@
-# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# Makefile.in generated by automake 1.11.3 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
-# Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -221,10 +221,12 @@ sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
 sysconfdir = @sysconfdir@
 target_alias = @target_alias@
+ticcutils_CFLAGS = @ticcutils_CFLAGS@
+ticcutils_LIBS = @ticcutils_LIBS@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-SUBDIRS = folia
+SUBDIRS = libfolia
 all: all-recursive
 
 .SUFFIXES:
@@ -473,10 +475,15 @@ install-am: all-am
 
 installcheck: installcheck-recursive
 install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
-	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
-	  `test -z '$(STRIP)' || \
-	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+	if test -z '$(STRIP)'; then \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	      install; \
+	else \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+	fi
 mostlyclean-generic:
 
 clean-generic:
diff --git a/include/folia/foliautils.h b/include/folia/foliautils.h
deleted file mode 100644
index 667e3f3..0000000
--- a/include/folia/foliautils.h
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
-  $Id: foliautils.h 14458 2012-03-13 17:05:21Z sloot $
-  $URL: https://ilk.uvt.nl/svn/sources/libfolia/trunk/include/folia/foliautils.h $
-
-  Copyright (c) 1998 - 2012
-  ILK   - Tilburg University
-  CLiPS - University of Antwerp
- 
-  This file is part of libfolia
-
-  libfolia is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; either version 3 of the License, or
-  (at your option) any later version.
-
-  libfolia is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-  along with this program; if not, see <http://www.gnu.org/licenses/>.
-
-  For questions and suggestions, see:
-      http://ilk.uvt.nl/software.html
-  or send mail to:
-      timbl at uvt.nl
-*/
-
-#ifndef FOLIAUTILS_H
-#define FOLIAUTILS_H
-
-#include <sstream>
-#include <set>
-#include <list>
-#include <vector>
-#include <stdexcept>
-#include <ctime>
-#include "unicode/unistr.h"
-#include "unicode/unistr.h"
-#include <unicode/ustream.h>
-#include "libxml/tree.h"
-#include "libxml/xpath.h"
-
-namespace folia {
-  enum AnnotatorType{ UNDEFINED = -1, AUTO = 0, MANUAL = 1 };
-  
-  enum Attrib { NO_ATT=0, ID=1, CLASS=2, ANNOTATOR=4, CONFIDENCE=8, 
-		N=16, DATETIME=32 };
-  
-  inline Attrib operator|( Attrib a1, Attrib a2 ){
-    return (Attrib) ((int)a1|(int)a2) ;
-  }
-  
-  inline Attrib& operator|=( Attrib& a1, Attrib& a2 ){
-    a1 = (a1 | a2);
-    return a1;
-  }
-  
-  enum ElementType  {
-    BASE=0, TextContent_t,
-    Text_t, Event_t, TimedEvent_t, Timings_t,
-    LineBreak_t, WhiteSpace_t, Word_t,
-    WordReference_t, Sentence_t, Paragraph_t,
-    Division_t, Head_t, Caption_t, Label_t,
-    List_t, ListItem_t, Figure_t, Quote_t, //structure annotation elements
-    Pos_t, Lemma_t, Phon_t, Domain_t, Sense_t, Subjectivity_t,
-    Correction_t, //token annotation elements
-    Annolay_t, SyntacticUnit_t, SyntaxLayer_t, 
-    Chunk_t, Chunking_t, 
-    Entity_t, Entities_t, 
-    Subentity_t, Subentities_t, //annotation layers
-    Morphology_t, Morpheme_t, 
-    ErrorDetection_t, New_t, 
-    Original_t, Current_t, 
-    Suggestion_t, 
-    Alternative_t, AltLayers_t, //alternatives
-    Description_t, Gap_t, 
-    Content_t, Feature_t, SynsetFeature_t, ActorFeature_t, HeadFeature_t,
-    BegindatetimeFeature_t, EnddatetimeFeature_t, //features
-    PlaceHolder_t,
-    Dependencies_t, Dependency_t, DependencyHead_t, DependencyDependent_t
-  };
-  
-  inline ElementType operator|( ElementType a1, ElementType a2 ){
-    return (ElementType) ((long int)a1|(long int)a2) ;
-  }
-  
-  
-  /*
-   * Annotation types tie FoLiA elements to a particular kind of annotation.
-   * Especially declarations make use of this.
-   *  static const annotation_type = {AnnotationType}
-   */
-  namespace AnnotationType {
-    enum AnnotationType { NO_ANN, TEXT, TOKEN, DIVISION, POS, LEMMA, EVENT,
-			  SUGGESTION, DOMEIN, SENSE, SYNTAX, CHUNKING, 
-			  SUBENTITY, ENTITY, ERRORDETECTION, CORRECTION,
-			  ALTERNATIVE, PHON, SUBJECTIVITY, MORPHOLOGICAL, 
-			  DEPENDENCY, TIMEDEVENT, GAP
-    };
-  }
-  
-  enum MetaDataType { NATIVE, CMDI, IMDI };
-  
-  class ArgsError: public std::runtime_error {
-  public:
-  ArgsError( const std::string& s ): std::runtime_error( "error in argument list: " + s  ){};
-  };
-  
-  class KeyError: public std::out_of_range {
-  public:
-  KeyError(): std::out_of_range( "key out of range" ){};
-  };
-  
-  class NotImplementedError: public std::runtime_error {
-  public:
-  NotImplementedError( const std::string& s ): 
-    std::runtime_error( "NOT IMPLEMENTED: " + s ){};
-  };
-  
-  class ValueError: public std::runtime_error {
-  public:
-  ValueError( const std::string& s ): std::runtime_error( s ){};
-  };
-  
-  class XmlError: public std::runtime_error {
-  public:
-  XmlError( const std::string& s ): std::runtime_error( "XML error: " + s ){};
-  };
-  
-  class NoSuchAnnotation: public std::runtime_error {
-  public:
-  NoSuchAnnotation( ): std::runtime_error( "no such annotation" ){};
-  NoSuchAnnotation( const std::string& s ): std::runtime_error( "no such annotation: " + s ){};
-  };
-  
-  class NoSuchText: public std::runtime_error {
-  public:
-  NoSuchText( ): std::runtime_error( "no such text" ){};
-  NoSuchText( const std::string& s ): std::runtime_error( "no such text: " + s ){};
-  };
-  
-  class NoDescription: public std::runtime_error {
-  public:
-  NoDescription( ): std::runtime_error( "no description" ){};
-  };
-  
-  class DuplicateAnnotationError: public std::runtime_error {
-  public:
-  DuplicateAnnotationError( const std::string& s ): std::runtime_error( s ){};
-  };
-  
-  class DuplicateIDError: public std::runtime_error {
-  public:
-  DuplicateIDError( const std::string& s ): std::runtime_error( "duplicate ID : " + s ){};
-  };
-  
-  class NoDefaultError: public std::runtime_error {
-  public:
-  NoDefaultError( const std::string& s ): std::runtime_error( "No Default found: " + s ){};
-  };
-  
-  UnicodeString UTF8ToUnicode( const std::string& );
-  std::string UnicodeToUTF8( const UnicodeString& );
-  
-  double toDouble( const std::string& );
-  
-  std::string toString( const double );
-  
-  std::string toString( const AnnotationType::AnnotationType& );
-  AnnotatorType stringToANT( const std::string& );
-  
-  std::string lowercase( const std::string& );
-  std::string uppercase( const std::string& );
-  
-  AnnotationType::AnnotationType stringToAT( const std::string& );
-  
-  std::string toString( const ElementType& );
-  
-  std::string compress( const std::string& );
-  
-  inline std::string strip( const std::string& s) { return compress( s ); }
-  
-  size_t split_at( const std::string&, std::vector<std::string>&,
-		   const std::string& );
-  
-  typedef std::map<std::string, std::string> KWargs;
-  
-  KWargs getArgs( const std::string& );
-  std::string toString( const KWargs& );
-  
-  inline std::ostream& operator<<( std::ostream& os, 
-				   const AnnotationType::AnnotationType& at ){
-    os << toString( at );
-    return os;
-  }
-  
-  template< typename T >
-    inline T stringTo( const std::string& str ) {
-    T result;
-    std::stringstream dummy ( str );
-    if ( !( dummy >> result ) ) {
-      throw( std::runtime_error( "conversion from string '"
-				 + str + "' failed" ) );
-    }
-    return result;
-  }  
-  
-  template<>
-    inline AnnotatorType stringTo( const std::string& str ) {
-    std::string at = uppercase( str );
-    if ( at == "AUTO" )
-      return AUTO;
-    else if ( at == "MANUAL" )
-      return MANUAL;
-    else
-      return UNDEFINED;
-  }
-  
-  template<>
-    inline bool stringTo( const std::string& str ) {
-    std::string b = uppercase( str );
-    if ( b == "YES" || b == "TRUE" || b == "1" )
-      return true;
-    else if ( b == "FALSE" || b == "NO" || b == "0" )
-      return false;
-    else
-      throw( std::runtime_error( "conversion from string '"
-				 + str + "' to bool failed" ) );
-  }
-  
-  template< typename T >
-    inline std::ostream& operator<<( std::ostream& os, const std::set<T>& s ){
-    os << "{";
-    typename std::set<T>::const_iterator it = s.begin();
-    while ( it != s.end() ){
-      os << *it;
-      ++it;
-      if ( it != s.end() )
-	os << ",";
-    }
-    os << "}";
-    return os;
-  }
-  
-  template< typename T >
-    inline std::ostream& operator<<( std::ostream& os, const std::list<T>& s ){
-    os << "[";
-    typename std::list<T>::const_iterator it = s.begin();
-    while ( it != s.end() ){
-      os << *it;
-      ++it;
-      if ( it != s.end() )
-	os << ",";
-    }
-    os << "]";
-    return os;
-  }
-  
-  template< typename T >
-    inline std::ostream& operator<<( std::ostream& os, const std::vector<T>& s ){
-    os << "[";
-    typename std::vector<T>::const_iterator it = s.begin();
-    while ( it != s.end() ){
-      os << *it;
-      ++it;
-      if ( it != s.end() )
-	os << ",";
-    }
-    os << "]";
-    return os;
-  }
-
-  template< typename S, typename T >
-    inline std::ostream& operator<< ( std::ostream& os, const std::map<S,T>& s ){
-    os << "{";
-    typename std::map<S,T>::const_iterator it = s.begin();
-    while ( it != s.end() ){
-      os << "<" << it->first << "," << it->second << ">";
-      ++it;
-      if ( it != s.end() )
-	os << ",";
-    }
-    os << "}";
-    return os;
-  }
-
-  template< typename S, typename T >
-    inline std::ostream& operator<< ( std::ostream& os, const std::multimap<S,T>& s ){
-    os << "{";
-    typename std::multimap<S,T>::const_iterator it = s.begin();
-    while ( it != s.end() ){
-      os << "<" << it->first << "," << it->second << ">";
-      ++it;
-      if ( it != s.end() )
-	os << ",";
-    }
-    os << "}";
-    return os;
-  }
-
-  xmlNode *newXMLNode( xmlNs *,  const std::string& );
-  void addAttributes( xmlNode *, const KWargs& );
-  KWargs getAttributes( const xmlNode * );
-
-  std::string Name( const xmlNode * );
-  std::string XmlContent( const xmlNode * );
-  std::string getNS( const xmlNode *, std::string& );
-  inline std::string getNS( const xmlNode *n ) {
-    std::string s;
-    return getNS( n, s);
-  }
-
-  std::map<std::string,std::string> getNSlist( const xmlNode * );
-
-  std::list<xmlNode*> FindNodes( xmlNode *, const std::string& );
-  xmlNode *xPath( xmlNode *, const std::string& );
-
-  std::tm *parseDate( const std::string& );
-
-} // namespace folia
-
-#endif // FOLIAUTILS
diff --git a/include/folia/Makefile.am b/include/libfolia/Makefile.am
similarity index 100%
rename from include/folia/Makefile.am
rename to include/libfolia/Makefile.am
diff --git a/include/folia/Makefile.in b/include/libfolia/Makefile.in
similarity index 92%
rename from include/folia/Makefile.in
rename to include/libfolia/Makefile.in
index d85c29d..7dd0581 100644
--- a/include/folia/Makefile.in
+++ b/include/libfolia/Makefile.in
@@ -1,9 +1,9 @@
-# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# Makefile.in generated by automake 1.11.3 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
-# Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -34,7 +34,7 @@ PRE_UNINSTALL = :
 POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
-subdir = include/folia
+subdir = include/libfolia
 DIST_COMMON = $(pkginclude_HEADERS) $(srcdir)/Makefile.am \
 	$(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -72,6 +72,12 @@ am__nobase_list = $(am__nobase_strip_setup); \
 am__base_list = \
   sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
   sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+  test -z "$$files" \
+    || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+    || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+         $(am__cd) "$$dir" && rm -f $$files; }; \
+  }
 am__installdirs = "$(DESTDIR)$(pkgincludedir)"
 HEADERS = $(pkginclude_HEADERS)
 ETAGS = etags
@@ -206,6 +212,8 @@ sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
 sysconfdir = @sysconfdir@
 target_alias = @target_alias@
+ticcutils_CFLAGS = @ticcutils_CFLAGS@
+ticcutils_LIBS = @ticcutils_LIBS@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
@@ -222,9 +230,9 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu include/folia/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu include/libfolia/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
-	  $(AUTOMAKE) --gnu include/folia/Makefile
+	  $(AUTOMAKE) --gnu include/libfolia/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
@@ -266,9 +274,7 @@ uninstall-pkgincludeHEADERS:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \
 	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
-	test -n "$$files" || exit 0; \
-	echo " ( cd '$(DESTDIR)$(pkgincludedir)' && rm -f" $$files ")"; \
-	cd "$(DESTDIR)$(pkgincludedir)" && rm -f $$files
+	dir='$(DESTDIR)$(pkgincludedir)'; $(am__uninstall_files_from_dir)
 
 ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
@@ -369,10 +375,15 @@ install-am: all-am
 
 installcheck: installcheck-am
 install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
-	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
-	  `test -z '$(STRIP)' || \
-	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+	if test -z '$(STRIP)'; then \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	      install; \
+	else \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+	fi
 mostlyclean-generic:
 
 clean-generic:
diff --git a/include/folia/document.h b/include/libfolia/document.h
similarity index 78%
rename from include/folia/document.h
rename to include/libfolia/document.h
index 4a2717f..e6233d9 100644
--- a/include/folia/document.h
+++ b/include/libfolia/document.h
@@ -1,8 +1,8 @@
 /*
-  $Id: document.h 14474 2012-03-19 13:04:14Z sloot $
-  $URL: https://ilk.uvt.nl/svn/sources/libfolia/trunk/include/folia/document.h $
+  $Id: document.h 15909 2013-04-03 13:52:24Z sloot $
+  $URL: https://ilk.uvt.nl/svn/sources/libfolia/trunk/include/libfolia/document.h $
 
-  Copyright (c) 1998 - 2012
+  Copyright (c) 1998 - 2013
   ILK   - Tilburg University
   CLiPS - University of Antwerp
  
@@ -27,8 +27,8 @@
       timbl at uvt.nl
 */
 
-#ifndef DOCUMENT_H
-#define DOCUMENT_H
+#ifndef FOLIA_DOCUMENT_H
+#define FOLIA_DOCUMENT_H
 
 #include <list>
 #include "unicode/unistr.h"
@@ -36,7 +36,8 @@
 #include "libxml/tree.h"
 #include "libxml/xpath.h"
 #include <ctime>
-#include "foliautils.h"
+#include "libfolia/folia.h"
+#include "libfolia/foliautils.h"
 
 namespace folia {
   extern const std::string NSFOLIA;
@@ -65,11 +66,6 @@ namespace folia {
     std::string matchannotationset;
   };
 
-  inline std::ostream& operator<<( std::ostream& os, const Pattern& p ){
-    os << "pattern: " << p.sequence;
-    return os;
-  }
-
   class FoliaElement;
   class Word;
   class Sentence;
@@ -85,15 +81,22 @@ namespace folia {
     void init();
     bool readFromFile( const std::string& );
     bool readFromString( const std::string& );
-    bool save( const std::string&, const std::string& = "" );
+    bool save( std::ostream&, const std::string&, bool = false );
+    bool save( std::ostream& os, bool kanon = false ){
+      return save( os, "", kanon );
+    }
+    bool save( const std::string&, const std::string&, bool = false );
+    bool save( const std::string& s, bool kanon = false ){
+      return save( s, "", kanon );
+    }
     int size() const;
     FoliaElement* doc() const { return foliadoc; }
     FoliaElement* addNode( ElementType, const KWargs& );
-    void addStyle( const std::string& st ){
-      styles.push_back( st );
-    };
+    void addStyle( const std::string&, const std::string& );
+    void replaceStyle( const std::string&, const std::string& );
     std::vector<Paragraph*> paragraphs() const;
     std::vector<Sentence*> sentences() const;
+    std::vector<Sentence*> sentenceParts() const;
     std::vector<Word*> words() const;
     std::vector<std::vector<Word*> > findwords( const Pattern&,
 						const std::string& ="" ) const;
@@ -105,7 +108,7 @@ namespace folia {
     Paragraph *rparagraphs( size_t ) const;
     Sentence *sentences( size_t ) const;
     Sentence *rsentences( size_t ) const;
-    std::string toXml( const std::string& ="" ) const;
+    std::string toXml( const std::string& ="", bool = false ) const;
     MetaDataType metadatatype() const { return _metadatatype; };
     std::string metadatafile() const { return _metadatafile; };
 
@@ -117,7 +120,8 @@ namespace folia {
   
     FoliaElement *index( const std::string& ) const; //retrieve element with specified ID 
     FoliaElement* operator []( const std::string& ) const ; //index as operator 
-    bool isDeclared( AnnotationType::AnnotationType, const std::string&, 
+    bool isDeclared( AnnotationType::AnnotationType, 
+		     const std::string&, const std::string&,
 		     const std::string&, const std::string& );
     bool isDeclared( AnnotationType::AnnotationType, const std::string& = "" );
     std::string defaultset( AnnotationType::AnnotationType ) const;
@@ -127,6 +131,9 @@ namespace folia {
     std::string defaultannotatortype( AnnotationType::AnnotationType, 
 				      const std::string& ="" ) const;
 
+    std::string defaultdatetime( AnnotationType::AnnotationType, 
+				 const std::string& ="" ) const;
+
     FoliaElement* parseXml( );
 
     std::string id() const { return _id; };
@@ -134,18 +141,20 @@ namespace folia {
 		  const std::string&,
 		  const std::string& = "" );
     void declare( AnnotationType::AnnotationType, 
-		  const std::string&, const std::string&, const std::string& );
+		  const std::string&, const std::string&, 
+		  const std::string&, const std::string& );
     xmlDoc *XmlDoc() const { return xmldoc; };
-    xmlNs *foliaNs() const { return _foliaNs; };
+    xmlNs *foliaNs() const { return _foliaNsOut; };
     void keepForDeletion( FoliaElement *p ) { delSet.insert( p ); };
     int debug;
 
     class at_t {
       friend std::ostream& operator<<( std::ostream&, const at_t& );
     public:
-    at_t( const std::string& _a, const std::string& _t ): a(_a),t(_t){}; 
+    at_t( const std::string& _a, const std::string& _t, const std::string& _d ): a(_a),t(_t),d(_d){}; 
       std::string a;
       std::string t;
+      std::string d;
     };
   private:
     std::map<AnnotationType::AnnotationType,std::multimap<std::string,at_t> > annotationdefaults;
@@ -165,7 +174,8 @@ namespace folia {
     std::set<FoliaElement *> delSet;
     FoliaElement *foliadoc;
     xmlDoc *xmldoc;
-    mutable xmlNs *_foliaNs;
+    xmlNs *_foliaNsIn;
+    mutable xmlNs *_foliaNsOut;
     MetaDataType _metadatatype;
     xmlNode *metadata;
     std::string _metadatafile;
@@ -174,7 +184,7 @@ namespace folia {
     std::string _language;
     std::string _publisher;
     std::string _license;
-    std::vector<std::string> styles;
+    std::multimap<std::string,std::string> styles;
     bool loadall;
     std::string filename;
     std::string version;
@@ -186,10 +196,10 @@ namespace folia {
   }
 
   inline std::ostream& operator<<( std::ostream& os, const Document::at_t& at ){
-    os << "<" << at.a << "," << at.t << ">";
+    os << "<" << at.a << "," << at.t << "," << at.d << ">";
     return os;
   }
 
 } // namespace folia
 
-#endif // DOCUMENT_H
+#endif // FOLIA_DOCUMENT_H
diff --git a/include/folia/folia.h b/include/libfolia/folia.h
similarity index 72%
rename from include/folia/folia.h
rename to include/libfolia/folia.h
index 7c4df7d..d7f11ed 100644
--- a/include/folia/folia.h
+++ b/include/libfolia/folia.h
@@ -1,8 +1,8 @@
 /*
-  $Id: folia.h 14476 2012-03-19 15:48:35Z sloot $
-  $URL: https://ilk.uvt.nl/svn/sources/libfolia/trunk/include/folia/folia.h $
+  $Id: folia.h 15909 2013-04-03 13:52:24Z sloot $
+  $URL: https://ilk.uvt.nl/svn/sources/libfolia/trunk/include/libfolia/folia.h $
 
-  Copyright (c) 1998 - 2012
+  Copyright (c) 1998 - 2013
   ILK   - Tilburg University
   CLiPS - University of Antwerp
  
@@ -36,7 +36,7 @@
 #include "libxml/tree.h"
 #include "libxml/xpath.h"
 #include <ctime>
-#include "foliautils.h"
+#include "libfolia/foliautils.h"
 
 namespace folia {
   class Document;
@@ -48,12 +48,12 @@ namespace folia {
   class Sentence;
   class Word;
   class TextContent;
-  class Alternative;
   class Correction;
   class Suggestion;
   class Division;
   class DependencyDependent;
   class Paragraph;
+  class Morpheme;
 
   class FoliaElement {
     friend std::ostream& operator<<( std::ostream&, const FoliaElement& );
@@ -66,12 +66,12 @@ namespace folia {
     FoliaElement( Document* =0 );
     virtual ~FoliaElement();
 
+    static FoliaElement *createElement( Document *, const ElementType  );
     static FoliaElement *createElement( Document *, const std::string&  );
 
-    void classInit( const std::string& s ){
+    void classInit( const std::string& s="" ){
       init(); // virtual init
       if ( !s.empty() ){
-	// virtual is only called when s != ""
 	// this enables the init of empty classes, which hopefully get their
 	// attributes in a later state
 	setAttributes(  getArgs( s ) );
@@ -211,16 +211,19 @@ namespace folia {
     }
 
     template <typename F>
-      F *annotation( const std::string& val ) const {
+      F *annotation( const std::string& st ) const {
       if ( allowannotations() ){
 	// Will return a SINGLE annotation (even if there are multiple). 
 	// Raises a NoSuchAnnotation exception if none was found
-	std::vector<F*>v = select<F>( val );
+	std::vector<F*>v = select<F>( st );
 	if ( v.size() >= 1 )
 	  return v[0];
 	else {
 	  F obj("");
-	  throw NoSuchAnnotation( obj.classname() );
+	  if ( st.empty() )
+	    throw NoSuchAnnotation( obj.classname() );
+	  else
+	    throw NoSuchAnnotation( obj.classname() + " in set '" + st + "'" );
 	}
       }
       else {
@@ -228,14 +231,19 @@ namespace folia {
       }
     }
 
+    std::vector<std::string> feats( const std::string& ) const;
+    std::vector<Sentence *> sentencePart() const;
     std::string feat( const std::string& ) const;
     //XML (de)serialisation
     std::string xmlstring() const; // serialize to a string (XML fragment)
-    virtual xmlNode *xml( bool ) const; //serialize to XML  
+    virtual xmlNode *xml( bool, bool = false ) const; //serialize to XML  
     virtual FoliaElement* parseXml( const xmlNode * );
     virtual std::string str() const;
     UnicodeString unicode() const { return text(); };
-    virtual UnicodeString text( const std::string& = "current" ) const;
+    UnicodeString toktext( const std::string& cls = "current" ) const {
+      return text( cls, true );
+    }
+    virtual UnicodeString text( const std::string& = "current", bool = false ) const;
     virtual TextContent *textcontent( const std::string& = "current" ) const;
     virtual UnicodeString stricttext( const std::string& = "current" ) const;
     bool hastext( const std::string& = "current" ) const ;
@@ -243,54 +251,60 @@ namespace folia {
       throw NotImplementedError("head() for " + _xmltag );
     }
     virtual FoliaElement *getNew() const {
-      throw NotImplementedError("getNew()"); };
+      throw NotImplementedError("getNew() for " + _xmltag ); };
     virtual FoliaElement *getOriginal() const {
-      throw NotImplementedError("getOriginal()"); };
+      throw NotImplementedError("getOriginal() for " + _xmltag ); };
     virtual FoliaElement *getCurrent() const {
-      throw NotImplementedError("getCurrent()"); };
+      throw NotImplementedError("getCurrent() for " + _xmltag ); };
     virtual FoliaElement *split( FoliaElement *, FoliaElement *, 
 				    const std::string& = "" ){
-      throw NotImplementedError("split()"); };
+      throw NotImplementedError("split() for " + _xmltag ); };
     virtual Correction *mergewords( FoliaElement *, 
 				    const std::vector<FoliaElement *>&,
 				    const std::string& = "" ){
-      throw NotImplementedError("mergewords()"); };
+      throw NotImplementedError("mergewords() for " + _xmltag ); };
     virtual Correction *deleteword( FoliaElement *, 
 				    const std::string& = "" ){
-      throw NotImplementedError("deleteword()"); };
+      throw NotImplementedError("deleteword() for " + _xmltag ); };
     virtual Correction *insertword( FoliaElement *, FoliaElement *,
 				    const std::string& = "" ){
-      throw NotImplementedError("insertword()"); };
+      throw NotImplementedError("insertword() for " + _xmltag ); };
     virtual std::vector<Suggestion*> suggestions() const
-      { throw NotImplementedError("suggestions()"); };    
+      { throw NotImplementedError("suggestions() for " + _xmltag ); };
     virtual Suggestion *suggestions( size_t ) const
-      { throw NotImplementedError("suggestions()"); };    
+      { throw NotImplementedError("suggestions() for " + _xmltag ); };    
     virtual std::string subset() const 
-      { throw NotImplementedError("subset()"); };
+      { throw NotImplementedError("subset() for " + _xmltag ); };
     virtual FoliaElement *previous() const {
-      throw NotImplementedError("previous()"); };
+      throw NotImplementedError("previous() for " + _xmltag ); };
     virtual FoliaElement *next() const {
-      throw NotImplementedError("next()"); };
+      throw NotImplementedError("next() for " + _xmltag ); };
     virtual std::vector<Word*> context( size_t, 
 					const std::string& ="" ) const {
-      throw NotImplementedError("contect()"); };
+      throw NotImplementedError("contect() for " + _xmltag ); };
     virtual std::vector<Word*> leftcontext( size_t, 
 					    const std::string& ="" ) const {
-      throw NotImplementedError("leftcontect()"); 
+      throw NotImplementedError("leftcontect() for " + _xmltag ); 
     };
     virtual std::vector<Word*> rightcontext( size_t, 
 					     const std::string& ="" ) const {
-      throw NotImplementedError("rightcontext()"); 
+      throw NotImplementedError("rightcontext() for " + _xmltag ); 
     };
     virtual int offset() const {
-      throw NotImplementedError("offset()"); 
+      throw NotImplementedError("offset() for " + _xmltag ); 
+    };
+    virtual std::string getlang() const {
+      throw NotImplementedError("offset() for " + _xmltag ); 
+    };
+    virtual std::string setlang( const std::string& ) {
+      throw NotImplementedError("offset() for " + _xmltag ); 
     };
 
-    std::string pos() const;
-    std::string lemma() const;
+    std::string pos( const std::string& = "" ) const;
+    std::string lemma( const std::string& = "" ) const;
     std::string cls() const { return _class; };
     std::string sett() const { return _set; };
-    std::string annotator() const { return _annotator; };
+    std::string annotator( ) const { return _annotator; };
     void annotator( const std::string& a ) { _annotator = a; };
     AnnotatorType annotatortype() const { return _annotator_type; };
     void annotatortype( AnnotatorType t ) { _annotator_type =  t; };
@@ -325,6 +339,12 @@ namespace folia {
     virtual std::vector<Word*> words() const {
       throw NotImplementedError("words() for " + _xmltag );
     };
+    virtual std::vector<Morpheme*> morphemes( const std::string& ) const {
+      throw NotImplementedError("morphemes() for " + _xmltag );
+    };
+    virtual Morpheme* morpheme( size_t, const std::string& ) const {
+      throw NotImplementedError("morpheme() for " + _xmltag );
+    };
     virtual Sentence *sentences( size_t ) const {
       throw NotImplementedError("sentences() for " + _xmltag );
     };
@@ -340,6 +360,9 @@ namespace folia {
     virtual Word *words( size_t ) const {
       throw NotImplementedError("words() for " + _xmltag );
     };
+    virtual std::vector<Word *> wordParts() const {
+      throw NotImplementedError("words() for " + _xmltag );
+    };
     virtual Word *rwords( size_t ) const {
       throw NotImplementedError("rwords() for " + _xmltag );
     };
@@ -357,9 +380,13 @@ namespace folia {
     }
     Word *addWord( const KWargs& );
     TextContent *settext( const std::string&, const std::string& = "current" );
+    TextContent *settext( const std::string&, int , const std::string& = "current" );
 
     template <typename F>
-      Alternative *addAlternative( const KWargs& );
+      F *addAlternative();
+    template <typename F>
+      F *addAlternative( const KWargs& );
+
     template <typename F>
       F *addAnnotation( const KWargs& args ) {
       F *res = 0;
@@ -381,7 +408,7 @@ namespace folia {
     virtual std::vector<Alternative *> alternatives( ElementType,
 						     const std::string& = ""
 						     ) const { 
-      throw NotImplementedError("alternatives()"); 
+      throw NotImplementedError("alternatives() for " + _xmltag ); 
     }
     virtual std::string content() const {
       throw NoSuchAnnotation( "content" );
@@ -399,22 +426,26 @@ namespace folia {
       throw NotImplementedError("correct() for " + _xmltag );
     }
     virtual Correction *correct( const std::string& = "" ){
-      throw NotImplementedError("correct()"); };
+      throw NotImplementedError("correct() for " + _xmltag ); };
 
     virtual std::string src() const {
-      throw NotImplementedError("src()"); };
+      throw NotImplementedError("src() for " + _xmltag ); };
 
     virtual UnicodeString caption() const {
-      throw NotImplementedError("caption() for " + classname()); };
+      throw NotImplementedError("caption() for " + _xmltag ); };
 
     void increfcount() { ++refcount; };
     FoliaElement *parent() const { return _parent; };
     void setParent( FoliaElement *p ) { _parent = p ; };
     void setAuth( bool b ){ _auth = b; };
+    virtual std::vector<FoliaElement *> resolve() const {
+      throw NotImplementedError("resolve() for " + _xmltag );
+    };
+
   protected:
     virtual void init()=0;
     virtual KWargs collectAttributes() const;
-    virtual std::string getTextDelimiter() const { return TEXTDELIMITER; }
+    virtual std::string getTextDelimiter( bool=false ) const { return TEXTDELIMITER; }
     virtual std::string generateId( const std::string& ){
       throw NotImplementedError( "generateId() not allowed for " + classname() );
     };
@@ -433,12 +464,12 @@ namespace folia {
 				       const std::set<ElementType>& ,
 				       bool = true ) const;
     bool acceptable( ElementType ) const;
-    bool addable( const FoliaElement *, const std::string& = "" ) const;
+    bool checkAtts();
+    bool addable( const FoliaElement * ) const;
 
     std::vector<FoliaElement*> data;
     FoliaElement *_parent;
     bool _auth;
-    //  UnicodeString _text;
     Document *mydoc;
     std::string _xmltag;
     ElementType _element_id;
@@ -461,7 +492,7 @@ namespace folia {
     std::string _class;
     std::string _annotator;
     std::string _n;
-    std::tm *_datetime;
+    std::string _datetime;
     AnnotatorType _annotator_type;
     double _confidence;
     int refcount;
@@ -503,7 +534,8 @@ namespace folia {
 
   class AbstractStructureElement: public FoliaElement, AllowGenerateID {
   public:  
-  AbstractStructureElement( Document *d=0 ): FoliaElement( d ) {};
+  AbstractStructureElement( Document *d=0 ): FoliaElement( d ) { classInit(); };
+    
     std::string str() const;
     bool allowannotations() const { return true; };
     std::vector<Alternative *> alternatives( ElementType = BASE,
@@ -528,6 +560,8 @@ namespace folia {
     std::string generateId( const std::string& tag ){
       return IGgen( tag, _id ); 
     }
+  private:
+    void init();
   };
 
   class AbstractAnnotation: public FoliaElement {
@@ -537,15 +571,19 @@ namespace folia {
 
   class AbstractTokenAnnotation: public AbstractAnnotation, AllowGenerateID {
   public:
-  AbstractTokenAnnotation( Document *d=0 ):  AbstractAnnotation( d ){};
+  AbstractTokenAnnotation( Document *d=0 ):  AbstractAnnotation( d ){ classInit(); };
     std::string generateId( const std::string& tag ){
       return IGgen( tag, _id ); 
     }
+  private:
+    void init();
   };
 
   class AbstractSubTokenAnnotation: public AbstractAnnotation {
   public:
-  AbstractSubTokenAnnotation( Document *d=0 ):  AbstractAnnotation( d ){};
+  AbstractSubTokenAnnotation( Document *d=0 ):  AbstractAnnotation( d ){ classInit(); };
+  private:
+    void init();
   };
 
   class Feature: public FoliaElement {
@@ -567,12 +605,14 @@ namespace folia {
 
   class AbstractSpanAnnotation: public AbstractAnnotation, AllowGenerateID {
   public:
-  AbstractSpanAnnotation( Document *d=0 ):  AbstractAnnotation( d ){};
-    xmlNode *xml( bool ) const;
+  AbstractSpanAnnotation( Document *d=0 ):  AbstractAnnotation( d ){ classInit(); };
+    xmlNode *xml( bool, bool=false ) const;
     FoliaElement *append( FoliaElement* );
     std::string generateId( const std::string& tag ){
       return IGgen( tag, _id ); 
     }
+  private:
+    void init();
   };
 
   class TextContent: public FoliaElement {
@@ -582,18 +622,26 @@ namespace folia {
   TextContent( Document *d, const std::string& s="" ):  FoliaElement( d ){ classInit( s ); }
   TextContent( Document *d, const KWargs& a ):  FoliaElement( d ){ classInit( a ); }
     FoliaElement* parseXml( const xmlNode * );
-    xmlNode *xml( bool ) const;
+    xmlNode *xml( bool, bool=false ) const;
     void setAttributes( const KWargs& );
     KWargs collectAttributes() const;  
     std::string str() const;
-    UnicodeString text( const std::string& = "current" ) const;
+    UnicodeString text( const std::string& = "current", bool = false ) const;
     int offset() const { return _offset; };
-    FoliaElement *append( FoliaElement* ){ throw NotImplementedError("TextContent::append()"); };
+    std::string getlang() const { return _lang; };
+    std::string setlang( const std::string& l ) { 
+      std::string t = _lang;
+      _lang = l;
+      return t;
+    };
+    FoliaElement *append( FoliaElement* ){ 
+      throw NotImplementedError("TextContent::append() for " + _xmltag ); };
     TextContent *postappend();
     std::vector<FoliaElement*> findreplacables( FoliaElement * ) const;
   private:
     void init();
     int _offset;
+    std::string _lang;
     UnicodeString _text;
   };
 
@@ -645,12 +693,22 @@ namespace folia {
   Content( Document *d, const std::string& s=""): FoliaElement( d ) { classInit( s ); };
   Content( Document *d, const KWargs& a ): FoliaElement( d ) { classInit( a ); };
     FoliaElement* parseXml( const xmlNode * );
-    xmlNode *xml( bool ) const;
+    xmlNode *xml( bool, bool = false ) const;
     std::string content() const { return value; };
   private:
     void init();
     std::string value;
   };
+  
+  class MetricAnnotation: public FoliaElement {
+  public:
+  MetricAnnotation( const std::string& s=""): FoliaElement( ) { classInit( s ); };
+  MetricAnnotation( const KWargs& a ): FoliaElement( ) { classInit( a ); };
+  MetricAnnotation( Document *d, const std::string& s=""): FoliaElement( d ) { classInit( s ); };
+  MetricAnnotation( Document *d, const KWargs& a ): FoliaElement( d ) { classInit( a ); };
+  private:
+    void init();
+  };
 
   class Division: public AbstractStructureElement {
   public:
@@ -698,6 +756,8 @@ namespace folia {
     Sentence *sentence() const;
     Paragraph *paragraph() const;
     Division *division() const;
+    std::vector<Morpheme *> morphemes( const std::string& ="" ) const;
+    Morpheme* morpheme( size_t, const std::string& ="" ) const;
     Correction *incorrection() const;
     Word *previous() const;
     Word *next() const;
@@ -711,8 +771,8 @@ namespace folia {
     const Word* resolveword( const std::string& ) const;
     void setAttributes( const KWargs& );
     KWargs collectAttributes() const;  
-    std::string getTextDelimiter() const { 
-      if ( space )
+    std::string getTextDelimiter( bool retaintok=false) const { 
+      if ( space || retaintok )
 	return TEXTDELIMITER;
       else {
 	return "";
@@ -723,10 +783,22 @@ namespace folia {
     bool space;
   };
 
+  class String: public AbstractTokenAnnotation {
+  public:
+  String( const std::string& s="" ): AbstractTokenAnnotation(){ classInit( s ); };
+  String( const KWargs& a ):  AbstractTokenAnnotation(){ classInit( a ); };
+  String( Document *d, const std::string& s=""):  AbstractTokenAnnotation( d ){ classInit( s ); };
+  String( Document *d, const KWargs& a ):  AbstractTokenAnnotation( d ){ classInit( a ); };
+  private:
+    void init();
+  };
+
   class PlaceHolder: public Word {
   public:
   PlaceHolder( const std::string& s=""): Word(){ classInit( s ); };
   PlaceHolder( const KWargs& a ): Word(){ classInit( a ); };
+  PlaceHolder( Document *d, const std::string& s=""): Word( d ){ classInit( s ); };
+  PlaceHolder( Document *d, const KWargs& a ): Word( d ){ classInit( a ); };
     void setAttributes( const KWargs& );
   private:
     void init();
@@ -746,6 +818,7 @@ namespace folia {
     Correction *deleteword( FoliaElement *, const std::string& args );
     Correction *insertword( FoliaElement *, FoliaElement *,
 			    const std::string& args );
+    std::vector<Word*> wordParts() const;
   private:
     Correction *correctWords( const std::vector<FoliaElement *>&,
 			      const std::vector<FoliaElement *>&,
@@ -839,7 +912,7 @@ namespace folia {
     void init();
   };
 
-  class Alternative: public AbstractStructureElement{
+  class Alternative: public AbstractStructureElement {
   public:
   Alternative( const std::string& s=""):  AbstractStructureElement(){ classInit( s ); };
   Alternative( const KWargs& a ):  AbstractStructureElement(){ classInit( a ); };
@@ -850,23 +923,40 @@ namespace folia {
     void init();
   };
 
+  
+  class AlternativeLayers: public FoliaElement {
+  public:
+  AlternativeLayers( const std::string& s=""): FoliaElement(){ classInit( s ); };
+  AlternativeLayers( const KWargs& a ): FoliaElement(){ classInit( a ); };
+  AlternativeLayers( Document *d, const std::string& s=""): FoliaElement( d ){ classInit( s ); };
+  AlternativeLayers( Document *d, const KWargs& a ): FoliaElement( d ){ classInit( a ); };
+  private:
+    void init();
+  };
+
   template <typename F>
-    Alternative *FoliaElement::addAlternative( const KWargs& args ){
+    F *FoliaElement::addAlternative( const KWargs& args ){
     KWargs kw;
     std::string id = generateId( "alt" );
     kw["id"] = id;
-    Alternative *res = 0;
+    F *res = 0;
+    Alternative *alt = 0;
     try {
-      res = new Alternative( mydoc, kw );
-      res->addAnnotation<F>( args );
+      alt = new Alternative( mydoc, kw );
+      res = alt->addAnnotation<F>( args );
     }
     catch( std::exception& ){
-      delete res;
+      delete alt;
       throw;
     }
-    append( res );
+    append( alt );
     return res;
   }
+  template <typename F>
+    F *FoliaElement::addAlternative(){
+    KWargs numb;
+    return addAlternative<F>( numb );
+  }
 
   class PosAnnotation: public AbstractTokenAnnotation {
   public:
@@ -935,26 +1025,27 @@ namespace folia {
   Quote( Document *d, const std::string& s="" ): AbstractStructureElement( d ){ classInit( s ); };
   Quote( Document *d, const KWargs& a ): AbstractStructureElement( d ){ classInit( a ); };
     FoliaElement *append( FoliaElement *);
+    std::vector<Word*> wordParts() const;
   private:
     void init();
   };
 
-  class BegindatetimeFeature: public Feature {
+  class BeginDateTimeFeature: public Feature {
   public:
-  BegindatetimeFeature( const std::string& s="" ): Feature( ){ classInit( s ); }
-  BegindatetimeFeature( const KWargs& a ): Feature( ){ classInit( a ); }
-  BegindatetimeFeature( Document *d, const std::string& s="" ): Feature( d ){ classInit( s ); }
-  BegindatetimeFeature( Document *d, const KWargs& a ): Feature( d ){ classInit( a ); }
+  BeginDateTimeFeature( const std::string& s="" ): Feature( ){ classInit( s ); }
+  BeginDateTimeFeature( const KWargs& a ): Feature( ){ classInit( a ); }
+  BeginDateTimeFeature( Document *d, const std::string& s="" ): Feature( d ){ classInit( s ); }
+  BeginDateTimeFeature( Document *d, const KWargs& a ): Feature( d ){ classInit( a ); }
   private:
     void init();
   };
 
-  class EnddatetimeFeature: public Feature {
+  class EndDateTimeFeature: public Feature {
   public:
-  EnddatetimeFeature( const std::string& s="" ): Feature( ){ classInit( s ); }
-  EnddatetimeFeature( const KWargs& a ): Feature( ){ classInit( a ); }
-  EnddatetimeFeature( Document *d, const std::string& s="" ): Feature( d ){ classInit( s ); }
-  EnddatetimeFeature( Document *d, const KWargs& a ): Feature( d ){ classInit( a ); }
+  EndDateTimeFeature( const std::string& s="" ): Feature( ){ classInit( s ); }
+  EndDateTimeFeature( const KWargs& a ): Feature( ){ classInit( a ); }
+  EndDateTimeFeature( Document *d, const std::string& s="" ): Feature( d ){ classInit( s ); }
+  EndDateTimeFeature( Document *d, const KWargs& a ): Feature( d ){ classInit( a ); }
   private:
     void init();
   };
@@ -989,6 +1080,56 @@ namespace folia {
     void init();
   };
 
+  class ValueFeature: public Feature {
+  public:
+  ValueFeature( const std::string& s="" ): Feature( ){ classInit( s ); }
+  ValueFeature( const KWargs& a ): Feature( ){ classInit( a ); }
+  ValueFeature( Document *d, const std::string& s="" ): Feature( d ){ classInit( s ); }
+  ValueFeature( Document *d, const KWargs& a ): Feature( d ){ classInit( a ); }
+  private:
+    void init();
+  };
+
+  class FunctionFeature: public Feature {
+  public:
+  FunctionFeature( const std::string& s="" ): Feature( ){ classInit( s ); }
+  FunctionFeature( const KWargs& a ): Feature( ){ classInit( a ); }
+  FunctionFeature( Document *d, const std::string& s="" ): Feature( d ){ classInit( s ); }
+  FunctionFeature( Document *d, const KWargs& a ): Feature( d ){ classInit( a ); }
+  private:
+    void init();
+  };
+
+  class TimeFeature: public Feature {
+  public:
+  TimeFeature( const std::string& s="" ): Feature( ){ classInit( s ); }
+  TimeFeature( const KWargs& a ): Feature( ){ classInit( a ); }
+  TimeFeature( Document *d, const std::string& s="" ): Feature( d ){ classInit( s ); }
+  TimeFeature( Document *d, const KWargs& a ): Feature( d ){ classInit( a ); }
+  private:
+    void init();
+  };
+
+  class LevelFeature: public Feature {
+  public:
+  LevelFeature( const std::string& s="" ): Feature( ){ classInit( s ); }
+  LevelFeature( const KWargs& a ): Feature( ){ classInit( a ); }
+  LevelFeature( Document *d, const std::string& s="" ): Feature( d ){ classInit( s ); }
+  LevelFeature( Document *d, const KWargs& a ): Feature( d ){ classInit( a ); }
+  private:
+    void init();
+  };
+
+  class ModalityFeature: public Feature {
+  public:
+  ModalityFeature( const std::string& s="" ): Feature( ){ classInit( s ); }
+  ModalityFeature( const KWargs& a ): Feature( ){ classInit( a ); }
+  ModalityFeature( Document *d, const std::string& s="" ): Feature( d ){ classInit( s ); }
+  ModalityFeature( Document *d, const KWargs& a ): Feature( d ){ classInit( a ); }
+  private:
+    void init();
+  };
+
   class WordReference: public FoliaElement {
   public:
   WordReference( const std::string& s="" ): FoliaElement( ){ classInit( s ); };
@@ -1000,6 +1141,40 @@ namespace folia {
     FoliaElement* parseXml( const xmlNode *node );
   };  
 
+  class Alignment: public FoliaElement {
+  public:
+  Alignment( const std::string& s="" ): FoliaElement( ){ classInit( s ); };
+  Alignment( const KWargs& a ): FoliaElement( ){ classInit( a ); };
+  Alignment( Document *d, const std::string& s="" ): FoliaElement( d ){ classInit( s ); };
+  Alignment( Document *d, const KWargs& a ): FoliaElement( d ){ classInit( a ); };
+    std::string href() const { return _href; };
+    std::vector<FoliaElement *>resolve() const;
+    KWargs collectAttributes() const;  
+    void setAttributes( const KWargs& );
+  private:
+    void init();
+    std::string _href;
+    std::string _type;
+  };  
+
+  class AlignReference: public FoliaElement {
+    friend class Alignment;
+  public:
+  AlignReference( const std::string& s="" ): FoliaElement( ){ classInit( s ); };
+  AlignReference( const KWargs& a ): FoliaElement( ){ classInit( a ); };
+  AlignReference( Document *d, const std::string& s="" ): FoliaElement( d ){ classInit( s ); };
+  AlignReference( Document *d, const KWargs& a ): FoliaElement( d ){ classInit( a ); };
+    KWargs collectAttributes() const;  
+    void setAttributes( const KWargs& );
+  private:
+    void init();
+    FoliaElement* parseXml( const xmlNode *node );
+    FoliaElement *resolve( const Alignment *ref ) const;
+    std::string refId;
+    std::string _type;
+    std::string _t;
+  };  
+
   class SyntacticUnit: public AbstractSpanAnnotation {
   public:
   SyntacticUnit( const std::string& s="" ): AbstractSpanAnnotation( ){ classInit( s ); }
@@ -1030,12 +1205,12 @@ namespace folia {
     void init();
   };
 
-  class DependencyHead: public AbstractSpanAnnotation {
+  class Headwords: public AbstractSpanAnnotation {
   public:
-  DependencyHead( const std::string& s="" ): AbstractSpanAnnotation( ){ classInit( s ); }
-  DependencyHead( const KWargs& a ): AbstractSpanAnnotation( ){ classInit( a ); }
-  DependencyHead( Document *d, const std::string& s="" ): AbstractSpanAnnotation( d ){ classInit( s ); }
-  DependencyHead( Document *d, const KWargs& a ): AbstractSpanAnnotation( d ){ classInit( a ); }
+  Headwords( const std::string& s="" ): AbstractSpanAnnotation( ){ classInit( s ); }
+  Headwords( const KWargs& a ): AbstractSpanAnnotation( ){ classInit( a ); }
+  Headwords( Document *d, const std::string& s="" ): AbstractSpanAnnotation( d ){ classInit( s ); }
+  Headwords( Document *d, const KWargs& a ): AbstractSpanAnnotation( d ){ classInit( a ); }
   private:
     void init();
   };
@@ -1056,12 +1231,42 @@ namespace folia {
   Dependency( const KWargs& a ): AbstractSpanAnnotation( ){ classInit( a ); }
   Dependency( Document *d, const std::string& s="" ): AbstractSpanAnnotation( d ){ classInit( s ); }
   Dependency( Document *d, const KWargs& a ): AbstractSpanAnnotation( d ){ classInit( a ); }
-    DependencyHead *head() const;
+    Headwords *head() const;
     DependencyDependent *dependent() const;
   private:
     void init();
   };
 
+  class CoreferenceLink: public AbstractSpanAnnotation {
+  public:
+  CoreferenceLink( const std::string& s="" ): AbstractSpanAnnotation(){ classInit( s ); }
+  CoreferenceLink( const KWargs& a ): AbstractSpanAnnotation(){ classInit( a ); }
+  CoreferenceLink( Document *d, const std::string& s="" ): AbstractSpanAnnotation( d ){ classInit( s ); }
+  CoreferenceLink( Document *d, const KWargs& a ): AbstractSpanAnnotation( d ){ classInit( a ); }
+  private:
+    void init();
+  };
+
+  class CoreferenceChain: public AbstractSpanAnnotation {
+  public:
+  CoreferenceChain( const std::string& s="" ): AbstractSpanAnnotation(){ classInit( s ); }
+  CoreferenceChain( const KWargs& a ): AbstractSpanAnnotation(){ classInit( a ); }
+  CoreferenceChain( Document *d, const std::string& s="" ): AbstractSpanAnnotation( d ){ classInit( s ); }
+  CoreferenceChain( Document *d, const KWargs& a ): AbstractSpanAnnotation( d ){ classInit( a ); }
+  private:
+    void init();
+  };
+
+  class SemanticRole: public AbstractSpanAnnotation {
+  public:
+  SemanticRole( const std::string& s="" ): AbstractSpanAnnotation(){ classInit( s ); }
+  SemanticRole( const KWargs& a ): AbstractSpanAnnotation(){ classInit( a ); }
+  SemanticRole( Document *d, const std::string& s="" ): AbstractSpanAnnotation( d ){ classInit( s ); }
+  SemanticRole( Document *d, const KWargs& a ): AbstractSpanAnnotation( d ){ classInit( a ); }
+  private:
+    void init();
+  };
+
   class AbstractAnnotationLayer: public FoliaElement, AllowGenerateID {
   public:
   AbstractAnnotationLayer( const std::string& s=""): FoliaElement( ) { classInit( s ); };
@@ -1075,42 +1280,49 @@ namespace folia {
     void init();
   };
 
-  class NewElement: public FoliaElement {
+  class AbstractCorrectionChild: public FoliaElement {
   public:
-  NewElement( const std::string& s=""): FoliaElement( ) { classInit( s ); };
-  NewElement( const KWargs& a ): FoliaElement( ) { classInit( a ); };
-  NewElement( Document *d, const std::string& s=""): FoliaElement( d ) { classInit( s ); };
-  NewElement( Document *d, const KWargs& a ): FoliaElement( d ) { classInit( a ); };
+  AbstractCorrectionChild( Document *d=0 ):  FoliaElement( d ){ classInit(); };
   private:
     void init();
   };
 
-  class Current: public FoliaElement {
+  class NewElement: public AbstractCorrectionChild {
   public:
-  Current( const std::string& s=""): FoliaElement( ) { classInit( s ); };
-  Current( const KWargs& a ): FoliaElement( ) { classInit( a ); };
-  Current( Document *d, const std::string& s=""): FoliaElement( d ) { classInit( s ); };
-  Current( Document *d, const KWargs& a ): FoliaElement( d ) { classInit( a ); };
+  NewElement( const std::string& s=""): AbstractCorrectionChild( ) { classInit( s ); };
+  NewElement( const KWargs& a ): AbstractCorrectionChild( ) { classInit( a ); };
+  NewElement( Document *d, const std::string& s=""): AbstractCorrectionChild( d ) { classInit( s ); };
+  NewElement( Document *d, const KWargs& a ): AbstractCorrectionChild( d ) { classInit( a ); };
   private:
     void init();
   };
 
-  class Original: public FoliaElement {
+  class Current: public AbstractCorrectionChild {
   public:
-  Original( const std::string& s=""): FoliaElement( ) { classInit( s ); };
-  Original( const KWargs& a ): FoliaElement( ) { classInit( a ); };
-  Original( Document *d, const std::string& s=""): FoliaElement( d ) { classInit( s ); };
-  Original( Document *d, const KWargs& a ): FoliaElement( d ) { classInit( a ); };
+  Current( const std::string& s=""): AbstractCorrectionChild( ) { classInit( s ); };
+  Current( const KWargs& a ): AbstractCorrectionChild( ) { classInit( a ); };
+  Current( Document *d, const std::string& s=""): AbstractCorrectionChild( d ) { classInit( s ); };
+  Current( Document *d, const KWargs& a ): AbstractCorrectionChild( d ) { classInit( a ); };
   private:
     void init();
   };
 
-  class Suggestion: public FoliaElement {
+  class Original: public AbstractCorrectionChild {
   public:
-  Suggestion( const std::string& s=""): FoliaElement( ) { classInit( s ); };
-  Suggestion( const KWargs& a ): FoliaElement( ) { classInit( a ); };
-  Suggestion( Document *d, const std::string& s=""): FoliaElement( d ) { classInit( s ); };
-  Suggestion( Document *d, const KWargs& a ): FoliaElement( d ) { classInit( a ); };
+  Original( const std::string& s=""): AbstractCorrectionChild( ) { classInit( s ); };
+  Original( const KWargs& a ): AbstractCorrectionChild( ) { classInit( a ); };
+  Original( Document *d, const std::string& s=""): AbstractCorrectionChild( d ) { classInit( s ); };
+  Original( Document *d, const KWargs& a ): AbstractCorrectionChild( d ) { classInit( a ); };
+  private:
+    void init();
+  };
+
+  class Suggestion: public AbstractCorrectionChild {
+  public:
+  Suggestion( const std::string& s=""): AbstractCorrectionChild( ) { classInit( s ); };
+  Suggestion( const KWargs& a ): AbstractCorrectionChild( ) { classInit( a ); };
+  Suggestion( Document *d, const std::string& s=""): AbstractCorrectionChild( d ) { classInit( s ); };
+  Suggestion( Document *d, const KWargs& a ): AbstractCorrectionChild( d ) { classInit( a ); };
   private:
     void init();
   };
@@ -1124,7 +1336,7 @@ namespace folia {
     std::string description() const { return _value; };
     void setAttributes( const KWargs& kwargs );
     FoliaElement* parseXml( const xmlNode * );
-    xmlNode *xml( bool ) const;
+    xmlNode *xml( bool, bool=false ) const;
   private:
     void init();
     std::string _value;
@@ -1145,7 +1357,7 @@ namespace folia {
     Current *getCurrent() const;
     std::vector<Suggestion*> suggestions() const;
     Suggestion *suggestions( size_t ) const;
-    UnicodeString text( const std::string& = "current" ) const;
+    UnicodeString text( const std::string& = "current", bool = false ) const;
     TextContent *textcontent( const std::string& = "current" ) const;
   private:
     void init();
@@ -1157,23 +1369,6 @@ namespace folia {
   ErrorDetection( const KWargs& a ): AbstractTokenAnnotation(){ classInit( a ); }
   ErrorDetection( Document *d, const std::string& s=""): AbstractTokenAnnotation( d ){ classInit( s ); }
   ErrorDetection( Document *d, const KWargs& a ): AbstractTokenAnnotation( d ){ classInit( a ); }
-    void setAttributes( const KWargs& );
-    KWargs collectAttributes() const;  
-  private:
-    void init();
-    bool error;
-  };
-
-  class AbstractSubtokenAnnotationLayer: public FoliaElement, AllowGenerateID {
-  public:
-  AbstractSubtokenAnnotationLayer( const std::string& s="" ): FoliaElement( ){ classInit( s ); }
-  AbstractSubtokenAnnotationLayer( const KWargs& a ): FoliaElement( ){ classInit( a ); }
-  AbstractSubtokenAnnotationLayer( Document *d, const std::string& s="" ): FoliaElement( d ){ classInit( s ); }
-  AbstractSubtokenAnnotationLayer( Document *d, const KWargs& a ): FoliaElement( d ){ classInit( a ); }
-    std::string generateId( const std::string& tag ){
-      return IGgen( tag, _id ); 
-    }
-
   private:
     void init();
   };
@@ -1192,22 +1387,22 @@ namespace folia {
     void init();
   };
 
-  class TimedEvent: public AbstractSpanAnnotation {
+  class TimeSegment: public AbstractSpanAnnotation {
   public:
-  TimedEvent( const std::string& s="" ): AbstractSpanAnnotation(){ classInit( s ); }
-  TimedEvent( const KWargs& a ): AbstractSpanAnnotation(){ classInit( a ); }
-  TimedEvent( Document *d, const std::string& s="" ): AbstractSpanAnnotation( d ){ classInit( s ); }
-  TimedEvent( Document *d, const KWargs& a ): AbstractSpanAnnotation( d ){ classInit( a ); }
+  TimeSegment( const std::string& s="" ): AbstractSpanAnnotation(){ classInit( s ); }
+  TimeSegment( const KWargs& a ): AbstractSpanAnnotation(){ classInit( a ); }
+  TimeSegment( Document *d, const std::string& s="" ): AbstractSpanAnnotation( d ){ classInit( s ); }
+  TimeSegment( Document *d, const KWargs& a ): AbstractSpanAnnotation( d ){ classInit( a ); }
   private:
     void init();
   };
 
-  class Morpheme: public AbstractSubtokenAnnotation {
+  class Morpheme: public AbstractStructureElement {
   public:
-  Morpheme( const std::string& s="" ): AbstractSubtokenAnnotation(){ classInit( s ); }
-  Morpheme( const KWargs& a ): AbstractSubtokenAnnotation(){ classInit( a ); }
-  Morpheme( Document *d, const std::string& s="" ): AbstractSubtokenAnnotation( d ){ classInit( s ); }
-  Morpheme( Document *d, const KWargs& a ): AbstractSubtokenAnnotation( d ){ classInit( a ); }
+  Morpheme( const std::string& s="" ): AbstractStructureElement(){ classInit( s ); }
+  Morpheme( const KWargs& a ): AbstractStructureElement(){ classInit( a ); }
+  Morpheme( Document *d, const std::string& s="" ): AbstractStructureElement( d ){ classInit( s ); }
+  Morpheme( Document *d, const KWargs& a ): AbstractStructureElement( d ){ classInit( a ); }
   private:
     void init();
   };
@@ -1262,22 +1457,12 @@ namespace folia {
     void init();
   };
 
-  class MorphologyLayer: public AbstractSubtokenAnnotationLayer {
+  class MorphologyLayer: public AbstractAnnotationLayer {
   public:
-  MorphologyLayer( const std::string& s="" ): AbstractSubtokenAnnotationLayer(){ classInit( s ); }
-  MorphologyLayer( const KWargs& a ): AbstractSubtokenAnnotationLayer(){ classInit( a ); }
-  MorphologyLayer( Document *d, const std::string& s="" ): AbstractSubtokenAnnotationLayer( d ){ classInit( s ); }
-  MorphologyLayer( Document *d, const KWargs& a ): AbstractSubtokenAnnotationLayer( d ){ classInit( a ); }
-  private:
-    void init();
-  };
-
-  class SubentitiesLayer: public AbstractSubtokenAnnotationLayer {
-  public:
-  SubentitiesLayer( const std::string& s="" ): AbstractSubtokenAnnotationLayer(){ classInit( s ); }
-  SubentitiesLayer( const KWargs& a ): AbstractSubtokenAnnotationLayer(){ classInit( a ); }
-  SubentitiesLayer( Document *d, const std::string& s="" ): AbstractSubtokenAnnotationLayer( d ){ classInit( s ); }
-  SubentitiesLayer( Document *d, const KWargs& a ): AbstractSubtokenAnnotationLayer( d ){ classInit( a ); }
+  MorphologyLayer( const std::string& s="" ): AbstractAnnotationLayer(){ classInit( s ); }
+  MorphologyLayer( const KWargs& a ): AbstractAnnotationLayer(){ classInit( a ); }
+  MorphologyLayer( Document *d, const std::string& s="" ): AbstractAnnotationLayer( d ){ classInit( s ); }
+  MorphologyLayer( Document *d, const KWargs& a ): AbstractAnnotationLayer( d ){ classInit( a ); }
   private:
     void init();
   };
@@ -1292,6 +1477,26 @@ namespace folia {
     void init();
   };
 
+  class CoreferenceLayer: public AbstractAnnotationLayer {
+  public:
+  CoreferenceLayer( const std::string& s=""): AbstractAnnotationLayer(){ classInit( s ); }
+  CoreferenceLayer( const KWargs& a ): AbstractAnnotationLayer(){ classInit( a ); }
+  CoreferenceLayer( Document *d, const std::string& s=""): AbstractAnnotationLayer( d ){ classInit( s ); }
+  CoreferenceLayer( Document *d, const KWargs& a ): AbstractAnnotationLayer( d ){ classInit( a ); }
+  private:
+    void init();
+  };
+
+  class SemanticRolesLayer: public AbstractAnnotationLayer {
+  public:
+  SemanticRolesLayer( const std::string& s=""): AbstractAnnotationLayer(){ classInit( s ); }
+  SemanticRolesLayer( const KWargs& a ): AbstractAnnotationLayer(){ classInit( a ); }
+  SemanticRolesLayer( Document *d, const std::string& s=""): AbstractAnnotationLayer( d ){ classInit( s ); }
+  SemanticRolesLayer( Document *d, const KWargs& a ): AbstractAnnotationLayer( d ){ classInit( a ); }
+  private:
+    void init();
+  };
+
   std::string VersionName();
   std::string Version();
 
diff --git a/include/libfolia/foliautils.h b/include/libfolia/foliautils.h
new file mode 100644
index 0000000..956d810
--- /dev/null
+++ b/include/libfolia/foliautils.h
@@ -0,0 +1,262 @@
+/*
+  $Id: foliautils.h 15907 2013-04-03 13:43:03Z sloot $
+  $URL: https://ilk.uvt.nl/svn/sources/libfolia/trunk/include/libfolia/foliautils.h $
+
+  Copyright (c) 1998 - 2013
+  ILK   - Tilburg University
+  CLiPS - University of Antwerp
+ 
+  This file is part of libfolia
+
+  libfolia is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 3 of the License, or
+  (at your option) any later version.
+
+  libfolia is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+  For questions and suggestions, see:
+      http://ilk.uvt.nl/software.html
+  or send mail to:
+      timbl at uvt.nl
+*/
+
+#ifndef FOLIA_UTILS_H
+#define FOLIA_UTILS_H
+
+#include <sstream>
+#include <set>
+#include <list>
+#include <vector>
+#include <stdexcept>
+#include <ctime>
+#include "ticcutils/PrettyPrint.h"
+#include "ticcutils/StringOps.h"
+#include "ticcutils/XMLtools.h"
+#include "unicode/unistr.h"
+#include "unicode/unistr.h"
+#include <unicode/ustream.h>
+#include "libxml/tree.h"
+
+namespace folia {
+  enum AnnotatorType{ UNDEFINED = -1, AUTO = 0, MANUAL = 1 };
+  
+  enum Attrib { NO_ATT=0, ID=1, CLASS=2, ANNOTATOR=4, CONFIDENCE=8, 
+		N=16, DATETIME=32, SETONLY=64, ALL=127 };
+  
+  inline Attrib& operator++( Attrib & a ){
+    return a = ( SETONLY == a ) 
+      ? NO_ATT
+      : ( NO_ATT == a ? ID : Attrib(a<<1) );
+  }
+
+  inline Attrib operator|( Attrib a1, Attrib a2 ){
+    return (Attrib) ((int)a1|(int)a2) ;
+  }
+  
+  inline Attrib& operator|=( Attrib& a1, Attrib& a2 ){
+    a1 = (a1 | a2);
+    return a1;
+  }
+  
+  enum ElementType  {
+    BASE=0, TextContent_t,
+    Text_t, Word_t, Str_t,
+    WordReference_t, Event_t, 
+    TimeSegment_t, TimingLayer_t,
+    LineBreak_t, WhiteSpace_t, 
+    Sentence_t, Paragraph_t,
+    Division_t, Head_t, 
+    Caption_t, Label_t,
+    List_t, ListItem_t,
+    Figure_t, Quote_t, //structure annotation elements
+    Pos_t, Lemma_t, 
+    Phon_t, Domain_t, 
+    Sense_t, Subjectivity_t,
+    Metric_t, Correction_t, //token annotation elements
+    AnnotationLayer_t, SyntacticUnit_t, 
+    Chunk_t, Chunking_t, 
+    Entity_t, Entities_t, 
+    Coreferences_t, CoreferenceLink_t, 
+    CoreferenceChain_t,  SyntaxLayer_t, 
+    Semroles_t, Semrole_t,
+    //    Subentity_t, Subentities_t, //annotation layers
+    Morphology_t, Morpheme_t, 
+    ErrorDetection_t, New_t, 
+    Original_t, Current_t, 
+    Alternative_t, Alternatives_t, //alternatives
+    Description_t, Gap_t, 
+    Suggestion_t, Content_t, 
+    Feature_t, SynsetFeature_t, 
+    ActorFeature_t, HeadFeature_t, 
+    ValueFeature_t, TimeFeature_t, 
+    ModalityFeature_t, LevelFeature_t,
+    BeginDateTimeFeature_t, EndDateTimeFeature_t,
+    FunctionFeature_t, //features
+    PlaceHolder_t,
+    Dependencies_t, Dependency_t, 
+    Headwords_t, DependencyDependent_t,
+    Alignment_t, AlignReference_t,
+    LastElement
+  };
+  
+  inline ElementType& operator++( ElementType &et ){
+    return et = ( LastElement == et ) 
+      ? BASE 
+      : ElementType(et+1);
+  }
+    
+  /*
+   * Annotation types tie FoLiA elements to a particular kind of annotation.
+   * Especially declarations make use of this.
+   *  static const annotation_type = {AnnotationType}
+   */
+  namespace AnnotationType {
+    enum AnnotationType { NO_ANN, TEXT, TOKEN, DIVISION, PARAGRAPH, STRING,
+			  LIST, FIGURE, WHITESPACE, LINEBREAK, SENTENCE, 
+			  POS, LEMMA, DOMEIN, SENSE, SYNTAX, CHUNKING, ENTITY,
+			  // Attention DOMAIN seems to be a defined constant
+			  // where/how/why?
+			  CORRECTION, SUGGESTION, ERRORDETECTION, ALTERNATIVE, 
+			  PHON, SUBJECTIVITY, MORPHOLOGICAL, SUBENTITY, EVENT, 
+			  DEPENDENCY, TIMEDEVENT, GAP, ALIGNMENT, 
+			  COMPLEXALIGNMENT, COREFERENCE, SEMROLE, METRIC,
+			  LAST_ANN
+    };
+    inline AnnotationType& operator++( AnnotationType &at ){
+      return at = ( LAST_ANN == at ) 
+	? NO_ANN 
+	: AnnotationType(at+1);
+    }
+  }
+
+  enum MetaDataType { NATIVE, CMDI, IMDI };
+  
+  class ArgsError: public std::runtime_error {
+  public:
+  ArgsError( const std::string& s ): std::runtime_error( "error in argument list: " + s  ){};
+  };
+  
+  class KeyError: public std::out_of_range {
+  public:
+  KeyError(): std::out_of_range( "key out of range" ){};
+  };
+  
+  class NotImplementedError: public std::runtime_error {
+  public:
+  NotImplementedError( const std::string& s ): 
+    std::runtime_error( "NOT IMPLEMENTED: " + s ){};
+  };
+  
+  class ValueError: public std::runtime_error {
+  public:
+  ValueError( const std::string& s ): std::runtime_error( s ){};
+  };
+  
+  class XmlError: public std::runtime_error {
+  public:
+  XmlError( const std::string& s ): std::runtime_error( "XML error: " + s ){};
+  };
+  
+  class NoSuchAnnotation: public std::runtime_error {
+  public:
+  NoSuchAnnotation( ): std::runtime_error( "no such annotation" ){};
+  NoSuchAnnotation( const std::string& s ): std::runtime_error( "no such annotation: " + s ){};
+  };
+  
+  class NoSuchText: public std::runtime_error {
+  public:
+  NoSuchText( ): std::runtime_error( "no such text" ){};
+  NoSuchText( const std::string& s ): std::runtime_error( "no such text: " + s ){};
+  };
+  
+  class NoDescription: public std::runtime_error {
+  public:
+  NoDescription( ): std::runtime_error( "no description" ){};
+  };
+  
+  class DuplicateAnnotationError: public std::runtime_error {
+  public:
+  DuplicateAnnotationError( const std::string& s ): std::runtime_error( s ){};
+  };
+  
+  class DuplicateIDError: public std::runtime_error {
+  public:
+  DuplicateIDError( const std::string& s ): std::runtime_error( "duplicate ID : " + s ){};
+  };
+  
+  class NoDefaultError: public std::runtime_error {
+  public:
+  NoDefaultError( const std::string& s ): std::runtime_error( "No Default found: " + s ){};
+  };
+  
+  UnicodeString UTF8ToUnicode( const std::string& );
+  std::string UnicodeToUTF8( const UnicodeString& );
+  
+  std::string toString( const AnnotationType::AnnotationType& );
+  AnnotatorType stringToANT( const std::string& );
+  
+  AnnotationType::AnnotationType stringToAT( const std::string& );
+  
+  std::string toString( const ElementType& );
+  ElementType stringToET( const std::string& );
+  
+  typedef std::map<std::string, std::string> KWargs;
+  
+  KWargs getArgs( const std::string& );
+  std::string toString( const KWargs& );
+  
+  inline std::ostream& operator<<( std::ostream& os, 
+				   const AnnotationType::AnnotationType& at ){
+    os << toString( at );
+    return os;
+  }
+  
+}
+
+namespace TiCC {
+  template<>
+    inline folia::AnnotationType::AnnotationType stringTo( const std::string& str ) {
+    return folia::stringToAT( str );
+  }
+  
+  template<>
+    inline folia::ElementType stringTo( const std::string& str ) {
+    return folia::stringToET( str );
+  }
+
+  template<>
+    inline folia::AnnotatorType stringTo( const std::string& str ) {
+    std::string at = uppercase( str );
+    if ( at == "AUTO" )
+      return folia::AUTO;
+    else if ( at == "MANUAL" )
+      return folia::MANUAL;
+    else
+      return folia::UNDEFINED;
+  }
+  
+}
+
+namespace folia {
+  void addAttributes( xmlNode *, const KWargs& );
+  KWargs getAttributes( const xmlNode * );
+
+  std::string parseDate( const std::string& );
+
+  bool AT_sanity_check();
+  bool Attrib_sanity_check();
+  bool ET_sanity_check();
+
+  bool isNCName( const std::string& );
+
+  inline std::string strip( const std::string& s ){ return TiCC::trim(s); };
+} // namespace folia
+
+#endif // FOLIA_UTILS
diff --git a/ltmain.sh b/ltmain.sh
old mode 100755
new mode 100644
index b4a3231..c2852d8
--- a/ltmain.sh
+++ b/ltmain.sh
@@ -1,9 +1,9 @@
 
-# libtool (GNU libtool) 2.4
+# libtool (GNU libtool) 2.4.2
 # Written by Gordon Matzigkeit <gord at gnu.ai.mit.edu>, 1996
 
 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
-# 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
 # This is free software; see the source for copying conditions.  There is NO
 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
@@ -41,6 +41,7 @@
 #       --quiet, --silent    don't print informational messages
 #       --no-quiet, --no-silent
 #                            print informational messages (default)
+#       --no-warn            don't display warning messages
 #       --tag=TAG            use configuration variables from tag TAG
 #   -v, --verbose            print more informational messages than default
 #       --no-verbose         don't print the extra informational messages
@@ -69,7 +70,7 @@
 #         compiler:		$LTCC
 #         compiler flags:		$LTCFLAGS
 #         linker:		$LD (gnu? $with_gnu_ld)
-#         $progname:	(GNU libtool) 2.4 Debian-2.4-2ubuntu1
+#         $progname:	(GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1
 #         automake:	$automake_version
 #         autoconf:	$autoconf_version
 #
@@ -79,9 +80,9 @@
 
 PROGRAM=libtool
 PACKAGE=libtool
-VERSION="2.4 Debian-2.4-2ubuntu1"
+VERSION="2.4.2 Debian-2.4.2-1ubuntu1"
 TIMESTAMP=""
-package_revision=1.3293
+package_revision=1.3337
 
 # Be Bourne compatible
 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
@@ -136,15 +137,10 @@ progpath="$0"
 
 : ${CP="cp -f"}
 test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
-: ${EGREP="/bin/grep -E"}
-: ${FGREP="/bin/grep -F"}
-: ${GREP="/bin/grep"}
-: ${LN_S="ln -s"}
 : ${MAKE="make"}
 : ${MKDIR="mkdir"}
 : ${MV="mv -f"}
 : ${RM="rm -f"}
-: ${SED="/bin/sed"}
 : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
 : ${Xsed="$SED -e 1s/^X//"}
 
@@ -387,7 +383,7 @@ case $progpath in
      ;;
   *)
      save_IFS="$IFS"
-     IFS=:
+     IFS=${PATH_SEPARATOR-:}
      for progdir in $PATH; do
        IFS="$save_IFS"
        test -x "$progdir/$progname" && break
@@ -771,8 +767,8 @@ func_help ()
 	s*\$LTCFLAGS*'"$LTCFLAGS"'*
 	s*\$LD*'"$LD"'*
 	s/\$with_gnu_ld/'"$with_gnu_ld"'/
-	s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
-	s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
+	s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
+	s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
 	p
 	d
      }
@@ -1052,6 +1048,7 @@ opt_finish=false
 opt_help=false
 opt_help_all=false
 opt_silent=:
+opt_warning=:
 opt_verbose=:
 opt_silent=false
 opt_verbose=false
@@ -1120,6 +1117,10 @@ esac
 			opt_silent=false
 func_append preserve_args " $opt"
 			;;
+      --no-warning|--no-warn)
+			opt_warning=false
+func_append preserve_args " $opt"
+			;;
       --no-verbose)
 			opt_verbose=false
 func_append preserve_args " $opt"
@@ -2059,7 +2060,7 @@ func_mode_compile ()
     *.[cCFSifmso] | \
     *.ada | *.adb | *.ads | *.asm | \
     *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
-    *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup)
+    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
       func_xform "$libobj"
       libobj=$func_xform_result
       ;;
@@ -3201,11 +3202,13 @@ func_mode_install ()
 
       # Set up the ranlib parameters.
       oldlib="$destdir/$name"
+      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
+      tool_oldlib=$func_to_tool_file_result
 
       func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
 
       if test -n "$stripme" && test -n "$old_striplib"; then
-	func_show_eval "$old_striplib $oldlib" 'exit $?'
+	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
       fi
 
       # Do each command in the postinstall commands.
@@ -3470,7 +3473,7 @@ static const void *lt_preloaded_setup() {
 	  # linked before any other PIC object.  But we must not use
 	  # pic_flag when linking with -static.  The problem exists in
 	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
-	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
+	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
 	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
 	  *-*-hpux*)
 	    pic_flag_for_symtable=" $pic_flag"  ;;
@@ -3982,14 +3985,17 @@ func_exec_program_core ()
 # launches target application with the remaining arguments.
 func_exec_program ()
 {
-  for lt_wr_arg
-  do
-    case \$lt_wr_arg in
-    --lt-*) ;;
-    *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
-    esac
-    shift
-  done
+  case \" \$* \" in
+  *\\ --lt-*)
+    for lt_wr_arg
+    do
+      case \$lt_wr_arg in
+      --lt-*) ;;
+      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
+      esac
+      shift
+    done ;;
+  esac
   func_exec_program_core \${1+\"\$@\"}
 }
 
@@ -5057,9 +5063,15 @@ void lt_dump_script (FILE* f)
 {
 EOF
 	    func_emit_wrapper yes |
-              $SED -e 's/\([\\"]\)/\\\1/g' \
-	           -e 's/^/  fputs ("/' -e 's/$/\\n", f);/'
-
+	      $SED -n -e '
+s/^\(.\{79\}\)\(..*\)/\1\
+\2/
+h
+s/\([\\"]\)/\\\1/g
+s/$/\\n/
+s/\([^\n]*\).*/  fputs ("\1", f);/p
+g
+D'
             cat <<"EOF"
 }
 EOF
@@ -5643,7 +5655,8 @@ func_mode_link ()
 	continue
 	;;
 
-      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
+      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
+      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
 	func_append compiler_flags " $arg"
 	func_append compile_command " $arg"
 	func_append finalize_command " $arg"
@@ -6150,7 +6163,8 @@ func_mode_link ()
 	lib=
 	found=no
 	case $deplib in
-	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
+	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
+        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
 	  if test "$linkmode,$pass" = "prog,link"; then
 	    compile_deplibs="$deplib $compile_deplibs"
 	    finalize_deplibs="$deplib $finalize_deplibs"
@@ -6834,7 +6848,7 @@ func_mode_link ()
 	         test "$hardcode_direct_absolute" = no; then
 		add="$dir/$linklib"
 	      elif test "$hardcode_minus_L" = yes; then
-		add_dir="-L$dir"
+		add_dir="-L$absdir"
 		# Try looking first in the location we're being installed to.
 		if test -n "$inst_prefix_dir"; then
 		  case $libdir in
@@ -7319,6 +7333,7 @@ func_mode_link ()
 	  # which has an extra 1 added just for fun
 	  #
 	  case $version_type in
+	  # correct linux to gnu/linux during the next big refactor
 	  darwin|linux|osf|windows|none)
 	    func_arith $number_major + $number_minor
 	    current=$func_arith_result
@@ -7438,7 +7453,7 @@ func_mode_link ()
 	  versuffix="$major.$revision"
 	  ;;
 
-	linux)
+	linux) # correct to gnu/linux during the next big refactor
 	  func_arith $current - $age
 	  major=.$func_arith_result
 	  versuffix="$major.$age.$revision"
@@ -8026,6 +8041,11 @@ EOF
 
       # Test again, we may have decided not to build it any more
       if test "$build_libtool_libs" = yes; then
+	# Remove ${wl} instances when linking with ld.
+	# FIXME: should test the right _cmds variable.
+	case $archive_cmds in
+	  *\$LD\ *) wl= ;;
+        esac
 	if test "$hardcode_into_libs" = yes; then
 	  # Hardcode the library paths
 	  hardcode_libdirs=
@@ -8056,7 +8076,7 @@ EOF
 	    elif test -n "$runpath_var"; then
 	      case "$perm_rpath " in
 	      *" $libdir "*) ;;
-	      *) func_apped perm_rpath " $libdir" ;;
+	      *) func_append perm_rpath " $libdir" ;;
 	      esac
 	    fi
 	  done
@@ -8064,11 +8084,7 @@ EOF
 	  if test -n "$hardcode_libdir_separator" &&
 	     test -n "$hardcode_libdirs"; then
 	    libdir="$hardcode_libdirs"
-	    if test -n "$hardcode_libdir_flag_spec_ld"; then
-	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
-	    else
-	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
-	    fi
+	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
 	  fi
 	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
 	    # We should set the runpath_var.
@@ -9158,6 +9174,8 @@ EOF
 	    esac
 	  done
 	fi
+	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
+	tool_oldlib=$func_to_tool_file_result
 	eval cmds=\"$old_archive_cmds\"
 
 	func_len " $cmds"
@@ -9267,7 +9285,8 @@ EOF
 	      *.la)
 		func_basename "$deplib"
 		name="$func_basename_result"
-		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+		func_resolve_sysroot "$deplib"
+		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
 		test -z "$libdir" && \
 		  func_fatal_error "\`$deplib' is not a valid libtool archive"
 		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
diff --git a/m4/Makefile.in b/m4/Makefile.in
index b24da65..dc24a41 100644
--- a/m4/Makefile.in
+++ b/m4/Makefile.in
@@ -1,9 +1,9 @@
-# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# Makefile.in generated by automake 1.11.3 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
-# Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -182,6 +182,8 @@ sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
 sysconfdir = @sysconfdir@
 target_alias = @target_alias@
+ticcutils_CFLAGS = @ticcutils_CFLAGS@
+ticcutils_LIBS = @ticcutils_LIBS@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
@@ -276,10 +278,15 @@ install-am: all-am
 
 installcheck: installcheck-am
 install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
-	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
-	  `test -z '$(STRIP)' || \
-	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+	if test -z '$(STRIP)'; then \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	      install; \
+	else \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+	fi
 mostlyclean-generic:
 
 clean-generic:
diff --git a/m4/ltversion.m4 b/m4/ltversion.m4
index 9c7b5d4..07a8602 100644
--- a/m4/ltversion.m4
+++ b/m4/ltversion.m4
@@ -9,15 +9,15 @@
 
 # @configure_input@
 
-# serial 3293 ltversion.m4
+# serial 3337 ltversion.m4
 # This file is part of GNU Libtool
 
-m4_define([LT_PACKAGE_VERSION], [2.4])
-m4_define([LT_PACKAGE_REVISION], [1.3293])
+m4_define([LT_PACKAGE_VERSION], [2.4.2])
+m4_define([LT_PACKAGE_REVISION], [1.3337])
 
 AC_DEFUN([LTVERSION_VERSION],
-[macro_version='2.4'
-macro_revision='1.3293'
+[macro_version='2.4.2'
+macro_revision='1.3337'
 _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
 _LT_DECL(, macro_revision, 0)
 ])
diff --git a/m4/pkg.m4 b/m4/pkg.m4
index 9bb3e06..9a71878 100644
--- a/m4/pkg.m4
+++ b/m4/pkg.m4
@@ -26,7 +26,8 @@
 # ----------------------------------
 AC_DEFUN([PKG_PROG_PKG_CONFIG],
 [m4_pattern_forbid([^_?PKG_[A-Z_]+$])
-m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
+m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
+m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
 AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
 AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
 AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
@@ -72,7 +73,8 @@ m4_define([_PKG_CONFIG],
     pkg_cv_[]$1="$$1"
  elif test -n "$PKG_CONFIG"; then
     PKG_CHECK_EXISTS([$3],
-                     [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
+                     [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes ],
 		     [pkg_failed=yes])
  else
     pkg_failed=untried
@@ -120,9 +122,9 @@ if test $pkg_failed = yes; then
    	AC_MSG_RESULT([no])
         _PKG_SHORT_ERRORS_SUPPORTED
         if test $_pkg_short_errors_supported = yes; then
-	        $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1`
+	        $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
         else 
-	        $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1`
+	        $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
         fi
 	# Put the nasty error message in config.log where it belongs
 	echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
@@ -135,7 +137,7 @@ $$1_PKG_ERRORS
 Consider adjusting the PKG_CONFIG_PATH environment variable if you
 installed software in a non-standard prefix.
 
-_PKG_TEXT])dnl
+_PKG_TEXT])[]dnl
         ])
 elif test $pkg_failed = untried; then
      	AC_MSG_RESULT([no])
@@ -146,7 +148,7 @@ path to pkg-config.
 
 _PKG_TEXT
 
-To get pkg-config, see <http://pkg-config.freedesktop.org/>.])dnl
+To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
         ])
 else
 	$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
diff --git a/missing b/missing
index 28055d2..86a8fc3 100755
--- a/missing
+++ b/missing
@@ -1,10 +1,10 @@
 #! /bin/sh
 # Common stub for a few missing GNU programs while installing.
 
-scriptversion=2009-04-28.21; # UTC
+scriptversion=2012-01-06.13; # UTC
 
 # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
-# 2008, 2009 Free Software Foundation, Inc.
+# 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
 # Originally by Fran,cois Pinard <pinard at iro.umontreal.ca>, 1996.
 
 # This program is free software; you can redistribute it and/or modify
@@ -84,7 +84,6 @@ Supported PROGRAM values:
   help2man     touch the output file
   lex          create \`lex.yy.c', if possible, from existing .c
   makeinfo     touch the output file
-  tar          try tar, gnutar, gtar, then tar without non-portable flags
   yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
 
 Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
@@ -122,15 +121,6 @@ case $1 in
     # Not GNU programs, they don't have --version.
     ;;
 
-  tar*)
-    if test -n "$run"; then
-       echo 1>&2 "ERROR: \`tar' requires --run"
-       exit 1
-    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
-       exit 1
-    fi
-    ;;
-
   *)
     if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
        # We have it, but it failed.
@@ -226,7 +216,7 @@ WARNING: \`$1' $msg.  You should only need it if
          \`Bison' from any GNU archive site."
     rm -f y.tab.c y.tab.h
     if test $# -ne 1; then
-        eval LASTARG="\${$#}"
+        eval LASTARG=\${$#}
 	case $LASTARG in
 	*.y)
 	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
@@ -256,7 +246,7 @@ WARNING: \`$1' is $msg.  You should only need it if
          \`Flex' from any GNU archive site."
     rm -f lex.yy.c
     if test $# -ne 1; then
-        eval LASTARG="\${$#}"
+        eval LASTARG=\${$#}
 	case $LASTARG in
 	*.l)
 	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
@@ -318,41 +308,6 @@ WARNING: \`$1' is $msg.  You should only need it if
     touch $file
     ;;
 
-  tar*)
-    shift
-
-    # We have already tried tar in the generic part.
-    # Look for gnutar/gtar before invocation to avoid ugly error
-    # messages.
-    if (gnutar --version > /dev/null 2>&1); then
-       gnutar "$@" && exit 0
-    fi
-    if (gtar --version > /dev/null 2>&1); then
-       gtar "$@" && exit 0
-    fi
-    firstarg="$1"
-    if shift; then
-	case $firstarg in
-	*o*)
-	    firstarg=`echo "$firstarg" | sed s/o//`
-	    tar "$firstarg" "$@" && exit 0
-	    ;;
-	esac
-	case $firstarg in
-	*h*)
-	    firstarg=`echo "$firstarg" | sed s/h//`
-	    tar "$firstarg" "$@" && exit 0
-	    ;;
-	esac
-    fi
-
-    echo 1>&2 "\
-WARNING: I can't seem to be able to run \`tar' with the given arguments.
-         You may want to install GNU tar or Free paxutils, or check the
-         command line arguments."
-    exit 1
-    ;;
-
   *)
     echo 1>&2 "\
 WARNING: \`$1' is needed, and is $msg.
diff --git a/src/Makefile.am b/src/Makefile.am
index 6f96784..d47eeb6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,4 +1,4 @@
-# $Id: Makefile.am 8182 2011-02-02 14:08:35Z sloot $
+# $Id: Makefile.am 15924 2013-04-03 15:53:58Z sloot $
 # $URL $
 
 AM_CPPFLAGS = -I at top_srcdir@/include
@@ -6,9 +6,12 @@ AM_CPPFLAGS = -I at top_srcdir@/include
 LDADD = libfolia.la
 
 lib_LTLIBRARIES = libfolia.la
-libfolia_la_LDFLAGS = -version-info 1:0:0
+libfolia_la_LDFLAGS = -version-info 2:0:0
 
-libfolia_la_SOURCES =  folia.cxx document.cxx foliautils.cxx
+libfolia_la_SOURCES = folia.cxx document.cxx foliautils.cxx
+
+bin_PROGRAMS = folialint
+folialint_SOURCES = folialint.cxx
 
 check_PROGRAMS = simpletest
 TESTS = $(check_PROGRAMS) 
diff --git a/src/Makefile.in b/src/Makefile.in
index 49911b0..aebdcc7 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -1,9 +1,9 @@
-# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# Makefile.in generated by automake 1.11.3 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
-# Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -15,9 +15,10 @@
 
 @SET_MAKE@
 
-# $Id: Makefile.am 8182 2011-02-02 14:08:35Z sloot $
+# $Id: Makefile.am 15924 2013-04-03 15:53:58Z sloot $
 # $URL $
 
+
 VPATH = @srcdir@
 pkgdatadir = $(datadir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
@@ -37,6 +38,7 @@ PRE_UNINSTALL = :
 POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
+bin_PROGRAMS = folialint$(EXEEXT)
 check_PROGRAMS = simpletest$(EXEEXT)
 subdir = src
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
@@ -73,7 +75,13 @@ am__nobase_list = $(am__nobase_strip_setup); \
 am__base_list = \
   sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
   sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
-am__installdirs = "$(DESTDIR)$(libdir)"
+am__uninstall_files_from_dir = { \
+  test -z "$$files" \
+    || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+    || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+         $(am__cd) "$$dir" && rm -f $$files; }; \
+  }
+am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)"
 LTLIBRARIES = $(lib_LTLIBRARIES)
 libfolia_la_LIBADD =
 am_libfolia_la_OBJECTS = folia.lo document.lo foliautils.lo
@@ -81,6 +89,11 @@ libfolia_la_OBJECTS = $(am_libfolia_la_OBJECTS)
 libfolia_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
 	$(CXXFLAGS) $(libfolia_la_LDFLAGS) $(LDFLAGS) -o $@
+PROGRAMS = $(bin_PROGRAMS)
+am_folialint_OBJECTS = folialint.$(OBJEXT)
+folialint_OBJECTS = $(am_folialint_OBJECTS)
+folialint_LDADD = $(LDADD)
+folialint_DEPENDENCIES = libfolia.la
 am_simpletest_OBJECTS = simpletest.$(OBJEXT)
 simpletest_OBJECTS = $(am_simpletest_OBJECTS)
 simpletest_LDADD = $(LDADD)
@@ -98,8 +111,10 @@ CXXLD = $(CXX)
 CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
 	$(LDFLAGS) -o $@
-SOURCES = $(libfolia_la_SOURCES) $(simpletest_SOURCES)
-DIST_SOURCES = $(libfolia_la_SOURCES) $(simpletest_SOURCES)
+SOURCES = $(libfolia_la_SOURCES) $(folialint_SOURCES) \
+	$(simpletest_SOURCES)
+DIST_SOURCES = $(libfolia_la_SOURCES) $(folialint_SOURCES) \
+	$(simpletest_SOURCES)
 ETAGS = etags
 CTAGS = ctags
 am__tty_colors = \
@@ -234,14 +249,17 @@ sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
 sysconfdir = @sysconfdir@
 target_alias = @target_alias@
+ticcutils_CFLAGS = @ticcutils_CFLAGS@
+ticcutils_LIBS = @ticcutils_LIBS@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 AM_CPPFLAGS = -I at top_srcdir@/include
 LDADD = libfolia.la
 lib_LTLIBRARIES = libfolia.la
-libfolia_la_LDFLAGS = -version-info 1:0:0
+libfolia_la_LDFLAGS = -version-info 2:0:0
 libfolia_la_SOURCES = folia.cxx document.cxx foliautils.cxx
+folialint_SOURCES = folialint.cxx
 TESTS = $(check_PROGRAMS) 
 TESTS_ENVIRONMENT = topsrcdir=$(top_srcdir)
 simpletest_SOURCES = simpletest.cxx
@@ -311,8 +329,51 @@ clean-libLTLIBRARIES:
 	  echo "rm -f \"$${dir}/so_locations\""; \
 	  rm -f "$${dir}/so_locations"; \
 	done
-libfolia.la: $(libfolia_la_OBJECTS) $(libfolia_la_DEPENDENCIES) 
+libfolia.la: $(libfolia_la_OBJECTS) $(libfolia_la_DEPENDENCIES) $(EXTRA_libfolia_la_DEPENDENCIES) 
 	$(libfolia_la_LINK) -rpath $(libdir) $(libfolia_la_OBJECTS) $(libfolia_la_LIBADD) $(LIBS)
+install-binPROGRAMS: $(bin_PROGRAMS)
+	@$(NORMAL_INSTALL)
+	test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+	for p in $$list; do echo "$$p $$p"; done | \
+	sed 's/$(EXEEXT)$$//' | \
+	while read p p1; do if test -f $$p || test -f $$p1; \
+	  then echo "$$p"; echo "$$p"; else :; fi; \
+	done | \
+	sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
+	    -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+	sed 'N;N;N;s,\n, ,g' | \
+	$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+	  { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+	    if ($$2 == $$4) files[d] = files[d] " " $$1; \
+	    else { print "f", $$3 "/" $$4, $$1; } } \
+	  END { for (d in files) print "f", d, files[d] }' | \
+	while read type dir files; do \
+	    if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+	    test -z "$$files" || { \
+	    echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+	    $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+	    } \
+	; done
+
+uninstall-binPROGRAMS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+	files=`for p in $$list; do echo "$$p"; done | \
+	  sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+	      -e 's/$$/$(EXEEXT)/' `; \
+	test -n "$$list" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(bindir)" && rm -f $$files
+
+clean-binPROGRAMS:
+	@list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
+	echo " rm -f" $$list; \
+	rm -f $$list || exit $$?; \
+	test -n "$(EXEEXT)" || exit 0; \
+	list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+	echo " rm -f" $$list; \
+	rm -f $$list
 
 clean-checkPROGRAMS:
 	@list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
@@ -322,7 +383,10 @@ clean-checkPROGRAMS:
 	list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
 	echo " rm -f" $$list; \
 	rm -f $$list
-simpletest$(EXEEXT): $(simpletest_OBJECTS) $(simpletest_DEPENDENCIES) 
+folialint$(EXEEXT): $(folialint_OBJECTS) $(folialint_DEPENDENCIES) $(EXTRA_folialint_DEPENDENCIES) 
+	@rm -f folialint$(EXEEXT)
+	$(CXXLINK) $(folialint_OBJECTS) $(folialint_LDADD) $(LIBS)
+simpletest$(EXEEXT): $(simpletest_OBJECTS) $(simpletest_DEPENDENCIES) $(EXTRA_simpletest_DEPENDENCIES) 
 	@rm -f simpletest$(EXEEXT)
 	$(CXXLINK) $(simpletest_OBJECTS) $(simpletest_LDADD) $(LIBS)
 
@@ -334,6 +398,7 @@ distclean-compile:
 
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/document.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/folia.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/folialint.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/foliautils.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/simpletest.Po at am__quote@
 
@@ -497,14 +562,15 @@ check-TESTS: $(TESTS)
 	  fi; \
 	  dashes=`echo "$$dashes" | sed s/./=/g`; \
 	  if test "$$failed" -eq 0; then \
-	    echo "$$grn$$dashes"; \
+	    col="$$grn"; \
 	  else \
-	    echo "$$red$$dashes"; \
+	    col="$$red"; \
 	  fi; \
-	  echo "$$banner"; \
-	  test -z "$$skipped" || echo "$$skipped"; \
-	  test -z "$$report" || echo "$$report"; \
-	  echo "$$dashes$$std"; \
+	  echo "$${col}$$dashes$${std}"; \
+	  echo "$${col}$$banner$${std}"; \
+	  test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \
+	  test -z "$$report" || echo "$${col}$$report$${std}"; \
+	  echo "$${col}$$dashes$${std}"; \
 	  test "$$failed" -eq 0; \
 	else :; fi
 
@@ -542,9 +608,11 @@ check-am: all-am
 	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
 	$(MAKE) $(AM_MAKEFLAGS) check-TESTS
 check: check-am
-all-am: Makefile $(LTLIBRARIES)
+all-am: Makefile $(LTLIBRARIES) $(PROGRAMS)
+install-binPROGRAMS: install-libLTLIBRARIES
+
 installdirs:
-	for dir in "$(DESTDIR)$(libdir)"; do \
+	for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)"; do \
 	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
 	done
 install: install-am
@@ -557,10 +625,15 @@ install-am: all-am
 
 installcheck: installcheck-am
 install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
-	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
-	  `test -z '$(STRIP)' || \
-	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+	if test -z '$(STRIP)'; then \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	      install; \
+	else \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+	fi
 mostlyclean-generic:
 
 clean-generic:
@@ -575,8 +648,8 @@ maintainer-clean-generic:
 	@echo "it deletes files that may require special tools to rebuild."
 clean: clean-am
 
-clean-am: clean-checkPROGRAMS clean-generic clean-libLTLIBRARIES \
-	clean-libtool mostlyclean-am
+clean-am: clean-binPROGRAMS clean-checkPROGRAMS clean-generic \
+	clean-libLTLIBRARIES clean-libtool mostlyclean-am
 
 distclean: distclean-am
 	-rm -rf ./$(DEPDIR)
@@ -602,7 +675,7 @@ install-dvi: install-dvi-am
 
 install-dvi-am:
 
-install-exec-am: install-libLTLIBRARIES
+install-exec-am: install-binPROGRAMS install-libLTLIBRARIES
 
 install-html: install-html-am
 
@@ -642,24 +715,25 @@ ps: ps-am
 
 ps-am:
 
-uninstall-am: uninstall-libLTLIBRARIES
+uninstall-am: uninstall-binPROGRAMS uninstall-libLTLIBRARIES
 
 .MAKE: check-am install-am install-strip
 
 .PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
-	clean-checkPROGRAMS clean-generic clean-libLTLIBRARIES \
-	clean-libtool ctags distclean distclean-compile \
-	distclean-generic distclean-libtool distclean-tags distdir dvi \
-	dvi-am html html-am info info-am install install-am \
-	install-data install-data-am install-dvi install-dvi-am \
-	install-exec install-exec-am install-html install-html-am \
-	install-info install-info-am install-libLTLIBRARIES \
-	install-man install-pdf install-pdf-am install-ps \
-	install-ps-am install-strip installcheck installcheck-am \
-	installdirs maintainer-clean maintainer-clean-generic \
-	mostlyclean mostlyclean-compile mostlyclean-generic \
-	mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
-	uninstall-am uninstall-libLTLIBRARIES
+	clean-binPROGRAMS clean-checkPROGRAMS clean-generic \
+	clean-libLTLIBRARIES clean-libtool ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-binPROGRAMS install-data \
+	install-data-am install-dvi install-dvi-am install-exec \
+	install-exec-am install-html install-html-am install-info \
+	install-info-am install-libLTLIBRARIES install-man install-pdf \
+	install-pdf-am install-ps install-ps-am install-strip \
+	installcheck installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-binPROGRAMS \
+	uninstall-libLTLIBRARIES
 
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
diff --git a/src/document.cxx b/src/document.cxx
index 9fd2d6a..2f1fc1c 100644
--- a/src/document.cxx
+++ b/src/document.cxx
@@ -1,8 +1,8 @@
 /*
-  $Id: document.cxx 14474 2012-03-19 13:04:14Z sloot $
+  $Id: document.cxx 15909 2013-04-03 13:52:24Z sloot $
   $URL: https://ilk.uvt.nl/svn/sources/libfolia/trunk/src/document.cxx $
 
-  Copyright (c) 1998 - 2012
+  Copyright (c) 1998 - 2013
   ILK   - Tilburg University
   CLiPS - University of Antwerp
  
@@ -37,15 +37,16 @@
 #include <map>
 #include <algorithm>
 #include <stdexcept>
-#include "folia/document.h"
-#include "folia/folia.h"
+#include "ticcutils/XMLtools.h"
+#include "libfolia/document.h"
 #include "config.h"
 
 using namespace std;
+using namespace TiCC;
 
 namespace folia {
 
-  const string FOLIAVERSION = "0.8"; // the FoLiA version we implement
+  const string FOLIAVERSION = "0.8.2"; // the FoLiA version we implement
   const string NSFOLIA = "http://ilk.uvt.nl/folia";
   const string NSDCOI = "http://lands.let.ru.nl/projects/d-coi/ns/1.0";
   const string NSIMDI = "http://www.mpi.nl/IMDI/Schema/IMDI";
@@ -66,7 +67,8 @@ namespace folia {
     metadata = 0;
     xmldoc = 0;
     foliadoc = 0;
-    _foliaNs = 0;
+    _foliaNsIn = 0;
+    _foliaNsOut = 0;
     debug = 0;
     version = FOLIAVERSION;
   }
@@ -126,14 +128,20 @@ namespace folia {
     else
       loadall = true;
     it = kwargs.find( "version" );
-    if ( it != kwargs.end() )
+    if ( it != kwargs.end() ){
       version = it->second;
+    }
     else
       version.clear();
-
+    
     it = kwargs.find( "id" );
     if ( it != kwargs.end() ){
-      _id = it->second;
+      if ( isNCName( it->second ) ){
+	_id = it->second;
+      }
+      else {
+	// isNCName throws
+      }
       happy = true;
     }
     else {
@@ -163,13 +171,27 @@ namespace folia {
       throw DuplicateIDError( s );
   }
 
+  static int error_sink(void *mydata, xmlError *error ){
+    int *cnt = (int*)mydata;
+    if ( *cnt == 0 ){
+      cerr << "\nXML-error: " << error->message << endl;
+    }
+    (*cnt)++;
+    return 1;
+  }
+
   bool Document::readFromFile( const string& s ){
     if ( xmldoc ){
       throw runtime_error( "Document is aready initialized" );
       return false;
     }
-    xmldoc = xmlReadFile( s.c_str(), 0, 0 );
+    int cnt = 0;
+    xmlSetStructuredErrorFunc( &cnt, (xmlStructuredErrorFunc)error_sink );
+    xmldoc = xmlReadFile( s.c_str(), 0, XML_PARSE_NOBLANKS );
     if ( xmldoc ){
+      if ( cnt > 0 ){
+	throw XmlError( "document is invalid" );
+      }
       if ( debug )
 	cout << "read a doc from " << s << endl;
       foliadoc = parseXml();
@@ -192,8 +214,13 @@ namespace folia {
       throw runtime_error( "Document is aready initialized" );
       return false;
     }
-    xmldoc = xmlReadMemory( s.c_str(), s.length(), 0, 0, 0 );
+    int cnt = 0;
+    xmlSetStructuredErrorFunc( &cnt, (xmlStructuredErrorFunc)error_sink );
+    xmldoc = xmlReadMemory( s.c_str(), s.length(), 0, 0, XML_PARSE_NOBLANKS );
     if ( xmldoc ){
+      if ( cnt > 0 ){
+	throw XmlError( "document is invalid" );
+      }
       if ( debug )
 	cout << "read a doc from string" << endl;
       foliadoc = parseXml();
@@ -217,12 +244,16 @@ namespace folia {
     return os;
   }
 
-  bool Document::save( const string& fn, const string& nsLabel ) {
+  bool Document::save( ostream& os, const string& nsLabel, bool kanon ) {
+    string s = toXml( nsLabel, kanon );
+    os << s << endl;
+    return os;
+  }
+
+  bool Document::save( const string& fn, const string& nsLabel, bool kanon ) {
     ofstream os( fn.c_str() );
     if ( os.good() ) {
-      string s = toXml( nsLabel );
-      os << s << endl;
-      return true;
+      return save( os, nsLabel, kanon );
     }
     throw runtime_error( "saving to file " + fn + " failed" );
     return false;
@@ -266,6 +297,12 @@ namespace folia {
     return foliadoc->select<Sentence>( excludeSet );
   }
   
+  vector<Sentence*> Document::sentenceParts() const {
+    static set<ElementType> excludeSet;
+    vector<Sentence*> sents = foliadoc->select<Sentence>( excludeSet );
+    return sents;
+  }
+  
   Sentence *Document::sentences( size_t index ) const {
     vector<Sentence*> v = sentences();
     if ( index < v.size() ){
@@ -292,9 +329,13 @@ namespace folia {
       excludeSet.insert( Alternative_t );
       excludeSet.insert( Chunk_t );
       excludeSet.insert( SyntacticUnit_t );
+      excludeSet.insert( Coreferences_t );
+      excludeSet.insert( Semroles_t );
       excludeSet.insert( Entity_t );
-      excludeSet.insert( DependencyHead_t );
+      excludeSet.insert( Headwords_t );
+      excludeSet.insert( TimingLayer_t );
       excludeSet.insert( DependencyDependent_t );
+      excludeSet.insert( TimeSegment_t );
     }
     return foliadoc->select<Word>( excludeSet );
   }
@@ -378,6 +419,7 @@ namespace folia {
 	string s;
 	string a;
 	string t;
+	string d;
 	KWargs::const_iterator it = att.find("set" );
 	if ( it != att.end() ){
 	  s = it->second;
@@ -392,7 +434,11 @@ namespace folia {
 	if ( it != att.end() ){
 	  t = it->second;
 	}
-	declare( type, s, a, t );
+	it = att.find( "datetime" );
+	if ( it != att.end() ){
+	  d = parseDate( it->second );
+	}
+	declare( type, s, a, t, d );
       }
       n = n->next;
     }
@@ -414,6 +460,7 @@ namespace folia {
       throw XmlError("FoLiA Document has no ID!");
       return 0;
     }
+    setAttributes( att );
     FoliaElement *result = FoliaElement::createElement( this, Name(root) );
     if ( debug > 2 )
       cerr << "created " << root << endl;
@@ -480,12 +527,54 @@ namespace folia {
     }
     return result;
   }
+  
+  void Document::addStyle( const std::string& type, const std::string& href ){
+    if ( type == "text/xsl" ){
+      multimap<string,string>::iterator it = styles.find( type );
+      if ( it != styles.end() )
+	throw XmlError( "multiple 'text/xsl' style-sheets defined." );
+    }
+    styles.insert( make_pair( type, href ) );
+  }
+  
+  void Document::replaceStyle( const std::string& type, 
+			       const std::string& href ){
+    multimap<string,string>::iterator it = styles.find( type );
+    if ( it != styles.end() ){
+      it->second = href;
+    }
+    else {
+      styles.insert( make_pair( type, href ) );
+    }
+  }
 
   void Document::getstyles(){
     xmlNode *pnt = xmldoc->children;
     while ( pnt ){
       if ( pnt->type == XML_PI_NODE && Name(pnt) == "xml-stylesheet" ){
-	addStyle( (const char*)pnt->content );
+	string content = (const char*)pnt->content;
+	string type;
+	string href;
+	vector<string> v;
+	split( content, v );
+	if ( v.size() == 2 ){
+	  vector<string> w;
+	  split_at( v[0], w, "=" );
+	  if ( w.size() == 2 && w[0] == "type" ){
+	    type = w[1].substr(1,w[1].length()-2);
+	  }
+	  w.clear();
+	  split_at( v[1], w, "=" );
+	  if ( w.size() == 2 && w[0] == "href" ){
+	    href = w[1].substr(1,w[1].length()-2);
+	  }
+	}
+	if ( !type.empty() && !href.empty() ){
+	  addStyle( type, href );
+	}
+	else {
+	  throw XmlError( "problem parsing line: " + content );
+	}
       }
       pnt = pnt->next;
     }
@@ -494,11 +583,13 @@ namespace folia {
   FoliaElement* Document::parseXml( ){
     getstyles();
     xmlNode *root = xmlDocGetRootElement( xmldoc );
+    _foliaNsIn = root->ns;
     if ( debug > 2 ){
+      using TiCC::operator <<;
       string dum;
       cerr << "root = " << Name( root ) << endl;
       cerr << "in namespace " << getNS( root, dum ) << endl;
-      cerr << "namespace list" << getNSlist( root ) << endl;
+      cerr << "namespace list" << getNSvalues( root ) << endl;
     }
     FoliaElement *result = 0;
     if ( root  ){
@@ -507,7 +598,11 @@ namespace folia {
 	     checkNS( root, NSFOLIA ) ){
 	  result = parseFoliaDoc( root );
 	  if ( result ){
-	    _id = result->id();
+	    if ( isNCName( result->id() ) )
+	      _id = result->id();
+	    else {
+	      // isNCName throws
+	    }
 	  }
 	}
 	else if ( Name( root ) == "DCOI" &&
@@ -533,26 +628,44 @@ namespace folia {
     KWargs kw = getArgs( args );
     string a = kw["annotator"];
     string t = kw["annotatortype"];
+    string d = kw["datetime"];
     kw.erase("annotator");
     kw.erase("annotatortype");
+    kw.erase("datetime");
     if ( kw.size() != 0 ){
-      throw XmlError( "declaration: expected 'annotator' of 'annotatortype', got '" + kw.begin()->first + "'" );
+      throw XmlError( "declaration: expected 'annotator', 'annotatortype' or 'datetime', got '" + kw.begin()->first + "'" );
     }
-    declare( type, st, a, t );
+    declare( type, st, a, t, d );
   }
 
+  string getNow() {
+    time_t Time;
+    time(&Time);
+    tm curtime;
+    localtime_r(&Time,&curtime);
+    char buf[256];
+    strftime( buf, 100, "%Y-%m-%dT%X", &curtime );
+    string res = buf;
+    return res;
+  }
+  
   void Document::declare( AnnotationType::AnnotationType type, 
-			  const string& s, const string& a, const string& t ){
-    if ( !isDeclared( type, s, a, t ) ){
-      annotationdefaults[type].insert( make_pair(s, at_t(a,t) ) );
-      //    cerr << "inserted [" << type << "][" << st << "](" << a << "," << t << ")" << endl;
+			  const string& s, const string& a, 
+			  const string& t, const string& ds ){
+    string d = ds;
+    if ( d == "now()" ){
+      d = getNow();
+    }
+    if ( !isDeclared( type, s, a, t, d ) ){
+      annotationdefaults[type].insert( make_pair(s, at_t(a,t,d) ) );
+      //    cerr << "inserted [" << type << "][" << st << "](" << a << "," << t << "," << d ")" << endl;
       //    cerr << "annotation defaults now: " <<  annotationdefaults << endl;
       
     }
   }
 
   FoliaElement* Document::addNode( ElementType et, const KWargs& kwargs ){
-    FoliaElement *res = FoliaElement::createElement( this, toString(et) );
+    FoliaElement *res = FoliaElement::createElement( this, et );
     res->setAttributes( kwargs );
     foliadoc->append( res );
     return res;
@@ -561,14 +674,18 @@ namespace folia {
   bool Document::isDeclared( AnnotationType::AnnotationType type,
 			     const string& s, 
 			     const string& a,
-			     const string& t ){
+			     const string& t,
+			     const string& d ){
+    if ( type == AnnotationType::NO_ANN ){
+      return true;
+    }
     map<AnnotationType::AnnotationType,multimap<string,at_t> >::const_iterator mit1 = annotationdefaults.find(type);
     if ( mit1 != annotationdefaults.end() ){
       if ( s.empty() )
 	throw runtime_error("isDeclared with empty set.");
       multimap<string,at_t>::const_iterator mit2 = mit1->second.lower_bound(s);
       while ( mit2 != mit1->second.upper_bound(s) ){
-	if ( mit2->second.a == a && mit2->second.t == t )
+	if ( mit2->second.a == a && mit2->second.t == t && mit2->second.d == d )
 	  return true;
 	++mit2;
       }
@@ -578,6 +695,9 @@ namespace folia {
 
   bool Document::isDeclared( AnnotationType::AnnotationType type,
 			     const string& s ){
+    if ( type == AnnotationType::NO_ANN ){
+      return true;
+    }
     map<AnnotationType::AnnotationType,multimap<string,at_t> >::const_iterator mit1 = annotationdefaults.find(type);
     if ( mit1 != annotationdefaults.end() ){
       if ( s.empty() )
@@ -589,6 +709,8 @@ namespace folia {
   }
 
   string Document::defaultset( AnnotationType::AnnotationType type ) const {
+    if ( type == AnnotationType::NO_ANN )
+      return "";
     // search a set. it must be unique. Otherwise return ""
     //    cerr << "zoek '" << type << "' default set " <<  annotationdefaults << endl;
     map<AnnotationType::AnnotationType,multimap<string,at_t> >::const_iterator mit1 = annotationdefaults.find(type);
@@ -604,6 +726,9 @@ namespace folia {
 
   std::string Document::defaultannotator( AnnotationType::AnnotationType type,
 					  const string& st ) const {
+    if ( type == AnnotationType::NO_ANN ){
+      return "";
+    }
     // if ( !st.empty() ){
     //   cerr << "zoek '" << st << "' default annotator " <<  annotationdefaults << endl;
     // }
@@ -630,6 +755,9 @@ namespace folia {
 
   std::string Document::defaultannotatortype( AnnotationType::AnnotationType type,
 					      const string& st ) const {
+    if ( type == AnnotationType::NO_ANN ){
+      return "";
+    }
     map<AnnotationType::AnnotationType,multimap<string,at_t> >::const_iterator mit1 = annotationdefaults.find(type);
     string result;
     if ( mit1 != annotationdefaults.end() ){
@@ -649,6 +777,27 @@ namespace folia {
     return result;
   }
 
+  std::string Document::defaultdatetime( AnnotationType::AnnotationType type,
+					 const string& st ) const {
+    map<AnnotationType::AnnotationType,multimap<string,at_t> >::const_iterator mit1 = annotationdefaults.find(type);
+    string result;
+    if ( mit1 != annotationdefaults.end() ){
+      if ( st.empty() ){
+	if ( mit1->second.size() == 1 )
+	  result = mit1->second.begin()->second.d;
+	return result;
+      }
+      else {
+	if ( mit1->second.count( st ) == 1 ){
+	  map<string,at_t>::const_iterator mit2 = mit1->second.find( st );
+	  result = mit2->second.d;
+	}
+      }
+    }
+    //  cerr << "get default ==> " << result << endl;
+    return result;
+  }
+
   void Document::setannotations( xmlNode *node ) const {
     map<AnnotationType::AnnotationType,multimap<string,at_t> >::const_iterator mit = annotationdefaults.begin();
     while ( mit != annotationdefaults.end() ){
@@ -657,7 +806,7 @@ namespace folia {
 	// Find the 'label' 
 	string label = toString( mit->first );
 	label += "-annotation";
-	xmlNode *n = xmlAddChild( node, newXMLNode( _foliaNs, label ) );
+	xmlNode *n = XmlNewNode( foliaNs(), label );
 	KWargs args;
 	string s = it->second.a;
 	if ( !s.empty() )
@@ -665,10 +814,14 @@ namespace folia {
 	s = it->second.t;
 	if ( !s.empty() )
 	  args["annotatortype"] = s;
+	s = it->second.d;
+	if ( !s.empty() )
+	  args["datetime"] = s;
 	s = it->first;
 	if ( s != "undefined" ) // the default
 	  args["set"] = s;
 	addAttributes( n, args );
+	xmlAddChild( node, n );
 	++it;
       }
       ++mit;
@@ -695,26 +848,31 @@ namespace folia {
 	atts["license"] = _license;
       if ( !_publisher.empty() )
 	atts["publisher"] = _publisher;
+      addAttributes( node, atts );
     }
     else if ( _metadatatype == IMDI  ||
 	      _metadatatype == CMDI ){
-      xmlAddChild( node, xmlCopyNodeList(metadata) );
       if ( !_metadatafile.empty() )
 	atts["src"] = _metadatafile;
+      addAttributes( node, atts );
+      xmlAddChild( node, xmlCopyNodeList(metadata) );
     }
-    addAttributes( node, atts );
   }
 
   void Document::setstyles( xmlDoc* doc ) const {
-    for ( size_t i=0; i < styles.size(); ++i ){
+    multimap<string,string>::const_iterator it = styles.begin();
+    while ( it != styles.end() ){
+      string content = "type=\"" + it->first 
+	+ "\" href=\"" + it->second + "\"";
       xmlAddChild( (xmlNode*)doc,
 		   xmlNewDocPI( doc,
 				(const xmlChar*)"xml-stylesheet", 
-				(const xmlChar*)styles[i].c_str() ) );
+				(const xmlChar*)content.c_str() ) );
+      ++it;
     }
   }
 
-  string Document::toXml( const string& nsLabel ) const {
+  string Document::toXml( const string& nsLabel, bool kanon ) const {
     string result;
     if ( foliadoc ){
       xmlDoc *outDoc = xmlNewDoc( (const xmlChar*)"1.0" );
@@ -724,15 +882,18 @@ namespace folia {
       xmlNs *xl = xmlNewNs( root, (const xmlChar *)"http://www.w3.org/1999/xlink", 
 			    (const xmlChar *)"xlink" );
       xmlSetNs( root, xl );
-      if ( !_foliaNs ){
+      if ( !_foliaNsIn ){
 	if ( nsLabel.empty() )
-	  _foliaNs = xmlNewNs( root, (const xmlChar *)NSFOLIA.c_str(), 0 );
+	  _foliaNsOut = xmlNewNs( root, (const xmlChar *)NSFOLIA.c_str(), 0 );
 	else
-	  _foliaNs = xmlNewNs( root,
-			       (const xmlChar *)NSFOLIA.c_str(),
-			       (const xmlChar*)nsLabel.c_str() );
+	  _foliaNsOut = xmlNewNs( root,
+				  (const xmlChar *)NSFOLIA.c_str(),
+				  (const xmlChar*)nsLabel.c_str() );
       }
-      xmlSetNs( root, _foliaNs );
+      else {
+	_foliaNsOut = xmlNewNs( root, _foliaNsIn->href, _foliaNsIn->prefix );
+      }
+      xmlSetNs( root, _foliaNsOut );
       KWargs attribs;
       attribs["_id"] = foliadoc->id(); // sort "id" in front!
       attribs["generator"] = string("libfolia-v") + VERSION;
@@ -740,21 +901,21 @@ namespace folia {
 	attribs["version"] = version;
       addAttributes( root, attribs );
 
-      xmlNode *md = xmlAddChild( root,  newXMLNode( _foliaNs, "metadata" ) );  
-      xmlNode *an = xmlAddChild( md,  newXMLNode( _foliaNs, "annotations" ) );
+      xmlNode *md = xmlAddChild( root, XmlNewNode( foliaNs(), "metadata" ) );  
+      xmlNode *an = xmlAddChild( md, XmlNewNode( foliaNs(), "annotations" ) );
       setannotations( an );
       setmetadata( md );
       vector<FoliaElement*>::const_iterator it= foliadoc->data.begin();
       while ( it != foliadoc->data.end() ){
-	xmlAddChild( root, (*it)->xml( true ) );
+	xmlAddChild( root, (*it)->xml( true, kanon ) );
 	++it;
       }
       xmlChar *buf; int size;
-      xmlDocDumpFormatMemory( outDoc, &buf, &size, 1 );
+      xmlDocDumpFormatMemoryEnc( outDoc, &buf, &size, "UTF-8", 1 );
       result = string( (const char *)buf, size );
       xmlFree( buf );
       xmlFreeDoc( outDoc );
-      _foliaNs = 0;
+      _foliaNsOut = 0;
     }
     else
       throw runtime_error( "can't save, no doc" );
@@ -985,6 +1146,12 @@ namespace folia {
     }
   }
 
+  inline std::ostream& operator<<( std::ostream& os, const Pattern& p ){
+    using TiCC::operator <<;
+    os << "pattern: " << p.sequence;
+    return os;
+  }
+
   bool Pattern::match( const UnicodeString& us, size_t& pos, int& gap, 
 		       bool& done, bool& flag ) const {
     UnicodeString s = us;
diff --git a/src/folia.cxx b/src/folia.cxx
index a6288d7..647032c 100644
--- a/src/folia.cxx
+++ b/src/folia.cxx
@@ -1,8 +1,8 @@
 /*
-  $Id: folia.cxx 14476 2012-03-19 15:48:35Z sloot $
+  $Id: folia.cxx 15909 2013-04-03 13:52:24Z sloot $
   $URL: https://ilk.uvt.nl/svn/sources/libfolia/trunk/src/folia.cxx $
 
-  Copyright (c) 1998 - 2012
+  Copyright (c) 1998 - 2013
   ILK   - Tilburg University
   CLiPS - University of Antwerp
  
@@ -38,14 +38,17 @@
 #include <map>
 #include <algorithm>
 #include <stdexcept>
-#include "folia/document.h"
-#include "folia/folia.h"
+#include "ticcutils/PrettyPrint.h"
+#include "ticcutils/StringOps.h"
+#include "ticcutils/XMLtools.h"
+#include "libfolia/document.h"
 #include "config.h"
 
 using namespace std;
+using namespace TiCC;
 
 namespace folia {
-
+  
   string VersionName() { return PACKAGE_STRING; }
   string Version() { return VERSION; }
 
@@ -81,7 +84,6 @@ namespace folia {
     _confidence = -1;
     _element_id = BASE;
     refcount = 0;
-    _datetime = 0;
     _parent = 0;
     _auth = true;
     _required_attributes = NO_ATT;
@@ -105,7 +107,6 @@ namespace folia {
 	mydoc->keepForDeletion( data[i] );
       }
     }
-    delete _datetime;
   }
 
   xmlNs *FoliaElement::foliaNs() const {
@@ -117,7 +118,7 @@ namespace folia {
 
   void FoliaElement::setAttributes( const KWargs& kwargs ){
     Attrib supported = _required_attributes | _optional_attributes;
-    // if ( _element_id == Gap_t ){
+    // if ( _element_id == Feature_t ){
     //   cerr << "set attributes: " << kwargs << " on " << toString(_element_id) << endl;
     //   cerr << "required = " <<  _required_attributes << endl;
     //   cerr << "optional = " <<  _optional_attributes << endl;
@@ -125,8 +126,10 @@ namespace folia {
     //   cerr << "ID & supported = " << (ID & supported) << endl;
     //   cerr << "ID & _required = " << (ID & _required_attributes ) << endl;
     // }
-    if ( mydoc && mydoc->debug > 2 )
+    if ( mydoc && mydoc->debug > 2 ){
+      using TiCC::operator <<;
       cerr << "set attributes: " << kwargs << " on " << toString(_element_id) << endl;
+    }
   
     KWargs::const_iterator it = kwargs.find( "generate_id" );
     if ( it != kwargs.end() ) {
@@ -144,13 +147,12 @@ namespace folia {
       it = kwargs.find( "id" );
       if ( it != kwargs.end() ) {
 	if ( !ID & supported )
-	  throw ValueError("ID is not supported");
+	  throw ValueError("ID is not supported for " + classname() );
 	else {
+	  isNCName( it->second );
 	  _id = it->second;
 	}
       }
-      else if ( ID & _required_attributes )
-	throw ValueError("ID is required for " + classname() );
       else
 	_id = "";
     }
@@ -158,8 +160,9 @@ namespace folia {
     it = kwargs.find( "set" );
     string def;
     if ( it != kwargs.end() ) {
-      if ( !(CLASS & supported) )
-	throw ValueError("Set is not supported");
+      if ( !( (CLASS|SETONLY) & supported ) ){
+	throw ValueError("Set is not supported for " + classname());
+      }
       else {
 	_set = it->second;
       }
@@ -173,8 +176,6 @@ namespace folia {
     else if ( mydoc && ( def = mydoc->defaultset( _annotation_type )) != "" ){
       _set = def;
     }
-    else if ( mydoc && (CLASS & _required_attributes ) )
-      throw ValueError("Set is required for " + classname() );
     else
       _set = "";
     
@@ -197,8 +198,6 @@ namespace folia {
 	}
       }
     }
-    else if ( CLASS & _required_attributes )
-      throw ValueError("Class is required for " + classname() );
     else
       _class = "";
 
@@ -219,8 +218,6 @@ namespace folia {
 	      (def = mydoc->defaultannotator( _annotation_type, _set )) != "" ){
       _annotator = def;
     }
-    else if ( ANNOTATOR & _required_attributes )
-      throw ValueError("Annotator is required for " + classname() );
     else
       _annotator = "";
   
@@ -231,7 +228,8 @@ namespace folia {
       else {
 	_annotator_type = stringTo<AnnotatorType>( it->second );
 	if ( _annotator_type == UNDEFINED )
-	  throw ValueError("annotatortype must be 'auto' or 'manual'");
+	  throw ValueError( "annotatortype must be 'auto' or 'manual', got '"
+			    + it->second + "'" );
       }
     }
     else if ( mydoc &&
@@ -240,8 +238,6 @@ namespace folia {
       if ( _annotator_type == UNDEFINED )
 	throw ValueError("annotatortype must be 'auto' or 'manual'");
     }
-    else if ( ANNOTATOR & _required_attributes )
-      throw ValueError("Annotatortype is required for " + classname() );
     else
       _annotator_type = UNDEFINED;
 
@@ -254,15 +250,13 @@ namespace folia {
 	try {
 	  _confidence = stringTo<double>(it->second);
 	  if ( _confidence < 0 || _confidence > 1.0 )
-	    throw ValueError("Confidence must be a floating point number between 0 and 1");	    
+	    throw ValueError("Confidence must be a floating point number between 0 and 1, got " + TiCC::toString(_confidence) );	    
 	}
 	catch (...){
 	  throw ValueError("invalid Confidence value, (not a number?)");
 	}
       }
     }
-    else if ( CONFIDENCE & _required_attributes )
-      throw ValueError("Confidence is required for " + classname() );
     else
       _confidence = -1;
 
@@ -274,8 +268,6 @@ namespace folia {
 	_n = it->second;
       }
     }
-    else if ( N & _required_attributes )
-      throw ValueError("N is required");
     else
       _n = "";
   
@@ -284,15 +276,18 @@ namespace folia {
       if ( !(DATETIME & supported) )
 	throw ValueError("datetime is not supported for " + classname() );
       else {
-	_datetime = parseDate( it->second );
-	if ( _datetime == 0 )
+	string time = parseDate( it->second );
+	if ( time.empty() )
 	  throw ValueError( "invalid datetime string:" + it->second );
+	_datetime = time;
       }
     }
-    else if ( DATETIME & _required_attributes )
-      throw ValueError("datetime is required");
+    else if ( mydoc &&
+	      (def = mydoc->defaultdatetime( _annotation_type, _set )) != "" ){
+      _datetime = def;
+    }
     else
-      _datetime = 0;
+      _datetime.clear();
 
     it = kwargs.find( "auth" );
     if ( it != kwargs.end() ){
@@ -318,6 +313,46 @@ namespace folia {
       tmp->setAttributes( newa );
       append( tmp );
     }
+    it = kwargs.find( "value" );
+    if ( it != kwargs.end() ){
+      KWargs newa;
+      newa["class"] = it->second;
+      FoliaElement *tmp = new ValueFeature();
+      tmp->setAttributes( newa );
+      append( tmp );
+    }
+    it = kwargs.find( "function" );
+    if ( it != kwargs.end() ){
+      KWargs newa;
+      newa["class"] = it->second;
+      FoliaElement *tmp = new FunctionFeature();
+      tmp->setAttributes( newa );
+      append( tmp );
+    }
+    it = kwargs.find( "level" );
+    if ( it != kwargs.end() ){
+      KWargs newa;
+      newa["class"] = it->second;
+      FoliaElement *tmp = new LevelFeature();
+      tmp->setAttributes( newa );
+      append( tmp );
+    }
+    it = kwargs.find( "time" );
+    if ( it != kwargs.end() ){
+      KWargs newa;
+      newa["class"] = it->second;
+      FoliaElement *tmp = new TimeFeature();
+      tmp->setAttributes( newa );
+      append( tmp );
+    }
+    it = kwargs.find( "modality" );
+    if ( it != kwargs.end() ){
+      KWargs newa;
+      newa["class"] = it->second;
+      FoliaElement *tmp = new ModalityFeature();
+      tmp->setAttributes( newa );
+      append( tmp );
+    }
     it = kwargs.find( "synset" );
     if ( it != kwargs.end() ){
       KWargs newa;
@@ -330,7 +365,7 @@ namespace folia {
     if ( it != kwargs.end() ){
       KWargs newa;
       newa["class"] = it->second;
-      FoliaElement *tmp = new BegindatetimeFeature();
+      FoliaElement *tmp = new BeginDateTimeFeature();
       tmp->setAttributes( newa );
       append( tmp );
     }
@@ -338,7 +373,7 @@ namespace folia {
     if ( it != kwargs.end() ){
       KWargs newa;
       newa["class"] = it->second;
-      FoliaElement *tmp = new EnddatetimeFeature();
+      FoliaElement *tmp = new EndDateTimeFeature();
       tmp->setAttributes( newa );
       append( tmp );
     }
@@ -366,7 +401,11 @@ namespace folia {
       isDefaultAnn = false;
       attribs["annotator"] = _annotator;
     }
-  
+
+    if ( !_datetime.empty() &&
+	 _datetime != mydoc->defaultdatetime( _annotation_type, _set ) ){
+      attribs["datetime"] = _datetime;
+    }
     if ( _annotator_type != UNDEFINED ){
       AnnotatorType at = stringTo<AnnotatorType>( mydoc->defaultannotatortype( _annotation_type, _set ) );
       if ( (!isDefaultSet || !isDefaultAnn) && _annotator_type != at ){
@@ -378,14 +417,11 @@ namespace folia {
     }
   
     if ( _confidence >= 0 )
-      attribs["confidence"] = toString(_confidence);
+      attribs["confidence"] = TiCC::toString(_confidence);
   
     if ( !_n.empty() )
       attribs["n"] = _n;
 
-    if ( _datetime != 0 )
-      attribs["datetime"] = getDateTime();
-
     if ( !AUTH || !_auth )
       attribs["auth"] = "no";
 
@@ -394,7 +430,7 @@ namespace folia {
 
   string FoliaElement::xmlstring() const{
     // serialize to a string (XML fragment)
-    xmlNode *n = xml( true );
+    xmlNode *n = xml( true, false );
     xmlSetNs( n, xmlNewNs( n, (const xmlChar *)NSFOLIA.c_str(), 0 ) );
     xmlBuffer *buf = xmlBufferCreate();
     xmlNodeDump( buf, 0, n, 0, 0 );
@@ -404,30 +440,33 @@ namespace folia {
     return result;
   }
 
-  xmlNode *FoliaElement::xml( bool recursive ) const {
-    xmlNode *e = newXMLNode( foliaNs(), _xmltag );
+  string tagToAtt( const FoliaElement* c ){
+    if ( c->isinstance(SynsetFeature_t) )
+      return "synset";
+    else if ( c->isinstance(ActorFeature_t) )
+      return "actor";
+    else if ( c->isinstance(HeadFeature_t) )
+      return "head";
+    else if ( c->isinstance(ValueFeature_t) )
+      return "value";
+    else if ( c->isinstance(FunctionFeature_t) )
+      return "function";
+    else if ( c->isinstance(BeginDateTimeFeature_t) )
+      return "begindatetime";
+    else if ( c->isinstance(EndDateTimeFeature_t) )
+      return "enddatetime";
+    return "";
+  }
+
+  xmlNode *FoliaElement::xml( bool recursive, bool kanon ) const {
+    xmlNode *e = XmlNewNode( foliaNs(), _xmltag );
     KWargs attribs = collectAttributes();
     set<FoliaElement *> skipelements;
     vector<FoliaElement*>::const_iterator it=data.begin();
     while ( it != data.end() ){
-      if ( (*it)->isinstance(SynsetFeature_t) ){
-	attribs["synset"] = (*it)->cls();
-	skipelements.insert( *it );
-      }
-      else if ( (*it)->isinstance(ActorFeature_t) ){
-	attribs["actor"] = (*it)->cls();
-	skipelements.insert( *it );
-      }
-      else if ( (*it)->isinstance(HeadFeature_t) ){
-	attribs["head"] = (*it)->cls();
-	skipelements.insert( *it );
-      }
-      else if ( (*it)->isinstance(BegindatetimeFeature_t) ){
-	attribs["begindatetime"] = (*it)->cls();
-	skipelements.insert( *it );
-      }
-      else if ( (*it)->isinstance(EnddatetimeFeature_t) ){
-	attribs["enddatetime"] = (*it)->cls();
+      string at = tagToAtt( *it );
+      if ( !at.empty() ){
+	attribs[at] = (*it)->cls();
 	skipelements.insert( *it );
       }
       ++it;
@@ -439,6 +478,7 @@ namespace folia {
       // in front and the 'current' class first
       list<FoliaElement *> textelements;
       list<FoliaElement *> otherelements;
+      multimap<ElementType, FoliaElement *> otherelementsMap;
       vector<FoliaElement*>::const_iterator it=data.begin();
       while ( it != data.end() ){
 	if ( skipelements.find(*it) == skipelements.end() ){
@@ -448,17 +488,35 @@ namespace folia {
 	    else
 	      textelements.push_back( *it );
 	  }
-	  else
-	    otherelements.push_back( *it );
+	  else {
+	    if ( kanon )
+	      otherelementsMap.insert( make_pair( (*it)->element_id(), *it ) );
+	    else
+	      otherelements.push_back( *it );
+	  }
 	}
 	++it;
       }
-      textelements.splice( textelements.end(), otherelements );
       list<FoliaElement*>::const_iterator lit=textelements.begin();
       while ( lit != textelements.end() ){
-	xmlAddChild( e, (*lit)->xml( recursive ) );
+	xmlAddChild( e, (*lit)->xml( recursive, kanon ) );
 	++lit;
       }
+      if ( !kanon ){
+	list<FoliaElement*>::const_iterator lit=otherelements.begin();
+	while ( lit != otherelements.end() ){
+	  xmlAddChild( e, (*lit)->xml( recursive, kanon ) );
+	  ++lit;
+	}
+      }
+      else {
+	multimap<ElementType, FoliaElement*>::const_iterator lit
+	  = otherelementsMap.begin();
+	while ( lit != otherelementsMap.end() ){
+	  xmlAddChild( e, (lit->second)->xml( recursive, kanon ) );
+	  ++lit;
+	}
+      }
     }
     return e;
   }
@@ -468,6 +526,8 @@ namespace folia {
   }
 
   bool FoliaElement::hastext( const string& cls ) const {
+    // does this element have a TextContent with class 'cls'
+    // Default is class="current"
     try {
       this->textcontent(cls);
       return true;
@@ -476,25 +536,27 @@ namespace folia {
     }
   }
   
-  UnicodeString FoliaElement::text( const string& cls ) const {
+  UnicodeString FoliaElement::text( const string& cls, bool retaintok ) const {
+    // get the UnicodeString value of underlying elements
+    // default cls="current"
     if ( !PRINTABLE )
       throw NoSuchText( _xmltag );
     //  cerr << (void*)this << ":text() for " << _xmltag << " and class= " << cls << " step 1 " << endl;
     
     UnicodeString result;    
     try {
-      result = this->textcontent(cls)->text(cls);
+      result = this->textcontent(cls)->text(cls, retaintok );
     } catch (NoSuchText& e ) {
       for( size_t i=0; i < data.size(); ++i ){
 	// try to get text dynamically from children
 	// skip TextContent elements
 	if ( data[i]->PRINTABLE && !data[i]->isinstance( TextContent_t ) ){
 	  try {
-	    UnicodeString tmp = data[i]->text( cls );
+	    UnicodeString tmp = data[i]->text( cls, retaintok );
 	    //	cerr << "text() for " << _xmltag << " step 2, tmp= " << tmp << endl;
 	    result += tmp;
 	    if ( !tmp.isEmpty() ){
-	      result += UTF8ToUnicode( data[i]->getTextDelimiter() );
+	      result += UTF8ToUnicode( data[i]->getTextDelimiter( retaintok ) );
 	    }
 	  } catch ( NoSuchText& e ){
 	  }
@@ -514,11 +576,14 @@ namespace folia {
   }
   
   UnicodeString FoliaElement::stricttext( const string& cls ) const {
+    // get UnicoeString content of TextContent children only
+    // default cls="current"
     return this->textcontent(cls)->text(cls);
   }
 
   TextContent *FoliaElement::textcontent( const string& cls ) const {
     // Get the text explicitly associated with this element (of the specified class).
+    // the default class is 'current'
     // Returns the TextContent instance rather than the actual text. Does not recurse into children
     // with sole exception of Correction
     // Raises NoSuchText exception if not found. 
@@ -566,6 +631,8 @@ namespace folia {
 
   TextContent *FoliaElement::settext( const string& txt, 
 				      const string& cls ){
+    // create a TextContent child of class 'cls'
+    // Default cls="current"
     KWargs args;
     args["value"] = txt;
     args["class"] = cls;
@@ -575,6 +642,22 @@ namespace folia {
     return node;
   }
 
+  TextContent *FoliaElement::settext( const string& txt, 
+				      int offset,
+				      const string& cls ){
+    // create a TextContent child of class 'cls'
+    // Default cls="current"
+    // sets the offset attribute.
+    KWargs args;
+    args["value"] = txt;
+    args["class"] = cls;
+    args["offset"] = TiCC::toString(offset);
+    TextContent *node = new TextContent( mydoc );
+    node->setAttributes( args );
+    replace( node );
+    return node;
+  }
+
   string FoliaElement::description() const {
     vector<FoliaElement *> v =  select( Description_t, false );
     if ( v.size() == 0 )
@@ -583,34 +666,67 @@ namespace folia {
       return v[0]->description();
   }
 
+  void fillSM( map<ElementType,set<ElementType> >& sm ){
+    static ElementType featureSet[] = { SynsetFeature_t, 
+					ActorFeature_t, HeadFeature_t, 
+					ValueFeature_t, TimeFeature_t, 
+					ModalityFeature_t, LevelFeature_t,
+					BeginDateTimeFeature_t, 
+					EndDateTimeFeature_t,
+					FunctionFeature_t };
+    sm[Feature_t] = set<ElementType>(featureSet, featureSet + 10 );
+    static ElementType annolaySet[] = { SyntaxLayer_t, 
+					Chunking_t, Entities_t, 
+					TimingLayer_t, Dependencies_t, 
+					Coreferences_t, Semroles_t };
+    sm[AnnotationLayer_t] = set<ElementType>( annolaySet, 
+					      annolaySet + 7 );
+  }
+
+  bool isSubClass( ElementType e1, ElementType e2 ){
+    static map<ElementType,set<ElementType> > sm;
+    if ( sm.empty() )
+      fillSM( sm );
+    map<ElementType,set<ElementType> >::const_iterator it = sm.find( e2 );
+    if ( it != sm.end() ){
+      return it->second.find( e1 ) != it->second.end();
+    }
+    return false;
+  }
+
   bool FoliaElement::acceptable( ElementType t ) const {
     set<ElementType>::const_iterator it = _accepted_data.find( t );
-    if ( it == _accepted_data.end() )
+    if ( it == _accepted_data.end() ){
       return false;
+      // it = _accepted_data.begin();
+      // while ( it != _accepted_data.end() ){
+      // 	if ( isSubClass( t, *it ) )
+      // 	  return true;
+      // 	++it;
+      // }
+      // return false;
+    }
     return true;
   }
  
-  bool FoliaElement::addable( const FoliaElement *c,
-			      const string& setname ) const {
+  bool FoliaElement::addable( const FoliaElement *c ) const {
     if ( !acceptable( c->_element_id ) ){
       throw ValueError( "Unable to append object of type " + c->classname()
 			+ " to a " + classname() );
-      return false;
     }
     if ( c->occurrences > 0 ){
       vector<FoliaElement*> v = select( c->_element_id );
       size_t count = v.size();
-      if ( count > c->occurrences )
-	throw DuplicateAnnotationError( "Unable to add another object of type " + c->classname() + " to " + classname() + ". There are already " + toString(count) + " instances of this class, which is the maximum." );
-      return false;
+      if ( count > c->occurrences ){
+	throw DuplicateAnnotationError( "Unable to add another object of type " + c->classname() + " to " + classname() + ". There are already " + TiCC::toString(count) + " instances of this class, which is the maximum." );
+      }
     }
-    if ( c->occurrences_per_set > 0 && !setname.empty() &&
-	 ( CLASS & c->_required_attributes ) ){
-      vector<FoliaElement*> v = select( c->_element_id, setname );
+    if ( c->occurrences_per_set > 0 &&
+	 ( (CLASS|SETONLY) & c->_required_attributes ) ){
+      vector<FoliaElement*> v = select( c->_element_id, c->_set );
       size_t count = v.size();
       if ( count > c->occurrences_per_set )
-	throw DuplicateAnnotationError( "Unable to add another object of type " + c->classname() + " to " + classname() + ". There are already " + toString(count) + " instances of this class, which is the maximum." );
-      return false;
+	throw DuplicateAnnotationError( "Unable to add another object of type " + c->classname() + " to " + classname() + ". There are already " + TiCC::toString(count) + " instances of this class, which is the maximum." );
     }
     return true;
   }
@@ -633,9 +749,38 @@ namespace folia {
     }
   }
   
+  bool FoliaElement::checkAtts(){
+    if ( _id.empty() && (ID & _required_attributes ) ){
+      throw ValueError( "ID is required for " + classname() );
+    }
+    if ( _set.empty() && (CLASS & _required_attributes ) ){
+      throw ValueError( "Set is required for " + classname() );
+    }
+    if ( _class.empty() && ( CLASS & _required_attributes ) ){
+      throw ValueError( "Class is required for " + classname() );
+    }
+    if ( _annotator.empty() && ( ANNOTATOR & _required_attributes ) ){
+      throw ValueError( "Annotator is required for " + classname() );
+    }
+    if ( _annotator_type == UNDEFINED && ( ANNOTATOR & _required_attributes ) ){
+      throw ValueError( "Annotatortype is required for " + classname() );
+    }
+    if ( _confidence == -1 && ( CONFIDENCE & _required_attributes ) ){
+      throw ValueError( "Confidence is required for " + classname() );
+    }
+    if ( _n.empty() && ( N & _required_attributes ) ){
+      throw ValueError( "N is required for " + classname() );
+    }
+    if ( DATETIME & _required_attributes ){
+      throw ValueError( "datetime is required for " + classname() );
+    }
+    return true;
+  }
+
   FoliaElement *FoliaElement::append( FoliaElement *child ){
     bool ok = false;
     try {
+      ok = child->checkAtts();
       ok = addable( child );
     }
     catch ( exception& ){
@@ -675,17 +820,18 @@ namespace folia {
   }
 
   vector<FoliaElement*> FoliaElement::select( ElementType et,
-					      const string& val,
+					      const string& st,
 					      const set<ElementType>& exclude,
 					      bool recurse ) const {
     vector<FoliaElement*> res;
     for ( size_t i = 0; i < data.size(); ++i ){
-      if ( data[i]->_element_id == et  && data[i]->_set == val ){
+      if ( data[i]->_element_id == et && 
+	   ( st.empty() || data[i]->_set == st ) ){
 	res.push_back( data[i] );
       }
       if ( recurse ){
 	if ( exclude.find( data[i]->_element_id ) == exclude.end() ){
-	  vector<FoliaElement*> tmp = data[i]->select( et, val, exclude, recurse );
+	  vector<FoliaElement*> tmp = data[i]->select( et, st, exclude, recurse );
 	  res.insert( res.end(), tmp.begin(), tmp.end() );
 	}
       }
@@ -694,7 +840,7 @@ namespace folia {
   }
 
   vector<FoliaElement*> FoliaElement::select( ElementType et,
-					      const string& val,
+					      const string& st,
 					      bool recurse ) const {
     static set<ElementType> excludeSet;
     if ( excludeSet.empty() ){
@@ -702,7 +848,7 @@ namespace folia {
       excludeSet.insert( Suggestion_t );
       excludeSet.insert( Alternative_t );
     }
-    return select( et, val, excludeSet, recurse );
+    return select( et, st, excludeSet, recurse );
   }
 
   vector<FoliaElement*> FoliaElement::select( ElementType et,
@@ -734,14 +880,15 @@ namespace folia {
       excludeSet.insert( Chunk_t );
       excludeSet.insert( SyntacticUnit_t );
       excludeSet.insert( Entity_t );
-      excludeSet.insert( DependencyHead_t );
+      excludeSet.insert( Headwords_t );
       excludeSet.insert( DependencyDependent_t );
     }
     return select( et, excludeSet, recurse );
   }
-
+  
   FoliaElement* FoliaElement::parseXml( const xmlNode *node ){
     KWargs att = getAttributes( node );
+    //    cerr << "got attributes " << att << endl;
     setAttributes( att );
     xmlNode *p = node->children;
     while ( p ){
@@ -769,24 +916,23 @@ namespace folia {
     if ( !(DATETIME & supported) )
       throw ValueError("datetime is not supported for " + classname() );
     else {
-      _datetime = parseDate( s );
-      if ( _datetime == 0 )
+      string time = parseDate( s );
+      if ( time.empty() )
 	throw ValueError( "invalid datetime string:" + s );
+      _datetime = time;
     }
   }
 
   string FoliaElement::getDateTime() const {
-    char buf[100];
-    strftime( buf, 100, "%Y-%m-%dT%X", _datetime );
-    return buf;
+    return _datetime;
   }
 
-  string FoliaElement::pos() const { 
-    return annotation<PosAnnotation>()->cls(); 
+  string FoliaElement::pos( const string& st ) const { 
+    return annotation<PosAnnotation>( st )->cls(); 
   }
   
-  string FoliaElement::lemma() const { 
-    return annotation<LemmaAnnotation>()->cls(); 
+  string FoliaElement::lemma( const string& st ) const { 
+    return annotation<LemmaAnnotation>( st )->cls(); 
   }
 
   PosAnnotation *FoliaElement::addPosAnnotation( const KWargs& args ){
@@ -833,6 +979,51 @@ namespace folia {
     return res;
   }
 
+
+  vector<Word*> Quote::wordParts() const {
+    vector<Word*> result;
+    for ( size_t i=0; i < data.size(); ++i ){
+      FoliaElement *pnt = data[i];
+      if ( pnt->isinstance( Word_t ) )
+	result.push_back( dynamic_cast<Word*>(pnt) );
+      else if ( pnt->isinstance( Sentence_t ) ){
+	PlaceHolder *p = new PlaceHolder( mydoc, "text='" + 
+					  pnt->id() + "'");
+	mydoc->keepForDeletion( p );
+	result.push_back( p );
+      }
+      else if ( pnt->isinstance( Quote_t ) ){
+	vector<Word*> tmp = pnt->wordParts();
+	result.insert( result.end(), tmp.begin(), tmp.end() );
+      }
+      else if ( pnt->isinstance( Description_t ) ){
+	// ignore
+      }
+      else {
+	throw XmlError( "Word or Sentence expected in Quote. got: " 
+			+ pnt->classname() );
+      }
+    }
+    return result;
+  }
+
+  vector<Word*> Sentence::wordParts() const {
+    vector<Word*> result;
+    for ( size_t i=0; i < data.size(); ++i ){
+      FoliaElement *pnt = data[i];
+      if ( pnt->isinstance( Word_t ) )
+	result.push_back( dynamic_cast<Word*>(pnt) );
+      else if ( pnt->isinstance( Quote_t ) ){	
+	vector<Word*> v = pnt->wordParts();
+	result.insert( result.end(), v.begin(),v.end() );
+      }
+      else {
+	// skip all other stuff. Is there any?
+      }
+    }
+    return result;
+  }
+  
   Correction *Sentence::splitWord( FoliaElement *orig, FoliaElement *p1, FoliaElement *p2, const KWargs& args ){
     vector<FoliaElement*> ov;
     ov.push_back( orig );
@@ -927,7 +1118,6 @@ namespace folia {
     }
   }
 
-
   void TextContent::setAttributes( const KWargs& args ){
     KWargs kwargs = args; // need to copy
     KWargs::const_iterator it = kwargs.find( "value" );
@@ -936,7 +1126,7 @@ namespace folia {
       kwargs.erase("value");
     }
     else
-      throw ValueError("TextContent expects value= parameter");
+      throw ValueError( "TextContent expects 'value' attribute" );
     it = kwargs.find( "offset" );
     if ( it != kwargs.end() ) {
       _offset = stringTo<int>(it->second);
@@ -944,6 +1134,13 @@ namespace folia {
     }
     else
       _offset = -1;
+    it = kwargs.find( "lang" );
+    if ( it != kwargs.end() ) {
+      _lang = it->second;
+      kwargs.erase("lang");
+    }
+    else
+      _lang.clear();
     it = kwargs.find( "ref" );
     if ( it != kwargs.end() ) {
       throw NotImplementedError( "ref attribute in TextContent" );
@@ -959,6 +1156,7 @@ namespace folia {
 
   FoliaElement* TextContent::parseXml( const xmlNode *node ){
     KWargs att = getAttributes( node );
+    using TiCC::operator<<;
     att["value"] = XmlContent( node );
     setAttributes( att );
     if ( mydoc && mydoc->debug > 2 )
@@ -994,7 +1192,7 @@ namespace folia {
     return UnicodeToUTF8(_text);
   }
 
-  UnicodeString TextContent::text( const string& ) const{
+  UnicodeString TextContent::text( const string&, bool ) const{
     return _text;
   }
 
@@ -1003,7 +1201,7 @@ namespace folia {
     //    cerr << "generateId," << tag << " nodeId = " << nodeId << endl;
     int max = getMaxId(tag);
     //    cerr << "MAX = " << max << endl;
-    string id = nodeId + '.' + tag + '.' +  toString( max + 1 );
+    string id = nodeId + '.' + tag + '.' +  TiCC::toString( max + 1 );
     //    cerr << "new id = " << id << endl;
     return id;
   }
@@ -1016,7 +1214,7 @@ namespace folia {
   void AllowGenerateID::setMaxId( FoliaElement *child ) {
     if ( !child->id().empty() && !child->xmltag().empty() ){
       vector<string> parts;
-      size_t num = split_at( child->id(), parts, "." );
+      size_t num = TiCC::split_at( child->id(), parts, "." );
       if ( num > 0 ){
 	string val = parts[num-1];
 	int i;
@@ -1285,7 +1483,7 @@ namespace folia {
       excludeSet.insert( Chunk_t );
       excludeSet.insert( SyntacticUnit_t );
       excludeSet.insert( Entity_t );
-      excludeSet.insert( DependencyHead_t );
+      excludeSet.insert( Headwords_t );
       excludeSet.insert( DependencyDependent_t );
     }
     return select<Paragraph>( excludeSet );
@@ -1301,7 +1499,7 @@ namespace folia {
       excludeSet.insert( Chunk_t );
       excludeSet.insert( SyntacticUnit_t );
       excludeSet.insert( Entity_t );
-      excludeSet.insert( DependencyHead_t );
+      excludeSet.insert( Headwords_t );
       excludeSet.insert( DependencyDependent_t );
     }
     return select<Sentence>( excludeSet );
@@ -1315,9 +1513,13 @@ namespace folia {
       excludeSet.insert( Alternative_t );
       excludeSet.insert( Chunk_t );
       excludeSet.insert( SyntacticUnit_t );
+      excludeSet.insert( Coreferences_t );
+      excludeSet.insert( Semroles_t );
       excludeSet.insert( Entity_t );
-      excludeSet.insert( DependencyHead_t );
+      excludeSet.insert( Headwords_t );
+      excludeSet.insert( TimingLayer_t );
       excludeSet.insert( DependencyDependent_t );
+      excludeSet.insert( TimeSegment_t );
     }
     return select<Word>( excludeSet );
   }
@@ -1431,6 +1633,60 @@ namespace folia {
     return atts;
   }
 
+  KWargs AlignReference::collectAttributes() const {
+    KWargs atts;
+    atts["id"] = refId;
+    atts["type"] = _type;
+    if ( !_t.empty() )
+      atts["t"] = _t;
+    return atts;
+  }
+
+  void AlignReference::setAttributes( const KWargs& args ){
+    KWargs::const_iterator it = args.find( "id" );
+    if ( it != args.end() ){
+      refId = it->second;
+    }
+    it = args.find( "type" );
+    if ( it != args.end() ){
+      try {
+	stringTo<ElementType>( it->second );
+      }
+      catch (...){
+	throw XmlError( "attribute 'type' must be an Element Type" );
+      }
+      _type = it->second;
+    }
+    else {
+      throw XmlError( "attribute 'type' required for AlignReference" );
+    }
+    it = args.find( "t" );
+    if ( it != args.end() ){
+      _t = it->second;
+    }
+  }
+
+
+  KWargs Alignment::collectAttributes() const {
+    KWargs atts = FoliaElement::collectAttributes();
+    if ( !_href.empty() ){
+      atts["xlink:href"] = _href;
+      if ( !_type.empty() )
+	atts["xlink:type"] = _type;
+      else
+	atts["xlink:type"] = "simple";
+    }
+    return atts;
+  }
+  
+  void Alignment::setAttributes( const KWargs& args ){
+    KWargs::const_iterator it = args.find( "href" );
+    if ( it != args.end() ){
+      _href = it->second;
+    }
+    FoliaElement::setAttributes( args );
+  }
+
   Correction *Word::correct( const string& s ){
     vector<FoliaElement*> nil;
     KWargs args = getArgs( s );
@@ -1461,12 +1717,13 @@ namespace folia {
 
   FoliaElement *Word::append( FoliaElement *child ) {
     if ( child->element_id() == Pos_t ||
-	 child->element_id() == Lemma_t ){
+    	 child->element_id() == Lemma_t ||
+    	 child->element_id() == Morphology_t ){
       // sanity check, there may be no other child within the same set
       vector<FoliaElement*> v = select( child->element_id(), child->sett() );
       if ( v.empty() ) {
-	// OK!
-	return FoliaElement::append( child );
+    	// OK!
+    	return FoliaElement::append( child );
       }
       delete child;
       throw DuplicateAnnotationError( "Word::append" );
@@ -1507,6 +1764,24 @@ namespace folia {
     return 0;
   }
 
+  vector<Morpheme *> Word::morphemes( const string& set ) const {
+    vector<Morpheme *> result;
+    vector<MorphologyLayer*> mv = select<MorphologyLayer>();
+    for( size_t i=0; i < mv.size(); ++i ){
+      vector<Morpheme*> tmp = mv[i]->select<Morpheme>( set );
+      result.insert( result.end(), tmp.begin(), tmp.end() );
+    }
+    return result;
+  }
+
+  Morpheme * Word::morpheme( size_t pos, const string& set ) const {
+    vector<Morpheme *> tmp = morphemes( set );
+    if ( pos >=0 && pos < tmp.size() )
+      return tmp[pos];
+    else
+      throw range_error( "morpheme() index out of range" );
+  }
+
   Correction *Word::incorrection( ) const {
     // Is the Word part of a correction? If it is, it returns the Correction element, otherwise it returns 0;
     FoliaElement *p = _parent; 
@@ -1670,17 +1945,59 @@ namespace folia {
       cerr << "Found word reference" << id << endl;
     FoliaElement *res = (*mydoc)[id];
     if ( res ){
+      // To DO: check juiste type. Woord, morpheme, dat mag, maar andere?
       res->increfcount();
     }
     else {
       if ( mydoc->debug )
 	cerr << "...Unresolvable!" << endl;
-      res = this;
+      throw XmlError( "Unresolvable id " + id + "in WordReference" );
     }
     delete this;
     return res;
   }
 
+  FoliaElement* AlignReference::parseXml( const xmlNode *node ){
+    KWargs att = getAttributes( node );
+    string val = att["id"];
+    if ( val.empty() )
+      throw XmlError( "ID required for AlignReference" );
+    refId = val;
+    if ( mydoc->debug ) 
+      cerr << "Found AlignReference ID " << refId << endl;
+    val = att["type"];
+    if ( val.empty() )
+      throw XmlError( "type required for AlignReference" );
+    try {
+      stringTo<ElementType>( val );
+    }
+    catch (...){
+      throw XmlError( "type must be an Element Type" );
+    }
+    _type = val;
+    val = att["t"];
+    if ( !val.empty() ){
+      _t = val;
+    }
+    return this;
+  }
+
+  FoliaElement *AlignReference::resolve( const Alignment *ref ) const {
+    if ( ref->href().empty() )
+      return (*mydoc)[refId]; 
+    else
+      throw NotImplementedError( "resolve for external doc" );
+  }
+
+  vector<FoliaElement *> Alignment::resolve() const {
+    vector<AlignReference*> v = select<AlignReference>();
+    vector<FoliaElement*> result;
+    for ( size_t i=0; i < v.size(); ++i ){
+      result.push_back( v[i]->resolve( this ) );
+    }
+    return result;
+  }
+
   void PlaceHolder::setAttributes( const KWargs& args ){
     KWargs::const_iterator it = args.find( "text" );
     if ( it == args.end() ){
@@ -1700,13 +2017,16 @@ namespace folia {
       attribs.erase( "class" );    
       
     if ( _offset >= 0 ){
-      attribs["offset"] = toString( _offset );
+      attribs["offset"] = TiCC::toString( _offset );
+    }
+    if ( !_lang.empty() ){
+      attribs["lang"] = _lang;
     }
     return attribs;
   }
 
-  xmlNode *TextContent::xml( bool ) const {
-    xmlNode *e = FoliaElement::xml( false );
+  xmlNode *TextContent::xml( bool, bool ) const {
+    xmlNode *e = FoliaElement::xml( false, false );
     xmlAddChild( e, xmlNewText( (const xmlChar*)str().c_str()) );
     return e;
   }
@@ -1747,8 +2067,8 @@ namespace folia {
     _value = it->second;
   }
 
-  xmlNode *Description::xml( bool ) const {
-    xmlNode *e = FoliaElement::xml( false );
+  xmlNode *Description::xml( bool, bool ) const {
+    xmlNode *e = FoliaElement::xml( false, false );
     xmlAddChild( e, xmlNewText( (const xmlChar*)_value.c_str()) );
     return e;
   }
@@ -1764,19 +2084,22 @@ namespace folia {
   }
 
   FoliaElement *AbstractSpanAnnotation::append( FoliaElement *child ){
-    if ( child->isinstance(Word_t) && acceptable( WordReference_t ) )
+    if ( child->isinstance(PlaceHolder_t) ||
+	 ( ( child->isinstance(Word_t) || child->isinstance(Morpheme_t) )
+	   && acceptable( WordReference_t ) ) )
       child->increfcount();
     FoliaElement::append( child );
     return child;
   }
 
-  xmlNode *AbstractSpanAnnotation::xml( bool recursive ) const {
-    xmlNode *e = FoliaElement::xml( false );
-    // append Word children:
+  xmlNode *AbstractSpanAnnotation::xml( bool recursive, bool kanon ) const {
+    xmlNode *e = FoliaElement::xml( false, false );
+    // append Word children as WREFS
     vector<FoliaElement*>::const_iterator it=data.begin();
     while ( it != data.end() ){
-      if ( (*it)->element_id() == Word_t ){
-	xmlNode *t = newXMLNode( foliaNs(), "wref" );
+      if ( (*it)->element_id() == Word_t ||
+	   (*it)->element_id() == Morpheme_t ){
+	xmlNode *t = XmlNewNode( foliaNs(), "wref" );
 	KWargs attribs;
 	attribs["id"] = (*it)->id();
 	string txt = (*it)->str();
@@ -1785,8 +2108,13 @@ namespace folia {
 	addAttributes( t, attribs );
 	xmlAddChild( e, t );
       }
-      else
-	xmlAddChild( e, (*it)->xml( recursive ) );
+      else {
+	string at = tagToAtt( *it );
+	if ( at.empty() ){
+	  // otherwise handled by FoliaElement::xml() above
+	  xmlAddChild( e, (*it)->xml( recursive, kanon ) );
+	}
+      }
       ++it;
     }
     return e;
@@ -1800,8 +2128,8 @@ namespace folia {
   }
 
 
-  xmlNode *Content::xml( bool ) const {
-    xmlNode *e = FoliaElement::xml( false );
+  xmlNode *Content::xml( bool, bool ) const {
+    xmlNode *e = FoliaElement::xml( false, false );
     xmlAddChild( e, xmlNewCDataBlock( 0,
 				      (const xmlChar*)value.c_str() ,
 				      value.length() ) );
@@ -1812,30 +2140,41 @@ namespace folia {
     KWargs att = getAttributes( node );
     setAttributes( att );
     xmlNode *p = node->children;
+    bool isCdata = false;
+    bool isText = false;
     while ( p ){
       if ( p->type == XML_CDATA_SECTION_NODE ){
+	if ( isText )
+	  throw XmlError( "intermixing text and CDATA in Content node" );
+	isCdata = true;
+	value += (char*)p->content;
+      }
+      else if ( p->type == XML_TEXT_NODE ){
+	if ( isCdata )
+	  throw XmlError( "intermixing text and CDATA in Content node" );
+	isText = true;
 	value += (char*)p->content;
       }
       p = p->next;
     }
     if ( value.empty() )
-      throw XmlError( "CDATA expected in Content node" );
+      throw XmlError( "CDATA or Text expected in Content node" );
     return this;
   }
 
-  UnicodeString Correction::text( const string& cls ) const {
+  UnicodeString Correction::text( const string& cls, bool retaintok ) const {
     if ( cls == "current" ){
       for( size_t i=0; i < data.size(); ++i ){
 	//    cerr << "data[" << i << "]=" << data[i] << endl;
 	if ( data[i]->isinstance( New_t ) || data[i]->isinstance( Current_t ) )
-	  return data[i]->text( cls );
+	  return data[i]->text( cls, retaintok );
       }
     }
     else if ( cls == "original" ){
       for( size_t i=0; i < data.size(); ++i ){
 	//    cerr << "data[" << i << "]=" << data[i] << endl;
 	if ( data[i]->isinstance( Original_t ) )
-	  return data[i]->text( cls );
+	  return data[i]->text( cls, retaintok );
       }
     }
     throw NoSuchText("wrong cls");
@@ -1933,8 +2272,8 @@ namespace folia {
     }
   }
 
-  DependencyHead *Dependency::head() const {
-    vector<DependencyHead*> v = select<DependencyHead>();
+  Headwords *Dependency::head() const {
+    vector<Headwords*> v = select<Headwords>();
     if ( v.size() < 1 )
       throw NoSuchAnnotation( "head" );
     else {
@@ -1955,41 +2294,61 @@ namespace folia {
     _xmltag="FoLiA";
     _element_id = BASE;
     const ElementType accept[] = { Text_t };
-    _accepted_data = set<ElementType>(accept, accept+1); 
+    _accepted_data = std::set<ElementType>(accept, accept + 1 );
   }
 
   void DCOI::init(){
     _xmltag="DCOI";
     _element_id = BASE;
     const ElementType accept[] = { Text_t };
-    _accepted_data = set<ElementType>(accept, accept+1); 
+    _accepted_data = std::set<ElementType>(accept, accept + 1 );
+  }
+
+  void AbstractStructureElement::init(){
+    _required_attributes = ID;
+    _optional_attributes = ALL;
+    occurrences_per_set=0;
+    TEXTDELIMITER = "\n\n";
+  }
+
+  void AbstractTokenAnnotation::init(){
+    _required_attributes = CLASS;
+    _optional_attributes = ALL;
+    occurrences_per_set=1;
   }
 
   void TextContent::init(){
     _element_id = TextContent_t;
     _xmltag="t";
-    _optional_attributes = CLASS|ANNOTATOR|CONFIDENCE;
-    _annotation_type =  AnnotationType::TEXT;
+    _optional_attributes = CLASS|ANNOTATOR|CONFIDENCE|DATETIME;
+    _annotation_type = AnnotationType::TEXT;
+    occurrences = 0;
+    occurrences_per_set=0;
     _offset = -1;
   }
 
   void Head::init() {
     _element_id = Head_t;
     _xmltag="head";
-    const ElementType accept[] = { Sentence_t, Description_t, TextContent_t };
-    _accepted_data = set<ElementType>(accept, accept+3); 
-    _annotation_type = AnnotationType::TOKEN;
+    const ElementType accept[] = { Sentence_t, Description_t, Event_t, 
+				   TextContent_t, Alignment_t };
+    _accepted_data = std::set<ElementType>(accept, accept + 5 );
+    occurrences=1;
     TEXTDELIMITER = " ";
   }
 
   void LineBreak::init(){
     _xmltag = "br";
     _element_id = LineBreak_t;
+    _required_attributes = NO_ATT;
+    _annotation_type = AnnotationType::LINEBREAK;
   }
 
   void WhiteSpace::init(){
     _xmltag = "whitespace";
     _element_id = WhiteSpace_t;
+    _required_attributes = NO_ATT;
+    _annotation_type = AnnotationType::WHITESPACE;
   }
 
   void Word::init(){
@@ -1997,16 +2356,34 @@ namespace folia {
     _element_id = Word_t;
     const ElementType accept[] = { TextContent_t, Pos_t, Lemma_t,
 				   Sense_t, Alternative_t, 
-				   Correction_t, ErrorDetection_t, Description_t,
-				   Morphology_t };
-    _accepted_data = set<ElementType>(accept, accept+9);
+				   Correction_t, ErrorDetection_t, 
+				   Description_t, Morphology_t,
+				   Alignment_t, Metric_t };
+    _accepted_data = std::set<ElementType>(accept, accept + 11 );
     _annotation_type = AnnotationType::TOKEN;
-    _required_attributes = ID;
-    _optional_attributes = CLASS|ANNOTATOR|CONFIDENCE;
     TEXTDELIMITER = " ";
     space = true;
   }
 
+  void String::init(){
+    _xmltag="str";
+    _element_id = Str_t;
+    _required_attributes = NO_ATT;
+    _optional_attributes = ID|CLASS;
+    const ElementType accept[] = { TextContent_t, Correction_t,
+				   Description_t, Alignment_t, Metric_t };
+    _accepted_data = std::set<ElementType>(accept, accept + 5 );
+    _annotation_type = AnnotationType::STRING;
+    occurrences = 0;
+    occurrences_per_set=0;
+  }
+
+  void PlaceHolder::init(){
+    _xmltag="placeholder";
+    _element_id = PlaceHolder_t;
+    _required_attributes = NO_ATT;
+  }
+
   void WordReference::init(){
     _required_attributes = ID;
     _xmltag = "wref";
@@ -2014,14 +2391,20 @@ namespace folia {
     _auth = false;
   }
 
-  void PlaceHolder::init(){
-    _xmltag="placeholder";
-    _element_id = PlaceHolder_t;
-    const ElementType accept[] = { TextContent_t };
-    _accepted_data = set<ElementType>(accept, accept+1);
-    _annotation_type = AnnotationType::TOKEN;
-    _required_attributes = NO_ATT;
-    TEXTDELIMITER = " ";
+  void Alignment::init(){
+    _optional_attributes = ALL;
+    _xmltag = "alignment";
+    _element_id = Alignment_t;
+    const ElementType accept[] = { AlignReference_t, Description_t };
+    _accepted_data = std::set<ElementType>(accept, accept + 2 );
+    occurrences_per_set=0;
+    _annotation_type = AnnotationType::ALIGNMENT;
+    PRINTABLE = false;
+  }
+
+  void AlignReference::init(){
+    _xmltag = "aref";
+    _element_id = AlignReference_t;
   }
 
 
@@ -2030,8 +2413,17 @@ namespace folia {
     _element_id = Gap_t;
     _annotation_type = AnnotationType::GAP;
     const ElementType accept[] = { Content_t, Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept+2); 
-    _optional_attributes = CLASS|ID|ANNOTATOR|CONFIDENCE|N;
+    _accepted_data = std::set<ElementType>(accept, accept + 2 );
+    _optional_attributes = CLASS|ID|ANNOTATOR|CONFIDENCE|N|DATETIME;
+  }
+
+  void MetricAnnotation::init(){
+    _element_id = Metric_t;
+    _xmltag = "metric";
+    const ElementType accept[] = { ValueFeature_t, Description_t };
+    _accepted_data = std::set<ElementType>(accept, accept + 2 );
+    _optional_attributes = CLASS|ANNOTATOR|CONFIDENCE;
+    _annotation_type = AnnotationType::METRIC;
   }
 
   void Content::init(){
@@ -2043,35 +2435,40 @@ namespace folia {
     _xmltag="s";
     _element_id = Sentence_t;
     const ElementType accept[] = { LineBreak_t, WhiteSpace_t, Word_t, 
-				   TextContent_t, Annolay_t, 
+				   Str_t,
+				   TextContent_t, AnnotationLayer_t, 
 				   SyntaxLayer_t, Chunking_t, Dependencies_t,
-				   Entities_t,
-				   Quote_t, Event_t,
+				   Entities_t, Semroles_t,
+				   Quote_t, Event_t, TimingLayer_t,
 				   Correction_t,
-				   Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept+13); 
-    _required_attributes = ID;
-    _optional_attributes = N;
+				   Description_t, Alignment_t, Metric_t };
+    _accepted_data = std::set<ElementType>(accept, accept + 18 );
+    _annotation_type = AnnotationType::SENTENCE;
   }
 
   void Division::init(){
     _xmltag="div";
     _element_id = Division_t;
-    _optional_attributes = CLASS;
+    _required_attributes = ID;
+    _optional_attributes = CLASS|N;
     const ElementType accept[] = { Division_t, Gap_t, Head_t, Paragraph_t,
 				   Sentence_t, List_t, Figure_t, Event_t,
-				   Description_t, LineBreak_t, TextContent_t,
-				   WhiteSpace_t };
-    _accepted_data = std::set<ElementType>(accept, accept+12); 
+				   Description_t, LineBreak_t, Str_t,
+				   TextContent_t,
+				   WhiteSpace_t, Metric_t, Coreferences_t };
+    _accepted_data = std::set<ElementType>(accept, accept + 15 );
     _annotation_type = AnnotationType::DIVISION;
+    TEXTDELIMITER = "\n\n\n";
   }
 
   void Text::init(){
     _xmltag="text";
     _element_id = Text_t;
     const ElementType accept[] = { Gap_t, Division_t, Paragraph_t, Sentence_t, 
-				   List_t, Figure_t, Description_t, Event_t };
-    _accepted_data = std::set<ElementType>(accept, accept+8); 
+				   List_t, Figure_t, Description_t, Event_t,
+				   Str_t,
+				   TextContent_t, Metric_t };
+    _accepted_data = std::set<ElementType>(accept, accept + 11 );
     _required_attributes = ID;
     TEXTDELIMITER = "\n\n";
   }
@@ -2080,59 +2477,59 @@ namespace folia {
     _xmltag="event";
     _element_id = Event_t;
     const ElementType accept[] = { Gap_t, Division_t, Paragraph_t, Sentence_t, 
-				   List_t, Figure_t, Description_t, 
+				   List_t, Figure_t, Description_t, Str_t,
 				   ActorFeature_t, TextContent_t, Feature_t,
-				   BegindatetimeFeature_t, EnddatetimeFeature_t };
-    _accepted_data = std::set<ElementType>(accept, accept+12); 
-    _required_attributes = CLASS;
-    _optional_attributes = ID|ANNOTATOR|N|DATETIME;
+				   BeginDateTimeFeature_t, EndDateTimeFeature_t };
+    _accepted_data = std::set<ElementType>(accept, accept + 13 );
     _annotation_type = AnnotationType::EVENT;
-    TEXTDELIMITER = "\n\n";
+    occurrences_per_set=0;
   }
 
-  void TimedEvent::init(){
-    _xmltag="timedevent";
-    _element_id = TimedEvent_t;
-    const ElementType accept[] = { Description_t, Feature_t };
-    _accepted_data = std::set<ElementType>(accept, accept+2); 
-    _required_attributes = CLASS;
-    _optional_attributes = ID|ANNOTATOR|CONFIDENCE|DATETIME;
+  void TimeSegment::init(){
+    _xmltag="timesegment";
+    _element_id = TimeSegment_t;
+    const ElementType accept[] = { Description_t, Feature_t, ActorFeature_t,
+				   Word_t,
+				   BeginDateTimeFeature_t, EndDateTimeFeature_t };
+    _accepted_data = std::set<ElementType>(accept, accept + 6 );
     _annotation_type = AnnotationType::TIMEDEVENT;
+    occurrences_per_set=0;
   }
 
   void Caption::init(){
     _xmltag="caption";
     _element_id = Caption_t;
-    const ElementType accept[] = { Sentence_t, Description_t, TextContent_t };
-    _accepted_data = std::set<ElementType>(accept, accept+3);
-    _optional_attributes = ID;
+    const ElementType accept[] = { Sentence_t, Description_t, 
+				   Str_t, TextContent_t };
+    _accepted_data = std::set<ElementType>(accept, accept + 4 );
+    occurrences = 1;
   }
 
   void Label::init(){
     _xmltag="label";
     _element_id = Label_t;
-    const ElementType accept[] = { Word_t, Description_t, TextContent_t };
-    _accepted_data = std::set<ElementType>(accept, accept+3);
-    _optional_attributes = ID;
+    const ElementType accept[] = { Word_t, Description_t, TextContent_t,
+				   Str_t, Alignment_t };
+    _accepted_data = std::set<ElementType>(accept, accept + 5 );
   }
 
   void ListItem::init(){
     _xmltag="listitem";
     _element_id = ListItem_t;
     const ElementType accept[] = { List_t, Sentence_t, Description_t, Label_t,
-				   Event_t, TextContent_t };
-    _accepted_data = std::set<ElementType>(accept, accept+6);
-    _optional_attributes = ID|N;
+				   Event_t, Str_t, TextContent_t, Alignment_t };
+    _accepted_data = std::set<ElementType>(accept, accept + 8 );
+    _annotation_type = AnnotationType::LIST;
   }
 
   void List::init(){
     _xmltag="list";
     _element_id = List_t;
     const ElementType accept[] = { ListItem_t, Description_t, 
-				   Caption_t, Event_t,
-				   TextContent_t };
-    _accepted_data = std::set<ElementType>(accept, accept+5);
-    _optional_attributes = ID|N;
+				   Caption_t, Event_t, Str_t,
+				   TextContent_t, Alignment_t };
+    _accepted_data = std::set<ElementType>(accept, accept + 7 );
+    _annotation_type = AnnotationType::LIST;
     TEXTDELIMITER="\n";
   }
 
@@ -2140,39 +2537,50 @@ namespace folia {
     _xmltag="figure";
     _element_id = Figure_t;
     const ElementType accept[] = { Sentence_t, Description_t, 
-				   Caption_t, TextContent_t };
-    _accepted_data = std::set<ElementType>(accept, accept+4);
-    _optional_attributes = ID|N;
+				   Caption_t, Str_t, TextContent_t };
+    _accepted_data = std::set<ElementType>(accept, accept + 5 );
+    _annotation_type = AnnotationType::FIGURE;
   }
 
   void Paragraph::init(){
     _xmltag="p";
     _element_id = Paragraph_t;
-    const ElementType accept[] = { Sentence_t, Correction_t, TextContent_t, Description_t, LineBreak_t, WhiteSpace_t, List_t, Figure_t };
-    _accepted_data = std::set<ElementType>(accept, accept+8);
-    _required_attributes = ID;
+    const ElementType accept[] = { Sentence_t, Correction_t, TextContent_t, 
+				   Str_t,
+				   Description_t, LineBreak_t, WhiteSpace_t, 
+				   List_t, Figure_t, Alignment_t, Metric_t };
+    _accepted_data = std::set<ElementType>(accept, accept + 11 );
+    _annotation_type = AnnotationType::PARAGRAPH;
   }
 
   void SyntacticUnit::init(){
-    _required_attributes = CLASS;
-    _optional_attributes = ID|ANNOTATOR|CONFIDENCE|DATETIME;
     _xmltag = "su";
     _element_id = SyntacticUnit_t;
+    _required_attributes = NO_ATT;
     _annotation_type = AnnotationType::SYNTAX;
     const ElementType accept[] = { SyntacticUnit_t, Word_t, WordReference_t,
 				   Description_t, Feature_t };
-    _accepted_data = std::set<ElementType>(accept, accept+5);
+    _accepted_data = std::set<ElementType>(accept, accept + 5 );
+  }
+
+  void SemanticRole::init(){
+    _xmltag = "semrole";
+    _element_id = Semrole_t;
+    _required_attributes = CLASS;
+    _annotation_type = AnnotationType::SEMROLE;
+    const ElementType accept[] = { Word_t, WordReference_t, Headwords_t,
+				   Alignment_t, Description_t, Metric_t };
+    _accepted_data = std::set<ElementType>(accept, accept + 6 );
   }
 
   void Chunk::init(){
     _required_attributes = NO_ATT;
-    _optional_attributes = ID|CLASS|ANNOTATOR|CONFIDENCE|DATETIME;
     _xmltag = "chunk";
     _element_id = Chunk_t;
     _annotation_type = AnnotationType::CHUNKING;
     const ElementType accept[] = { Word_t, WordReference_t, 
 				   Description_t, Feature_t };
-    _accepted_data = std::set<ElementType>(accept, accept+4);
+    _accepted_data = std::set<ElementType>(accept, accept + 4 );
   }
 
   void Entity::init(){
@@ -2181,93 +2589,94 @@ namespace folia {
     _xmltag = "entity";
     _element_id = Entity_t;
     _annotation_type = AnnotationType::ENTITY;
-    const ElementType accept[] = { Word_t, WordReference_t, 
-				   Description_t, Feature_t };
-    _accepted_data = std::set<ElementType>(accept, accept+4);
+    const ElementType accept[] = { Word_t, WordReference_t, Morpheme_t,
+				   Description_t, Feature_t, Metric_t };
+    _accepted_data = std::set<ElementType>(accept, accept + 6 );
   }
 
   void AbstractAnnotationLayer::init(){
-    _optional_attributes = CLASS;
-    _element_id = Annolay_t;
+    _xmltag = "annotationlayer";
+    _element_id = AnnotationLayer_t;
+    _optional_attributes = SETONLY;
     PRINTABLE=false;
   }
 
   void Alternative::init(){
-    _required_attributes = ID;
     _xmltag = "alt";
     _element_id = Alternative_t;
-    const ElementType accept[] = { Pos_t, Lemma_t, Correction_t };
-    _accepted_data = std::set<ElementType>(accept, accept+3);
+    _required_attributes = NO_ATT;
+    _optional_attributes = ALL;
+    const ElementType accept[] = { Pos_t, Lemma_t, Morphology_t, Correction_t };
+    _accepted_data = std::set<ElementType>(accept, accept + 4 );
     _annotation_type = AnnotationType::ALTERNATIVE;
     PRINTABLE = false;
     AUTH = false;
   }
 
+  void AlternativeLayers::init(){
+    _xmltag = "altlayers";
+    _element_id = Alternatives_t;
+    _optional_attributes = ALL;
+    const ElementType accept[] = { AnnotationLayer_t };
+    _accepted_data = std::set<ElementType>(accept, accept + 1 );
+    PRINTABLE = false;
+    AUTH = false;
+  }
+
+  void AbstractCorrectionChild::init(){
+    _optional_attributes = NO_ATT;
+    const ElementType accept[] = { Pos_t, Lemma_t,
+				   Phon_t, Domain_t,
+				   Sense_t, Subjectivity_t,
+				   Correction_t, ErrorDetection_t,
+				   Word_t, WordReference_t, Str_t,
+				   TextContent_t, Description_t };
+    _accepted_data = std::set<ElementType>(accept, accept + 13 );
+    occurrences = 1;
+    PRINTABLE=true;
+  }
+  
   void NewElement::init(){
     _xmltag = "new";
     _element_id = New_t;
-    const ElementType accept[] = { Pos_t, Lemma_t, Word_t, TextContent_t };
-    _accepted_data = std::set<ElementType>(accept, accept+4);
   }
 
   void Current::init(){
     _xmltag = "current";
     _element_id = Current_t;
-    const ElementType accept[] = { Pos_t, Lemma_t, Word_t, TextContent_t };
-    _accepted_data = std::set<ElementType>(accept, accept+4);
   }
 
   void Original::init(){
     _xmltag = "original";
     _element_id = Original_t;
-    const ElementType accept[] = { Pos_t, Lemma_t, Word_t, TextContent_t,
-				   Correction_t, Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept+6);
     AUTH = false;
   }
 
   void Suggestion::init(){
     _xmltag = "suggestion";
     _element_id = Suggestion_t;
-    const ElementType accept[] = { Pos_t, Lemma_t, TextContent_t, Word_t };
-    _accepted_data = std::set<ElementType>(accept, accept+4);
-    _optional_attributes = ANNOTATOR|CONFIDENCE|DATETIME;
+    _optional_attributes = ANNOTATOR|CONFIDENCE|DATETIME|N;
+    _annotation_type = AnnotationType::SUGGESTION;    
+    occurrences=0;
+    occurrences_per_set=0;
     AUTH = false;
   }
 
   void Correction::init(){
     _xmltag = "correction";
     _element_id = Correction_t;
-    _required_attributes = ID;
-    _optional_attributes = CLASS|ANNOTATOR|CONFIDENCE|DATETIME;
+    _required_attributes = NO_ATT;
     _annotation_type = AnnotationType::CORRECTION;
     const ElementType accept[] = { New_t, Original_t, Suggestion_t, Current_t,
 				   Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept+5);
+    _accepted_data = std::set<ElementType>(accept, accept + 5 );
+    occurrences_per_set=0;
   }
 
   void Description::init(){
     _xmltag = "desc";
     _element_id = Description_t;
-  }
-
-  void ErrorDetection::setAttributes( const KWargs& kwargs ){
-    KWargs::const_iterator it = kwargs.find( "error" );
-    if ( it != kwargs.end() ) {
-      string tmp = lowercase( it->second );
-      if ( tmp == "no" || tmp == "false" )
-	error = false;
-      else
-	error = true;
-    }
-    FoliaElement::setAttributes(kwargs);
-  }
-
-  KWargs ErrorDetection::collectAttributes() const {
-    KWargs attribs = FoliaElement::collectAttributes();
-    if ( error )
-      attribs["error"] = "yes";
-    return attribs;
+    occurrences = 1;
   }
 
   void Feature::setAttributes( const KWargs& kwargs ){
@@ -2298,101 +2707,147 @@ namespace folia {
     return attribs;
   }
 
-  std::string FoliaElement::feat( const std::string& s ) const {
+  vector<string> FoliaElement::feats( const std::string& s ) const {
+    //    return all classes of the given subset
+    vector<string> result;
+    for ( size_t i=0; i < data.size(); ++i ){
+      if ( ( data[i]->isinstance( Feature_t ) ||
+	     data[i]->isinstance( SynsetFeature_t ) ||
+	     data[i]->isinstance( BeginDateTimeFeature_t ) ||
+	     data[i]->isinstance( EndDateTimeFeature_t ) ||
+	     data[i]->isinstance( HeadFeature_t ) ||
+	     data[i]->isinstance( ValueFeature_t ) ||
+	     data[i]->isinstance( ActorFeature_t ) ) &&
+	   data[i]->subset() == s )
+	result.push_back( data[i]->cls() );
+    }
+    return result;
+  }
+  
+  string FoliaElement::feat( const std::string& s ) const {
+    //    return the fist class of the given subset
     for ( size_t i=0; i < data.size(); ++i ){
       if ( ( data[i]->isinstance( Feature_t ) ||
 	     data[i]->isinstance( SynsetFeature_t ) ||
-	     data[i]->isinstance( BegindatetimeFeature_t ) ||
-	     data[i]->isinstance( EnddatetimeFeature_t ) ||
+	     data[i]->isinstance( BeginDateTimeFeature_t ) ||
+	     data[i]->isinstance( EndDateTimeFeature_t ) ||
 	     data[i]->isinstance( HeadFeature_t ) ||
+	     data[i]->isinstance( ValueFeature_t ) ||
 	     data[i]->isinstance( ActorFeature_t ) ) &&
 	   data[i]->subset() == s )
 	return data[i]->cls();
     }
     return "";
   }
-
-  void AbstractSubtokenAnnotationLayer::init(){
-
-  }
-
+  
   void Morpheme::init(){
     _element_id = Morpheme_t;
     _xmltag = "morpheme";
     _required_attributes = NO_ATT;
-    _optional_attributes = ID|CLASS|ANNOTATOR|CONFIDENCE|DATETIME;
-    const ElementType accept[] = { Feature_t, TextContent_t };
-    _accepted_data = std::set<ElementType>(accept, accept+2);
+    _optional_attributes = ALL;
+    const ElementType accept[] = { Feature_t, FunctionFeature_t, TextContent_t,
+				   Str_t, Metric_t, Alignment_t, 
+				   Pos_t, Lemma_t, Sense_t, Subjectivity_t,
+				   Description_t };
+    _accepted_data = std::set<ElementType>(accept, accept + 11 );
     _annotation_type = AnnotationType::MORPHOLOGICAL;
   }
 
-  void Subentity::init(){
-    _element_id = Subentity_t;
-    _xmltag = "subentity";
-    _required_attributes = CLASS;
-    _optional_attributes = ID|ANNOTATOR|CONFIDENCE|DATETIME;
-    const ElementType accept[] = { Feature_t, TextContent_t };
-    _accepted_data = std::set<ElementType>(accept, accept+2);
-    _annotation_type = AnnotationType::SUBENTITY;
-  }
-
   void SyntaxLayer::init(){
     _element_id = SyntaxLayer_t;
     _xmltag = "syntax";
     const ElementType accept[] = { SyntacticUnit_t, Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept+2);
+    _accepted_data = std::set<ElementType>(accept, accept + 2 );
+    _annotation_type = AnnotationType::SYNTAX;
   }
 
   void ChunkingLayer::init(){
     _element_id = Chunking_t;
     _xmltag = "chunking";
     const ElementType accept[] = { Chunk_t, Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept+2);
+    _accepted_data = std::set<ElementType>(accept, accept + 2 );
+    _annotation_type = AnnotationType::CHUNKING;
   }
 
   void EntitiesLayer::init(){
     _element_id = Entities_t;
     _xmltag = "entities";
     const ElementType accept[] = { Entity_t, Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept+2);
+    _accepted_data = std::set<ElementType>(accept, accept + 2 );
+    _annotation_type = AnnotationType::ENTITY;
   }
 
   void TimingLayer::init(){
-    _element_id = Timings_t;
+    _element_id = TimingLayer_t;
     _xmltag = "timing";
-    const ElementType accept[] = { TimedEvent_t, Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept+2);
+    const ElementType accept[] = { TimeSegment_t, Description_t };
+    _accepted_data = std::set<ElementType>(accept, accept + 2 );
   }
 
   void MorphologyLayer::init(){
     _element_id = Morphology_t;
     _xmltag = "morphology";
     const ElementType accept[] = { Morpheme_t };
-    _accepted_data = std::set<ElementType>(accept, accept+1);
+    _accepted_data = std::set<ElementType>(accept, accept + 1 );
+    occurrences_per_set = 1; // Don't allow duplicates within the same set    
+    _annotation_type = AnnotationType::MORPHOLOGICAL;
   }
 
-  void SubentitiesLayer::init(){
-    _element_id = Subentities_t;
-    _xmltag = "subentities";
-    const ElementType accept[] = { Subentity_t };
-    _accepted_data = std::set<ElementType>(accept, accept+1);
+  void CoreferenceLayer::init(){
+    _element_id = Coreferences_t;
+    _xmltag = "coreferences";
+    const ElementType accept[] = { CoreferenceChain_t, Description_t };
+    _accepted_data = std::set<ElementType>(accept, accept + 2 );
+    _annotation_type = AnnotationType::COREFERENCE;
+  }
+
+  void CoreferenceLink::init(){
+    _element_id = CoreferenceLink_t;
+    _xmltag = "coreferencelink";
+    _required_attributes = NO_ATT;
+    _optional_attributes = ANNOTATOR|N|DATETIME;
+    const ElementType accept[] = { Word_t, WordReference_t, Headwords_t, 
+				   Description_t,
+				   Alignment_t, TimeFeature_t, LevelFeature_t,
+				   ModalityFeature_t, Metric_t};
+    _accepted_data = std::set<ElementType>(accept, accept + 9 );
+    _annotation_type = AnnotationType::COREFERENCE;    
+  }
+
+  void CoreferenceChain::init(){
+    _element_id = CoreferenceChain_t;
+    _xmltag = "coreferencechain";
+    _required_attributes = NO_ATT;
+    const ElementType accept[] = { CoreferenceLink_t, Description_t,
+				   Metric_t };
+    _accepted_data = std::set<ElementType>(accept, accept + 3 );
+    _annotation_type = AnnotationType::COREFERENCE;    
+  }
+
+  void SemanticRolesLayer::init(){
+    _element_id = Semroles_t;
+    _xmltag = "semroles";
+    const ElementType accept[] = { Semrole_t, Description_t };
+    _accepted_data = std::set<ElementType>(accept, accept + 2 );
+    _annotation_type = AnnotationType::SEMROLE;
   }
 
   void DependenciesLayer::init(){
     _element_id = Dependencies_t;
     _xmltag = "dependencies";
     const ElementType accept[] = { Dependency_t, Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept+2);
+    _accepted_data = std::set<ElementType>(accept, accept + 2 );
+    _annotation_type = AnnotationType::DEPENDENCY;
   }
 
   void Dependency::init(){
     _element_id = Dependency_t;
     _xmltag = "dependency";
-    _required_attributes = CLASS;
-    _optional_attributes = ID|ANNOTATOR|DATETIME|CONFIDENCE;
+    _required_attributes = NO_ATT;
     _annotation_type = AnnotationType::DEPENDENCY;
-    const ElementType accept[] = { DependencyDependent_t, DependencyHead_t, Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept+3);
+    const ElementType accept[] = { DependencyDependent_t, Headwords_t, 
+				   Feature_t, Description_t, Alignment_t };
+    _accepted_data = std::set<ElementType>(accept, accept + 5 );
   }
 
   void DependencyDependent::init(){
@@ -2401,100 +2856,95 @@ namespace folia {
     _required_attributes = NO_ATT;
     _optional_attributes = NO_ATT;
     _annotation_type = AnnotationType::DEPENDENCY;
-    const ElementType accept[] = { Word_t, WordReference_t, Description_t, Feature_t };
-    _accepted_data = std::set<ElementType>(accept, accept+4);
+    const ElementType accept[] = { Word_t, WordReference_t, PlaceHolder_t,
+				   Description_t, Feature_t, Alignment_t };
+    _accepted_data = std::set<ElementType>(accept, accept + 6 );
   }
 
-  void DependencyHead::init(){
-    _element_id = DependencyHead_t;
+  void Headwords::init(){
+    _element_id = Headwords_t;
     _xmltag = "hd";
     _required_attributes = NO_ATT;
     _optional_attributes = NO_ATT;
-    _annotation_type = AnnotationType::DEPENDENCY;
-    const ElementType accept[] = { Word_t, WordReference_t, Description_t, Feature_t };
-    _accepted_data = std::set<ElementType>(accept, accept+4);
+    const ElementType accept[] = { Word_t, WordReference_t, PlaceHolder_t,
+				   Description_t, Feature_t, Metric_t,
+				   Alignment_t };
+    _accepted_data = std::set<ElementType>(accept, accept + 7 );
   }
 
   void PosAnnotation::init(){
     _xmltag="pos";
     _element_id = Pos_t;
     _annotation_type = AnnotationType::POS;
-    _required_attributes = CLASS;
-    _optional_attributes = ANNOTATOR|CONFIDENCE|DATETIME;
     const ElementType accept[] = { Feature_t, HeadFeature_t, Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept+3);
+    _accepted_data = std::set<ElementType>(accept, accept + 3 );
   }
 
   void LemmaAnnotation::init(){
     _xmltag="lemma";
     _element_id = Lemma_t;
     _annotation_type = AnnotationType::LEMMA;
-    _required_attributes = CLASS;
-    _optional_attributes = ANNOTATOR|CONFIDENCE|DATETIME;
     const ElementType accept[] = { Feature_t, Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept+2);
+    _accepted_data = std::set<ElementType>(accept, accept + 2 );
   }
 
   void PhonAnnotation::init(){
     _xmltag="phon";
     _element_id = Phon_t;
     _annotation_type = AnnotationType::PHON;
-    _required_attributes = CLASS;
-    _optional_attributes = ANNOTATOR|CONFIDENCE|DATETIME;
     const ElementType accept[] = { Feature_t, Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept+2);
+    _accepted_data = std::set<ElementType>(accept, accept + 2 );
   }
 
   void DomainAnnotation::init(){
     _xmltag="domain";
     _element_id = Domain_t;
     _annotation_type = AnnotationType::DOMEIN;
-    _required_attributes = CLASS;
-    _optional_attributes = ANNOTATOR|CONFIDENCE|DATETIME;
     const ElementType accept[] = { Feature_t, Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept+2);
+    _accepted_data = std::set<ElementType>(accept, accept + 2 );
   }
 
   void SenseAnnotation::init(){
     _xmltag="sense";
     _element_id = Sense_t;
     _annotation_type = AnnotationType::SENSE;
-    _required_attributes = CLASS;
-    _optional_attributes = ANNOTATOR|CONFIDENCE|DATETIME;
     const ElementType accept[] = { Feature_t, SynsetFeature_t, Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept+3);
+    _accepted_data = std::set<ElementType>(accept, accept + 3 );
   }
 
   void SubjectivityAnnotation::init(){
     _xmltag="subjectivity";
     _element_id = Subjectivity_t;
     _annotation_type = AnnotationType::SUBJECTIVITY;
-    _required_attributes = CLASS;
-    _optional_attributes = ANNOTATOR|CONFIDENCE|DATETIME;
     const ElementType accept[] = { Feature_t, Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept+2);
+    _accepted_data = std::set<ElementType>(accept, accept + 2 );
   }
 
   void Quote::init(){
     _xmltag="quote";
     _element_id = Quote_t;
     _required_attributes = NO_ATT;
-    _optional_attributes = ID;
-    const ElementType accept[] = { Word_t, Sentence_t, Quote_t, 
-				   TextContent_t, Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept+5);
+    const ElementType accept[] = { Word_t, Sentence_t, Quote_t, Str_t,
+				   TextContent_t, Description_t, Alignment_t };
+    _accepted_data = std::set<ElementType>(accept, accept + 7 );
+    TEXTDELIMITER = " ";
   }
 
+  void Feature::init() {
+    _xmltag = "feat";
+    _element_id = Feature_t;
+    occurrences_per_set = 0; // Allow duplicates within the same set
+  }
 
-  void BegindatetimeFeature::init(){
+  void BeginDateTimeFeature::init(){
     _xmltag="begindatetime";
-    _element_id = BegindatetimeFeature_t;
+    _element_id = BeginDateTimeFeature_t;
     _subset = "begindatetime";
   }
 
-  void EnddatetimeFeature::init(){
+  void EndDateTimeFeature::init(){
     _xmltag="enddatetime";
-    _element_id = EnddatetimeFeature_t;
+    _element_id = EndDateTimeFeature_t;
     _subset = "enddatetime";
   }
 
@@ -2512,28 +2962,58 @@ namespace folia {
   }
 
   void HeadFeature::init(){
-    _xmltag = "headfeat";
+    _xmltag = "headfeature";
     _element_id = HeadFeature_t;
     _subset = "head";
   }
 
+  void ValueFeature::init(){
+    _xmltag = "value";
+    _element_id = ValueFeature_t;
+    _subset = "value";
+  }
+
+  void FunctionFeature::init(){
+    _xmltag = "function";
+    _element_id = FunctionFeature_t;
+    _subset = "function";
+  }
+
+  void LevelFeature::init(){
+    _xmltag = "level";
+    _element_id = LevelFeature_t;
+    _subset = "level";
+  }
+
+  void ModalityFeature::init(){
+    _xmltag = "modality";
+    _element_id = ModalityFeature_t;
+    _subset = "modality";
+  }
+
+  void TimeFeature::init(){
+    _xmltag = "time";
+    _element_id = TimeFeature_t;
+    _subset = "time";
+  }
+
   void AbstractSubtokenAnnotation::init() {
-    occurrences_per_set = 0; // Allow duplicates within the same set
+    _required_attributes = NO_ATT;
+    _optional_attributes = ALL;
+    occurrences_per_set = 0; // Allow duplicates within the same set    
   }
 
-  void Feature::init() {
-    _xmltag = "feat";
-    _element_id = Feature_t;
-    _required_attributes = CLASS;
+  void AbstractSpanAnnotation::init() {
+    _required_attributes = NO_ATT;
+    _optional_attributes = ALL;
     occurrences_per_set = 0; // Allow duplicates within the same set
   }
 
   void ErrorDetection::init(){
     _xmltag = "errordetection";
     _element_id = ErrorDetection_t;
-    _optional_attributes = CLASS|ANNOTATOR|CONFIDENCE|DATETIME;
     _annotation_type = AnnotationType::ERRORDETECTION;
-    error = true;
+    occurrences_per_set = 0; // Allow duplicates within the same set
   }
 
 } // namespace folia
diff --git a/src/folialint.cxx b/src/folialint.cxx
new file mode 100644
index 0000000..ea3b410
--- /dev/null
+++ b/src/folialint.cxx
@@ -0,0 +1,64 @@
+/*
+  $Id: folialint.cxx 15909 2013-04-03 13:52:24Z sloot $
+  $URL: https://ilk.uvt.nl/svn/sources/libfolia/trunk/src/folialint.cxx $
+
+  Copyright (c) 1998 - 2013
+  ILK   - Tilburg University
+  CLiPS - University of Antwerp
+ 
+  This file is part of libfolia
+
+  libfolia is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 3 of the License, or
+  (at your option) any later version.
+
+  libfolia is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+  For questions and suggestions, see:
+      http://ilk.uvt.nl/software.html
+  or send mail to:
+      timbl at uvt.nl
+*/
+
+#include <iostream>
+#include <fstream>
+#include <string>
+#include <map>
+#include "libfolia/document.h"
+
+using namespace std;
+
+void usage(){
+  cerr << "usage: folialint <foliafile> [<outputfile>]" << endl;
+}
+
+int main( int argc, char* argv[] ){
+  string outName;
+  if ( argc < 2 ){
+    usage();
+    exit( EXIT_FAILURE);
+  }
+  if ( argc == 3 ){
+    outName == argv[2];
+  }
+  try {
+    folia::Document d;
+    d.readFromFile( argv[1] );
+    if ( !outName.empty() )
+      d.save( outName );
+    else
+      cout << d;
+  }
+  catch( exception& e ){
+    cerr << "FAIL: " << e.what() << endl;
+    exit( EXIT_FAILURE );
+  }
+  exit( EXIT_SUCCESS );
+}
diff --git a/src/foliautils.cxx b/src/foliautils.cxx
index 3a71a96..e06f5b0 100644
--- a/src/foliautils.cxx
+++ b/src/foliautils.cxx
@@ -1,8 +1,8 @@
 /*
-  $Id: foliautils.cxx 14316 2012-02-23 10:04:11Z sloot $
+  $Id: foliautils.cxx 15909 2013-04-03 13:52:24Z sloot $
   $URL: https://ilk.uvt.nl/svn/sources/libfolia/trunk/src/foliautils.cxx $
 
-  Copyright (c) 1998 - 2012
+  Copyright (c) 1998 - 2013
   ILK   - Tilburg University
   CLiPS - University of Antwerp
  
@@ -36,10 +36,12 @@
 #include <list>
 #include <stdexcept>
 #include <algorithm> 
-#include "folia/document.h"
-#include "folia/folia.h"
+#include "ticcutils/StringOps.h"
+#include "ticcutils/XMLtools.h"
+#include "libfolia/document.h"
 
 using namespace std;
+using namespace TiCC;
 
 namespace folia {
 
@@ -76,24 +78,39 @@ namespace folia {
     case AnnotationType::TEXT:
       result = "text";
       break; 
+    case AnnotationType::STRING:
+      result = "string";
+      break; 
     case AnnotationType::TOKEN:
       result = "token";
       break; 
-    case AnnotationType::GAP:
-      result = "gap";
-      break; 
     case AnnotationType::DIVISION:
       result = "div";
       break; 
+    case AnnotationType::PARAGRAPH: 
+      result = "paragraph";
+      break; 
+    case AnnotationType::LIST: 
+      result = "list";
+      break; 
+    case AnnotationType::FIGURE: 
+      result = "figure";
+      break; 
+    case AnnotationType::WHITESPACE: 
+      result = "whitespace";
+      break; 
+    case AnnotationType::LINEBREAK: 
+      result = "linebreak";
+      break; 
+    case AnnotationType::SENTENCE: 
+      result = "sentence";
+      break; 
     case AnnotationType::POS: 
       result = "pos";
       break; 
     case AnnotationType::LEMMA:
       result = "lemma";
       break; 
-    case AnnotationType::EVENT:
-      result = "event";
-      break; 
     case AnnotationType::DOMEIN:
       result = "domain";
       break; 
@@ -109,12 +126,12 @@ namespace folia {
     case AnnotationType::ENTITY: 
       result = "entity";
       break;
-    case AnnotationType::SUBENTITY: 
-      result = "subentity";
-      break;
     case AnnotationType::CORRECTION: 
       result = "correction";
       break;
+    case AnnotationType::SUGGESTION: 
+      result = "suggestion";
+      break;
     case AnnotationType::ERRORDETECTION: 
       result = "errordetection";
       break;
@@ -130,49 +147,67 @@ namespace folia {
     case AnnotationType::MORPHOLOGICAL:
       result = "morphological";
       break;
+    case AnnotationType::SUBENTITY: 
+      result = "subentity";
+      break;
+    case AnnotationType::EVENT:
+      result = "event";
+      break; 
     case AnnotationType::DEPENDENCY:
       result = "dependency";
       break;
     case AnnotationType::TIMEDEVENT:
-      result = "timedevent";
+      result = "timesegment";
       break;
-    default:
-      throw ValueError( " unknown translation for annotation: " + 
-			folia::toString(int(at)) );
+    case AnnotationType::GAP:
+      result = "gap";
+      break; 
+    case AnnotationType::ALIGNMENT:
+      result = "alignment";
+      break; 
+    case AnnotationType::COMPLEXALIGNMENT:
+      result = "complexalignment";
+      break; 
+    case AnnotationType::COREFERENCE:
+      result = "coreference";
+      break; 
+    case AnnotationType::SEMROLE:
+      result = "semrole";
+      break; 
+    case AnnotationType::METRIC:
+      result = "metric";
+      break; 
+    case AnnotationType::LAST_ANN:
+      throw logic_error("LAST_ANN");
     };
     return result;
   }
-
-  int to_lower( const int& i ){ return tolower(i); }
-  int to_upper( const int& i ){ return toupper(i); }
-
-  string lowercase( const string& in ){
-    string s = in;
-    transform( s.begin(), s.end(), s.begin(), to_lower );
-    return s;
-  }
-
-  string uppercase( const string& in ){
-    string s = in;
-    transform( s.begin(), s.end(), s.begin(), to_upper );
-    return s;
-  }
-
+ 
   AnnotationType::AnnotationType stringToAT( const string& at ){
     if ( at == "text" )
       return AnnotationType::TEXT;
+    if ( at == "string" )
+      return AnnotationType::STRING;
     if ( at == "token" )
       return AnnotationType::TOKEN;
     if ( at == "div" )
       return AnnotationType::DIVISION;
-    if ( at == "gap" )
-      return AnnotationType::GAP;
+    if ( at == "paragraph" )
+      return AnnotationType::PARAGRAPH;
+    if ( at == "list" )
+      return AnnotationType::LIST;
+    if ( at == "figure" )
+      return AnnotationType::FIGURE;
+    if ( at == "whitespace" )
+      return AnnotationType::WHITESPACE;
+    if ( at == "linebreak" )
+      return AnnotationType::LINEBREAK;
+    if ( at == "sentence" )
+      return AnnotationType::SENTENCE;
     if ( at == "pos" )
       return AnnotationType::POS;
     if ( at == "lemma" )
       return AnnotationType::LEMMA;
-    if ( at == "event" )
-      return AnnotationType::EVENT;
     if ( at == "domain" )
       return AnnotationType::DOMEIN;
     if ( at == "sense" )
@@ -183,10 +218,10 @@ namespace folia {
       return AnnotationType::CHUNKING;
     if ( at == "entity" )
       return AnnotationType::ENTITY;
-    if ( at == "subentity" )
-      return AnnotationType::SUBENTITY;
     if ( at == "correction" )
       return AnnotationType::CORRECTION; 
+    if ( at == "suggestion" )
+      return AnnotationType::SUGGESTION; 
     if ( at == "errordetection" )
       return AnnotationType::ERRORDETECTION; 
     if ( at == "alternative" )
@@ -197,10 +232,26 @@ namespace folia {
       return AnnotationType::SUBJECTIVITY;
     if ( at == "morphological" )
       return AnnotationType::MORPHOLOGICAL;
+    if ( at == "subentity" )
+      return AnnotationType::SUBENTITY;
+    if ( at == "event" )
+      return AnnotationType::EVENT;
     if ( at == "dependency" )
       return AnnotationType::DEPENDENCY;
-    if ( at == "timedevent" )
+    if ( at == "timesegment" )
       return AnnotationType::TIMEDEVENT;
+    if ( at == "gap" )
+      return AnnotationType::GAP;
+    if ( at == "complexalignment" )
+      return AnnotationType::COMPLEXALIGNMENT;
+    if ( at == "alignment" )
+      return AnnotationType::ALIGNMENT;
+    if ( at == "semrole" )
+      return AnnotationType::SEMROLE;
+    if ( at == "coreference" )
+      return AnnotationType::COREFERENCE;
+    if ( at == "metric" )
+      return AnnotationType::METRIC;
     throw ValueError( " unknown translation for attribute: " + at );
   }
 
@@ -211,12 +262,13 @@ namespace folia {
     case TextContent_t: result = "t"; break;
     case Text_t: result = "text"; break;
     case Event_t: result = "event"; break;
-    case TimedEvent_t: result = "timedevent"; break;
-    case Timings_t: result = "timings"; break;
+    case TimeSegment_t: result = "timesegment"; break;
+    case TimingLayer_t: result = "timing"; break;
     case LineBreak_t: result = "br"; break;
     case WhiteSpace_t: result = "whitespace"; break;
-    case Word_t: result = "word"; break;
+    case Word_t: result = "w"; break;
     case WordReference_t: result = "wref"; break; 
+    case Str_t: result = "str"; break;
     case Sentence_t: result = "s"; break;
     case Paragraph_t: result = "p"; break;
     case Division_t: result = "div"; break;
@@ -234,15 +286,20 @@ namespace folia {
     case Sense_t: result = "sense"; break; 
     case Subjectivity_t: result = "subjectivity"; break; 
     case Correction_t: result = "correction"; break;
-    case Annolay_t: result = "annotationlayer"; break; 
+    case AnnotationLayer_t: result = "annotationlayer"; break; 
     case SyntacticUnit_t: result = "su"; break; 
     case SyntaxLayer_t: result = "syntax"; break; 
     case Chunk_t: result = "chunk"; break; 
     case Chunking_t: result = "chunking"; break; 
     case Entity_t: result = "entity"; break;
     case Entities_t: result = "entities"; break;
-    case Subentity_t: result = "subentity"; break;
-    case Subentities_t: result = "subentities"; break;
+    case Semroles_t: result = "semroles"; break;
+    case Semrole_t: result = "semrole"; break;
+    case Coreferences_t: result = "coreferences"; break;
+    case CoreferenceLink_t: result = "coreferencelink"; break;
+    case CoreferenceChain_t: result = "coreferencechain"; break;
+    // case Subentity_t: result = "subentity"; break;
+    // case Subentities_t: result = "subentities"; break;
     case Morphology_t: result = "morphology"; break;
     case Morpheme_t: result = "morpheme"; break;
     case ErrorDetection_t: result = "errordetection"; break;
@@ -250,242 +307,429 @@ namespace folia {
     case Original_t: result = "original"; break;
     case Current_t: result = "current"; break;
     case Suggestion_t: result = "suggestion"; break;
-    case Alternative_t: result = "alternative"; break; 
-    case AltLayers_t: result = "altlayers"; break;
+    case Alternative_t: result = "alt"; break; 
+    case Alternatives_t: result = "altlayers"; break;
     case Description_t: result = "desc"; break;
     case Gap_t: result = "gap"; break;
     case Content_t: result = "content"; break;
-    case Feature_t: result = "feature"; break;
+    case Metric_t: result = "metric"; break;
+    case Feature_t: result = "feat"; break;
     case SynsetFeature_t: result = "synset"; break;
     case ActorFeature_t: result = "actor"; break;
-    case HeadFeature_t: result = "headfeat"; break;
-    case BegindatetimeFeature_t: result = "begindatetime"; break;
-    case EnddatetimeFeature_t: result = "enddatetime"; break;
+    case HeadFeature_t: result = "headfeature"; break;
+    case ValueFeature_t: result = "value"; break;
+    case TimeFeature_t: result = "time"; break;
+    case ModalityFeature_t: result = "modality"; break;
+    case LevelFeature_t: result = "level"; break;
+    case FunctionFeature_t: result = "function"; break;
+    case BeginDateTimeFeature_t: result = "begindatetime"; break;
+    case EndDateTimeFeature_t: result = "enddatetime"; break;
     case PlaceHolder_t: result = "placeholder"; break;
     case Dependencies_t: result = "dependencies"; break;
     case Dependency_t: result = "dependency"; break;
     case DependencyDependent_t: result = "dep"; break;
-    case DependencyHead_t: result = "hd"; break;
+    case Headwords_t: result = "hd"; break;
+    case Alignment_t: result = "alignment"; break;
+    case AlignReference_t: result = "aref"; break; 
     default:
       result = "Unknown Elementtype " + folia::toString( int(et) );
     }
     return result;
   }
 
-  FoliaElement *FoliaElement::createElement( Document *doc, 
-					     const string& tag ){
-    //factory;
+  ElementType stringToET( const string& tag ){
     if ( tag == "FoLiA" ){
-      return new FoLiA( doc );
-    }
-    if ( tag == "DCOI" ){
-      return new DCOI( doc );
+      return BASE;
     }
     if ( tag == "text" ){
-      return new Text( doc );
+      return Text_t;
+    }
+    if ( tag == "w" ){
+      return Word_t;
+    }
+    if ( tag == "str" ){
+      return Str_t;
     }
     if ( tag == "event" ){
-      return new Event( doc );
+      return Event_t;
     }
-    if ( tag == "timedevent" ){
-      return new TimedEvent( doc );
+    if ( tag == "timesegment" ){
+      return TimeSegment_t;
     }
-    if ( tag == "timings" ){
-      return new TimingLayer( doc );
+    if ( tag == "timing" ){
+      return TimingLayer_t;
     }
     if ( tag == "s" ){
-      return new Sentence( doc );
+      return Sentence_t;
     }
     if ( tag == "t" ){
-      return new TextContent( doc );
+      return TextContent_t;
     }
     if ( tag == "br" ){
-      return new LineBreak( doc );
+      return LineBreak_t;
     }
     if ( tag == "whitespace" ){
-      return new WhiteSpace( doc );
-    }
-    if ( tag == "w" ){
-      return new Word( doc );
+      return WhiteSpace_t;
     }
     if ( tag == "figure" ){
-      return new Figure( doc );
+      return Figure_t;
     }
     if ( tag == "caption" ){
-      return new Caption( doc );
+      return Caption_t;
     }
     if ( tag == "label" ){
-      return new Label( doc );
+      return Label_t;
     }
     if ( tag == "list" ){
-      return new List( doc );
+      return List_t;
     }
     if ( tag == "listitem" ){
-      return new ListItem( doc );
+      return ListItem_t;
     }
     if ( tag == "p" ){
-      return new Paragraph( doc );
+      return Paragraph_t;
     }
     if ( tag == "new" ){
-      return new NewElement( doc );
+      return New_t;
     }
     if ( tag == "original" ){
-      return new Original( doc );
+      return Original_t;
+    }
+    if ( tag == "current" ){
+      return Current_t;
     }
     if ( tag == "suggestion" ){
-      return new Suggestion( doc );
+      return Suggestion_t;
     }
     if ( tag == "head" ){
-      return new Head( doc );
+      return Head_t;
     }
     if ( tag == "desc" ){
-      return new Description( doc );
+      return Description_t;
     }
     if ( tag == "gap" ){
-      return new Gap( doc );
+      return Gap_t;
     }
     if ( tag == "content" ){
-      return new Content( doc );
+      return Content_t;
+    }
+    if ( tag == "metric" ){
+      return Metric_t;
     }
     if ( tag == "div" ){
-      return new Division( doc );
+      return Division_t;
+    }
+    if ( tag == "annotationlayer" ){
+      return AnnotationLayer_t;
     }
     if ( tag == "pos" ){
-      return new PosAnnotation( doc );
+      return Pos_t;
     }
     if ( tag == "lemma" ){
-      return new LemmaAnnotation( doc );
+      return Lemma_t;
     }
     if ( tag == "phon" ){
-      return new PhonAnnotation( doc );
+      return Phon_t;
     }
     if ( tag == "domain" ){
-      return new DomainAnnotation( doc );
+      return Domain_t;
     }
     if ( tag == "sense" ){
-      return new SenseAnnotation( doc );
+      return Sense_t;
     }
     if ( tag == "syntax" ){
-      return new SyntaxLayer( doc );
+      return SyntaxLayer_t;
     }
     if ( tag == "subjectivity" ){
-      return new SubjectivityAnnotation( doc );
+      return Subjectivity_t;
     }
     if ( tag == "chunk" ){
-      return new Chunk( doc );
+      return Chunk_t;
     }
     if ( tag == "chunking" ){
-      return new ChunkingLayer( doc );
+      return Chunking_t;
     }
     if ( tag == "entity" ){
-      return new Entity( doc );
+      return Entity_t;
     }
     if ( tag == "entities" ){
-      return new EntitiesLayer( doc );
+      return Entities_t;
+    }
+    if ( tag == "semroles" ){
+      return Semroles_t;
+    }
+    if ( tag == "semrole" ){
+      return Semrole_t;
+    }
+    if ( tag == "coreferences" ){
+      return Coreferences_t;
+    }
+    if ( tag == "coreferencelink" ){
+      return CoreferenceLink_t;
+    }
+    if ( tag == "coreferencechain" ){
+      return CoreferenceChain_t;
+    }
+    // if ( tag == "subentity" ){
+    //   return Subentity_t;
+    // }
+    // if ( tag == "subentities" ){
+    //   return Subentities_t;
+    // }
+    if ( tag == "alt" ){
+      return Alternative_t;
     }
-    if ( tag == "subentity" ){
-      return new Subentity( doc );
+    if ( tag == "placeholder" ){
+      return PlaceHolder_t;
     }
-    if ( tag == "subentities" ){
-      return new SubentitiesLayer( doc );
+    if ( tag == "altlayers" ){
+      return Alternatives_t;
     }
     if ( tag == "su" ){
-      return new SyntacticUnit( doc );
+      return SyntacticUnit_t;
     }
     if ( tag == "wref" ){
-      return new WordReference( doc );
+      return WordReference_t;
     }
     if ( tag == "correction" ){
-      return new Correction( doc );
+      return Correction_t;
     }
     if ( tag == "errordetection" ){
-      return new ErrorDetection( doc );
+      return ErrorDetection_t;
     }
     if ( tag == "morphology" ){
-      return new MorphologyLayer( doc );
+      return Morphology_t;
     }
     if ( tag == "morpheme" ){
-      return new Morpheme( doc );
+      return Morpheme_t;
     }
     if ( tag == "feat" ){
-      return new Feature( doc );
+      return Feature_t;
     }
     if ( tag == "begindatetime" ){
-      return new BegindatetimeFeature( doc );
+      return BeginDateTimeFeature_t;
     }
     if ( tag == "enddatetime" ){
-      return new EnddatetimeFeature( doc );
+      return EndDateTimeFeature_t;
     }
     if ( tag == "synset" ){
-      return new SynsetFeature( doc );
+      return SynsetFeature_t;
     }
     if ( tag == "actor" ){
-      return new ActorFeature( doc );
+      return ActorFeature_t;
     }
-    if ( tag == "headfeat" ){
-      return new HeadFeature( doc );
+    if ( tag == "headfeature" ){
+      return HeadFeature_t;
+    }
+    if ( tag == "value" ){
+      return ValueFeature_t;
+    }
+    if ( tag == "time" ){
+      return TimeFeature_t;
+    }
+    if ( tag == "level" ){
+      return LevelFeature_t;
+    }
+    if ( tag == "function" ){
+      return FunctionFeature_t;
+    }
+    if ( tag == "modality" ){
+      return ModalityFeature_t;
     }
     if ( tag == "quote" ){
-      return new Quote( doc );
+      return Quote_t;
     }
     if ( tag == "dependencies" ){
-      return new DependenciesLayer( doc );
+      return Dependencies_t;
     }
     if ( tag == "dependency" ){
-      return new Dependency( doc );
+      return Dependency_t;
     }
     if ( tag == "dep" ){
-      return new DependencyDependent( doc );
+      return DependencyDependent_t;
     }
     if ( tag == "hd" ){
-      return new DependencyHead( doc );
+      return Headwords_t;
+    }
+    if ( tag == "alignment" ){
+      return Alignment_t;
+    }
+    if ( tag == "aref" ){
+      return AlignReference_t;
     }
     else {
-      //    throw runtime_error( "unknown tag <" + tag + ">" );
-      cerr << "unknown tag <" << tag << ">" << endl;
+      throw ValueError( "unknown tag <" + tag + ">" );
     }
-    return 0;
+    return BASE;
   }
 
-
-  string compress( const string& s ){
-    // remove leading and trailing spaces from a string
-    string result;
-    if ( !s.empty() ){
-      string::const_iterator b_it = s.begin();
-      while ( b_it != s.end() && isspace( *b_it ) ) ++b_it;
-      string::const_iterator e_it = s.end();
-      --e_it;
-      while ( e_it != s.begin() && isspace( *e_it ) ) --e_it;
-      if ( b_it <= e_it )
-	result = string( b_it, e_it+1 );
+  FoliaElement *FoliaElement::createElement( Document *doc, 
+					     ElementType et ){
+    switch ( et ){
+    case BASE:
+      return new FoLiA( doc );
+    case Text_t:
+      return new Text( doc );
+    case Word_t:
+      return new Word( doc );
+    case Str_t:
+      return new String( doc );
+    case Event_t:
+      return new Event( doc );
+    case TimeSegment_t:
+      return new TimeSegment( doc );
+    case TimingLayer_t:
+      return new TimingLayer( doc );
+    case Sentence_t:
+      return new Sentence( doc );
+    case TextContent_t:
+      return new TextContent( doc );
+    case LineBreak_t:
+      return new LineBreak( doc );
+    case WhiteSpace_t:
+      return new WhiteSpace( doc );
+    case Figure_t:
+      return new Figure( doc );
+    case Caption_t:
+      return new Caption( doc );
+    case Label_t:
+      return new Label( doc );
+    case List_t:
+      return new List( doc );
+    case ListItem_t:
+      return new ListItem( doc );
+    case Paragraph_t:
+      return new Paragraph( doc );
+    case New_t:
+      return new NewElement( doc );
+    case Original_t:
+      return new Original( doc );
+    case Current_t:
+      return new Current( doc );
+    case Suggestion_t:
+      return new Suggestion( doc );
+    case Head_t:
+      return new Head( doc );
+    case Description_t:
+      return new Description( doc );
+    case Gap_t:
+      return new Gap( doc );
+    case Content_t:
+      return new Content( doc );
+    case Metric_t:
+      return new MetricAnnotation( doc );
+    case Division_t:
+      return new Division( doc );
+    case AnnotationLayer_t:
+      return new AbstractAnnotationLayer( doc );
+    case Pos_t:
+      return new PosAnnotation( doc );
+    case Lemma_t:
+      return new LemmaAnnotation( doc );
+    case Phon_t:
+      return new PhonAnnotation( doc );
+    case Domain_t:
+      return new DomainAnnotation( doc );
+    case Sense_t:
+      return new SenseAnnotation( doc );
+    case SyntaxLayer_t:
+      return new SyntaxLayer( doc );
+    case Subjectivity_t:
+      return new SubjectivityAnnotation( doc );
+    case Chunk_t:
+      return new Chunk( doc );
+    case Chunking_t:
+      return new ChunkingLayer( doc );
+    case Entity_t:
+      return new Entity( doc );
+    case Entities_t:
+      return new EntitiesLayer( doc );
+    case Semroles_t:
+      return new SemanticRolesLayer( doc );
+    case Semrole_t:
+      return new SemanticRole( doc );
+    case Coreferences_t:
+      return new CoreferenceLayer( doc );
+    case CoreferenceLink_t:
+      return new CoreferenceLink( doc );
+    case CoreferenceChain_t:
+      return new CoreferenceChain( doc );
+    // case Subentity_t:
+    //   return new Subentity( doc );
+    // case Subentities_t:
+    //   return new SubentitiesLayer( doc );
+    case Alternative_t:
+      return new Alternative( doc );
+    case PlaceHolder_t:
+      return new PlaceHolder();
+    case Alternatives_t:
+      return new AlternativeLayers( doc );
+    case SyntacticUnit_t:
+      return new SyntacticUnit( doc );
+    case WordReference_t:
+      return new WordReference( doc );
+    case Correction_t:
+      return new Correction( doc );
+    case ErrorDetection_t:
+      return new ErrorDetection( doc );
+    case Morphology_t:
+      return new MorphologyLayer( doc );
+    case Morpheme_t:
+      return new Morpheme( doc );
+    case Feature_t:
+      return new Feature( doc );
+    case BeginDateTimeFeature_t:
+      return new BeginDateTimeFeature( doc );
+    case EndDateTimeFeature_t:
+      return new EndDateTimeFeature( doc );
+    case SynsetFeature_t:
+      return new SynsetFeature( doc );
+    case ActorFeature_t:
+      return new ActorFeature( doc );
+    case HeadFeature_t:
+      return new HeadFeature( doc );
+    case ValueFeature_t:
+      return new ValueFeature( doc );
+    case TimeFeature_t:
+      return new TimeFeature( doc );
+    case ModalityFeature_t:
+      return new ModalityFeature( doc );
+    case FunctionFeature_t:
+      return new FunctionFeature( doc );
+    case LevelFeature_t:
+      return new LevelFeature( doc );
+    case Quote_t:
+      return new Quote( doc );
+    case Dependencies_t:
+      return new DependenciesLayer( doc );
+    case Dependency_t:
+      return new Dependency( doc );
+    case DependencyDependent_t:
+      return new DependencyDependent( doc );
+    case Headwords_t:
+      return new Headwords( doc );
+    case Alignment_t:
+      return new Alignment( doc );
+    case AlignReference_t:
+      return new AlignReference( doc );
+    default:
+      throw ValueError( "unknown elementtype(" + toString(int(et)) + ")" );
     }
-    return result;
+    return 0;
   }
 
-  size_t split_at( const string& src, vector<string>& results, 
-		   const string& sep ){
-    // split a string into substrings, using seps as seperator
-    // silently skip empty entries (e.g. when two or more seperators co-incide)
-    // also purges trailing and leading spaces
-    results.clear();
-    string::size_type pos = 0;
-    string res;
-    while ( pos != string::npos ){
-      string::size_type p = src.find( sep, pos );
-      if ( p == string::npos ){
-	res = src.substr( pos );
-	pos = p;
-      }
-      else {
-	res = src.substr( pos, p - pos );
-	pos = p + sep.length();
-      }
-      res = folia::compress( res );
-      if ( !res.empty() )
-	results.push_back( res );
+  FoliaElement *FoliaElement::createElement( Document *doc, 
+					     const string& tag ){
+    
+    ElementType et = BASE;
+    try {
+      et = stringToET( tag );
     }
-    return results.size();
+    catch ( ValueError& e ){
+      cerr << e.what() << endl;
+      return 0;
+    }
+    return createElement( doc, et );
   }
 
   KWargs getArgs( const std::string& s ){
@@ -592,10 +836,6 @@ namespace folia {
     return result;
   }
 
-  xmlNode *newXMLNode( xmlNs *ns,  const string& elem ){
-    return xmlNewNode( ns, (const xmlChar*)elem.c_str() );
-  }
-
   KWargs getAttributes( const xmlNode *node ){
     KWargs atts;
     if ( node ){
@@ -613,120 +853,18 @@ namespace folia {
     while ( it != attribs.end() ){
       //    cerr << "addAttributes(" << it->first << ", " << it->second << ")" << endl;
       if ( it->first == "_id" ){ // id is special
-	xmlNewNsProp( node, 0, XML_XML_ID,  (const xmlChar *)it->second.c_str() );
+	xmlSetProp( node, XML_XML_ID, (const xmlChar *)it->second.c_str() );
       }
-      else {
-	xmlNewNsProp( node, 0, 
-		      (const xmlChar*)it->first.c_str(), 
-		      (const xmlChar*)it->second.c_str() );
-      }
-      ++it;
-    }
-  }
-
-  string Name( const xmlNode *node ){
-    string result;
-    if ( node ){
-      result = (char *)node->name;
-    }
-    return result;
-  }
-
-  string XmlContent( const xmlNode *node ){
-    string result;
-    if ( node ){
-      xmlChar *tmp = xmlNodeListGetString( node->doc, node->children, 1 );
-      if ( tmp ){
-	result = string( (char *)tmp );
-	xmlFree( tmp );
-      }
-    }
-    return result;
-  }
-
-  string getNS( const xmlNode *node, string& prefix ){
-    string result;
-    prefix = "";
-    xmlNs *p = node->ns;
-    if ( p ){
-      if ( p->prefix ){
-	prefix = (char *)p->prefix;
-      }
-      result = (char *)p->href;
-    }
-    return result;
-  }
-
-  map<string,string> getNSlist( const xmlNode *node ){
-    map<string,string> result;
-    xmlNs *p = node->ns;
-    while ( p ){
-      string pre;
-      string val;
-      if ( p->prefix ){
-	pre = (char *)p->prefix;
-      }
-      val = (char *)p->href;
-      result[pre] = val;
-      p = p->next;
-    }
-    return result;
-  }
-
-  list<xmlNode*> FindLocal( xmlXPathContext* ctxt, 
-			    const string& xpath ){
-    list<xmlNode*> nodes;
-    xmlXPathObject* result = xmlXPathEval((xmlChar*)xpath.c_str(), ctxt);
-    if ( result ){
-      if (result->type != XPATH_NODESET) {
-	xmlXPathFreeObject(result);
-	throw runtime_error( "sorry, only nodeset result types supported for now." );
-	return nodes;
-      }
-      xmlNodeSet* nodeset = result->nodesetval;
-      if ( nodeset ){
-	for (int i = 0; i != nodeset->nodeNr; ++i)
-	  nodes.push_back(nodeset->nodeTab[i]);
+      else if ( it->first == "lang" ){ // lang is special
+	xmlNodeSetLang( node, (const xmlChar*)it->second.c_str() );
       }
       else {
-	throw( runtime_error( "FindLocal: Missing nodeset" ) );
-      }
-      xmlXPathFreeObject(result);
-    }
-    else {
-      throw runtime_error( "Invalid Xpath: '" + xpath + "'" );
-    }
-    return nodes;
-  }
-
-  list<xmlNode*> FindNodes( xmlNode* node,
-			    const string& xpath ){
-    xmlXPathContext* ctxt = xmlXPathNewContext( node->doc );
-    ctxt->node = node;
-    ctxt->namespaces = xmlGetNsList( node->doc, ctxt->node );
-    ctxt->nsNr = 0;
-    if (ctxt->namespaces != 0 ) {
-      while (ctxt->namespaces[ctxt->nsNr] != 0 ){
-	ctxt->nsNr++;
+	xmlSetProp( node,
+		    (const xmlChar*)it->first.c_str(), 
+		    (const xmlChar*)it->second.c_str() );
       }
+      ++it;
     }
-    list<xmlNode*> nodes = FindLocal( ctxt, xpath );
-    if (ctxt->namespaces != NULL)
-      xmlFree(ctxt->namespaces);
-    xmlXPathFreeContext(ctxt);
-    return nodes;
-  }
-
-  xmlNode *xPath( xmlNode *node, const string& xpath ){
-    // try to find a path, but it may not be there...
-    // if there are more, just return the first
-
-    list<xmlNode*> srch = FindNodes( node, xpath );
-    xmlNode *result = 0;
-    if ( srch.size() != 0 ){
-      result = srch.front();
-    }
-    return result;
   }
 
   int toMonth( const string& ms ){
@@ -736,7 +874,7 @@ namespace folia {
       return result - 1;
     }
     catch( exception ){
-      string m = lowercase( ms );
+      string m = TiCC::lowercase( ms );
       if ( m == "jan" )
 	return 0;
       else if ( m == "feb" )
@@ -766,35 +904,37 @@ namespace folia {
     }
   }
 
-  tm *parseDate( const string& s ){
-    //  cerr << "try to read a date-time " << s << endl;
+  string parseDate( const string& s ){
+    if ( s.empty() )
+      return "";
+    //    cerr << "try to read a date-time " << s << endl;
     vector<string> date_time;
-    size_t num = split_at( s, date_time, "T");
+    size_t num = TiCC::split_at( s, date_time, "T");
     if ( num == 0 ){
-      num = split_at( s, date_time, " ");
+      num = TiCC::split_at( s, date_time, " ");
       if ( num == 0 ){
 	cerr << "failed to read a date-time " << s << endl;
 	return 0;
       }
     }
-    //  cerr << "found " << num << " parts" << endl;
+    //    cerr << "found " << num << " parts" << endl;
     tm *time = new tm();
     if ( num == 1 || num == 2 ){
-      //    cerr << "parse date " << date_time[0] << endl;
+      //      cerr << "parse date " << date_time[0] << endl;
       vector<string> date_parts;
-      size_t dnum = split_at( date_time[0], date_parts, "-" );
+      size_t dnum = TiCC::split_at( date_time[0], date_parts, "-" );
       switch ( dnum ){
       case 3: {
-	int year = stringTo<int>( date_parts[0] );
-	time->tm_year = year-1900;
+	int mday = stringTo<int>( date_parts[2] );
+	time->tm_mday = mday;
       }
       case 2: {
 	int mon = toMonth( date_parts[1] );
 	time->tm_mon = mon;
       }
       case 1: {
-	int mday = stringTo<int>( date_parts[2] );
-	time->tm_mday = mday;
+	int year = stringTo<int>( date_parts[0] );
+	time->tm_year = year-1900;
       }
 	break;
       default:
@@ -803,23 +943,24 @@ namespace folia {
       }
     }
     if ( num == 2 ){
-      //    cerr << "parse time " << date_time[1] << endl;
+      //      cerr << "parse time " << date_time[1] << endl;
       vector<string> date_parts;
-      num = split_at( date_time[1], date_parts, ":" );
+      num = TiCC::split_at( date_time[1], date_parts, ":" );
+      //      cerr << "parts " << date_parts << endl;
       switch ( num ){
       case 4:
 	// ignore
       case 3: {
-	int hour = stringTo<int>( date_parts[0] );
-	time->tm_hour = hour;
+	int sec = stringTo<int>( date_parts[2] );
+	time->tm_sec = sec;
       }
       case 2: {
 	int min = stringTo<int>( date_parts[1] );
 	time->tm_min = min;
       }
       case 1: {
-	int sec = stringTo<int>( date_parts[2] );
-	time->tm_sec = sec;
+	int hour = stringTo<int>( date_parts[0] );
+	time->tm_hour = hour;
       }
 	break;
       default:
@@ -827,11 +968,98 @@ namespace folia {
 	return 0;
       }
     }
-    //  cerr << "read _date time = ";
-    // char buf[100];
-    // strftime( buf, 100, "%Y-%b-%d %X", time );
-    // cerr << buf << endl;
-    return time;
+    // cerr << "read _date time = " << toString(time) << endl;
+    char buf[100];
+    strftime( buf, 100, "%Y-%m-%dT%X", time );
+    delete time;
+    return buf;
   }
 
+  bool AT_sanity_check(){
+    bool sane = true;
+    AnnotationType::AnnotationType at = AnnotationType::NO_ANN;
+    while ( ++at != AnnotationType::LAST_ANN ){
+      string s = toString( at );
+      if ( s.empty() ){
+	cerr << "no string translation for AnnotationType(" << at << ")" << endl;
+	sane = false;
+      }
+      else {
+	try {
+	  stringTo<AnnotationType::AnnotationType>( s );
+	}
+	catch ( ValueError& e ){
+	  cerr << "no AnnotationType found for string '" << s << "'" << endl;	
+	  sane = false;
+	}
+      }
+    }
+    return sane;
+  };
+
+  bool ET_sanity_check(){
+    bool sane = true;
+    ElementType et = BASE;
+    while ( ++et != LastElement ){
+      string s = toString( et );
+      if ( s.empty() ){
+	cerr << "no string translation for ElementType(" << et << ")" << endl;
+	sane = false;
+      }
+      else {
+	ElementType et2;
+	try {
+	  et2 = stringToET( s );
+	}
+	catch ( ValueError& e ){
+	  cerr << "no element type found for string '" << s << "'" << endl;
+	  sane = false;
+	  continue;
+	}
+	if ( et != et2 ){
+	  cerr << "Argl: toString(ET) doesn't match original:" << s 
+	       << " vs " << toString(et2) << endl;
+	  sane = false;
+	  continue;
+	}
+	FoliaElement *tmp = FoliaElement::createElement( 0, s );
+	if ( tmp == 0 ) {
+	  cerr << "no Element created found for string '" << s << "'" << endl;	
+	  sane = false;
+	}
+	else {
+	  if ( et != tmp->element_id() ){
+	    cerr << "the element type of " << tmp << " != " << et << endl;
+	    sane = false;
+	  }
+	  if ( s != tmp->xmltag() ){
+	    cerr << "the xmltag " << tmp->xmltag() << " != " << s << endl;
+	    sane = false;
+	  }
+	}
+      }
+    }
+    return sane;
+  };
+
+  bool isNCName( const std::string& s ){
+    static string extra=".-_";
+    if ( s.empty() )
+      throw XmlError( "an empty string is not a valid NCName." );
+    else if ( !isalpha(s[0]) )
+      throw XmlError( "'" 
+		      + s 
+		      + "' is not a valid NCName. (must start with character)." );
+    else {
+      for ( size_t i=1; i < s.length(); ++i ){
+	if ( !isalnum(s[i]) &&
+	     extra.find(s[i]) == string::npos )
+	  throw XmlError( "'" + s 
+			  + "' is not a valid NCName.(invalid '" 
+			  + char(s[i]) + "' found" );
+      }
+    }
+    return true;
+  }
+  
 } //namespace folia
diff --git a/src/simpletest.cxx b/src/simpletest.cxx
index b3ebc1b..ff5648c 100644
--- a/src/simpletest.cxx
+++ b/src/simpletest.cxx
@@ -1,8 +1,8 @@
 /*
-  $Id: simpletest.cxx 13851 2012-01-03 08:48:59Z sloot $
+  $Id: simpletest.cxx 15909 2013-04-03 13:52:24Z sloot $
   $URL: https://ilk.uvt.nl/svn/sources/libfolia/trunk/src/simpletest.cxx $
 
-  Copyright (c) 1998 - 2012
+  Copyright (c) 1998 - 2013
   ILK   - Tilburg University
   CLiPS - University of Antwerp
  
@@ -30,13 +30,23 @@
 #include <iostream>
 #include <string>
 #include <map>
-#include "folia/document.h"
-#include "folia/folia.h"
+#include "libfolia/document.h"
 
 using namespace std;
 using namespace folia;
 
 int main() {
+  cout << "checking sanity" << endl;
+  cout << "AnnotationType sanity" << endl;
+  if ( ! AT_sanity_check() ){
+    cout << "to bad. no use to continue" << endl;
+    return EXIT_FAILURE;
+  }
+  cout << "ElementType sanity" << endl;
+  if ( ! ET_sanity_check() ){
+    cout << "to bad. no use to continue" << endl;
+    return EXIT_FAILURE;
+  }
   cout << " Creating a document from scratch: ";
   Document d( "id='example'" );
   d.declare( AnnotationType::TOKEN, "adhocset", "annotator='proycon'" );

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/libfolia.git



More information about the debian-science-commits mailing list