From d922edfe83806b529bb86f585fc283fb0028e206 Mon Sep 17 00:00:00 2001 From: Ko van der Sloot Date: Fri, 1 Nov 2024 10:47:45 +0100 Subject: [PATCH] better NCName() handling using new folia::create_NCName() function --- configure.ac | 2 +- src/FoLiA-pm.cxx | 7 +------ src/FoLiA-txt.cxx | 9 +-------- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/configure.ac b/configure.ac index 36ab379..d769d2d 100644 --- a/configure.ac +++ b/configure.ac @@ -101,7 +101,7 @@ PKG_CHECK_MODULES([ucto], [ucto >= 0.9.4] ) CXXFLAGS="$ucto_CFLAGS $CXXFLAGS" LIBS="$ucto_LIBS $LIBS" -PKG_CHECK_MODULES([folia], [folia >= 2.19] ) +PKG_CHECK_MODULES([folia], [folia >= 2.21] ) CXXFLAGS="$folia_CFLAGS $CXXFLAGS" LIBS="$folia_LIBS $LIBS" diff --git a/src/FoLiA-pm.cxx b/src/FoLiA-pm.cxx index af68af2..45d21bd 100644 --- a/src/FoLiA-pm.cxx +++ b/src/FoLiA-pm.cxx @@ -393,12 +393,7 @@ Paragraph *add_par( Division *root, xmlNode *p, list& notes ){ note = new Note( args, doc ); } else { - if ( !isNCName( ref ) ){ - ref = "v." + ref; - if ( !isNCName( ref ) ){ - throw ( "the ref attribute in note cannot be converted to an ID" ); - } - } + ref = create_NCName( ref ); KWargs args; args["xml:id"] = ref; note = new Note( args, doc ); diff --git a/src/FoLiA-txt.cxx b/src/FoLiA-txt.cxx index 7121d04..30b5266 100644 --- a/src/FoLiA-txt.cxx +++ b/src/FoLiA-txt.cxx @@ -114,16 +114,9 @@ bool handle_one_file( const string& fileName ){ if ( !outputDir.empty() ){ nameNoExt = docid; } - if ( !isNCName( docid ) ){ - docid = "doc-" + docid; - if ( !isNCName( docid ) ){ - cerr << "unable to generate a Document ID from the filename: '" - << fileName << "'" << endl; - return false; - } - } Document *d = 0; try { + docid = create_NCName( docid ); d = new Document( "xml:id='"+ docid + "'" ); } catch ( exception& e ){