public static boolean validateTableRow ( final Node row , final int numColumns ) { assert row != null ; assert row . getNodeName ( ) . equals ( "row" ) || row . getNodeName ( ) . equals ( "tr" ) ; if ( row . getNodeName ( ) . equals ( "row" ) ) { final List < Node > entries = XMLUtilities . getDirectChildNodes ( row , "entry" ) ; final List < Node > entryTbls = XMLUtilities . getDirectChildNodes ( row , "entrytbl" ) ; if ( ( entries . size ( ) + entryTbls . size ( ) ) <= numColumns ) { for ( final Node entryTbl : entryTbls ) { if ( ! validateEntryTbl ( ( Element ) entryTbl ) ) return false ; } return true ; } else { return false ; } } else { final List < Node > nodes = XMLUtilities . getDirectChildNodes ( row , "td" , "th" ) ; return nodes . size ( ) <= numColumns ; } }
Check to ensure that a docbook row has the required number of columns for a table .