@@ -1019,6 +1019,41 @@ namespace folia {
10191019 }
10201020 }
10211021
1022+ bool AbstractSpanRole::addable ( const FoliaElement *parent ) const {
1023+ // / test if a reference might succesfully appended to \em parent
1024+ /* !
1025+ * \param parent the node to check
1026+ * \return true if it doesn't throw
1027+ *
1028+ * \note It will allways throw an error, instead of returning false
1029+ */
1030+ if ( !AbstractElement::addable ( parent ) ){
1031+ return false ;
1032+ }
1033+ // we must check wref children against the parent too
1034+ vector<WordReference*> wrefs = select<WordReference>();
1035+ for ( const auto & refs : wrefs ){
1036+ FoliaElement *ref = refs->ref ();
1037+ string tval = refs->tval ();
1038+ if ( !tval.empty () ){
1039+ string watt = ref->str (parent->textclass ());
1040+ if ( watt.empty () ){
1041+ string msg = " no matching 't' value found in the '<w>' refered by "
1042+ " <wref id=\" " + ref->id () + " \" t=\" " + tval
1043+ + " \" > for textclass '" + parent->textclass () + " '" ;
1044+ throw XmlError ( this , msg );
1045+ }
1046+ else if ( watt != tval ){
1047+ string msg = " the 't' value of <wref id=\" " + ref->id ()
1048+ + " \" t=\" " + tval + " \" > for textclass '" + parent->textclass ()
1049+ + " ' doesn't match any value of the refered word for that class" ;
1050+ throw XmlError ( this , msg );
1051+ }
1052+ }
1053+ }
1054+ return true ;
1055+ }
1056+
10221057 KWargs LinkReference::collectAttributes () const {
10231058 // / extract all Attribute-Value pairs for LinkReference
10241059 /* !
@@ -1461,6 +1496,7 @@ namespace folia {
14611496 if ( parent->isSubClass <AbstractSpanRole>() ){
14621497 // we should check the textclass of the layer above this.
14631498 // but due to recursion, it is not connected to that layer yet!
1499+ // this is checked later in AbstractSpanRole::addable( )
14641500 return true ;
14651501 }
14661502 if ( !_tval.empty () ){
0 commit comments