Funzioni XSLT (PHP 4)
PHP Manual

xslt_set_scheme_handlers

(PHP 4 >= 4.0.6)

xslt_set_scheme_handlersImposta gli handler di schema per il processore XSLT

Descrizione

void xslt_set_scheme_handlers ( resource $xh , array $handlers )

Registra gli handler di schema (XPath handler) per il documento.

Elenco dei parametri

xh

L'identificatore del processore XSLT, creato da xslt_create().

handlers

Un array con le seguenti chiavi: "get_all", "open", "get", "put", e "close".

Ogni voce deve essere un nome di funzione o un array nel seguente formato: array($obj, "method").

Notare che l'array dato non hai bisogno di contenere tutti i differenti elementi handler di schema (anche se potrebbe), ma ha solo bisogno di essere conforme al formato "handler" => "function" descritto sopra.

Ciascuno delle singole funzioni handler dello schema chiamate sono nei formati seguenti:

string   get_all(resource processor, string scheme, string rest)
resource open(resource processor, string scheme, string rest)
int      get(resource processor, resource fp, string &data)
int      put(resource processor, resource fp, string data)
void     close(resource processor, resource fp)

Valori restituiti

Nessun valore viene restituito.

Esempi

Example #1 Esempio dell'utilizzo di xslt_set_scheme_handlers()

Ad esempio, ecco un'implementazione della funzione PHP "file_exists()".

<?php

// Definizione dell'handler
function mySchemeHandler($processor$scheme$rest)
{
    
$rest substr($rest,1);    // rimuovere il primo / automaticamente aggiunto dal motore
    
if ($scheme == 'file_exists') {
        
// il risultato è incorporato in una piccola stringa xml
        
return '<?xml version="1.0" encoding="UTF-8"?><root>' . (file_exists($rest) ? 'true' 'false') . '</root>';
    }
}

$SchemeHandlerArray = array('get_all' => 'mySchemeHandler');

// Avvia il motore
$params = array();
$xh xslt_create();

xslt_set_scheme_handlers($xh$SchemeHandlerArray);

$result xslt_process($xh"myFile.xml""myFile.xsl"NULL, array(), $params);
xslt_free($xh);

echo 
$result;

?>

Dopo, all'interno del foglio di stile, è possibile verificare se un certo file esiste con:

<xsl:if test="document('file_exists:anotherXMLfile.xml')/root='true'">
 <!-- Il file esiste -->
</xsl:if>

Vedere anche:


Funzioni XSLT (PHP 4)
PHP Manual