function prepareXMLFromTemplate( $templateName, $cli = false )
    {
        $template = 'design:' . $templateName . '.tpl';
        $tpl = eZTemplate::factory();

        $tpl->setVariable( 'tpl_info', false );

        $content = $tpl->fetch( $template );
        $tplInfo = false;

        if ( $tpl->variable( "tpl_info" ) !== false )
        {
            $tplInfo = $tpl->variable( "tpl_info" );
        }
        if ( is_array( $tplInfo ) )
        {
            foreach ( $tplInfo as $var => $info )
            {
                if ( isset( $info['info'] ) )
                {
                    $query = $info['info'];
                }
                else
                {
                    $query = 'Info for ' . $var;
                }
                $default = '';
                if ( isset( $info['default'] ) )
                {
                    $default = $info['default'];
                }
                $value = eZPrepareXML::getUserInput( "Please enter \"" . $query . "\" (" . $default . "): ", $default );
                $tpl->setVariable( $var, $value );
            }
        }
        $content = $tpl->fetch( $template );
        $xml     = $tpl->variable( "xml_data" );
        return $xml;
    }
    eZUser::setCurrentlyLoggedInUser( $user, $user->attribute( 'contentobject_id' ) );
}

if( !( isset( $options['file'] ) || isset( $options['template'] ) ) )
{
    $cli->error( "Need at least a file or a template." );
    $script->shutdown( 1 );
}

if ( isset( $options['file'] ) )
{
    $xml = eZPrepareXML::prepareXMLFromFile( $options['file'], $cli );
}
elseif ( isset( $options['template'] ) )
{
    $xml = eZPrepareXML::prepareXMLFromTemplate( $options['template'], $cli );
}
else
{
    $cli->error( "Need at least one argument." );
    $script->shutdown( 1 );
}
$cli->output( "Trying to install data from XML ..." );

if ( $xml == '' )
{
    $cli->error( "No XML data available." );
    $script->shutdown( 1 );
}

$dom = new DOMDocument( '1.0', 'utf-8' );