Only show size attributes in product box woocommerce when available

to test is the text is not empty, try that :

function display_size_attribute() {

    global $product;

    if ($product->is_type('external')) {

        $taxonomy = 'pa_maat';

        $text = $product->get_attribute($taxonomy);

        if (!empty($text)) {
            echo "Maten:";
            echo '<span class="attribute-size">' 
                    . htmlspecialchars($text) 
            . '</span>';
        }

    } // END if ($product->is_type('external')) {


} // END function display_size_attribute() {

error code: 523