(PHP 4 >= 4.0.6)
xslt_set_scheme_handlers — XSLT プロセッサに関するスキーマハンドラを設定する
ドキュメントのスキーマハンドラ (XPath ハンドラ) を登録します。
xslt_create() で作成した XSLT プロセッサリンク ID。
"get_all"、"open"、"get"、"put" および "close" というキーを持つ配列。
すべてのエントリは、関数名を表す文字列あるいは array($obj, "method") 形式の配列である必要があります。
この配列には、すべてのスキームハンドラの要素を含める必要はありません (もちろん含めることもできます) が、 少なくとも "handler" => "function" 形式を満たさなければなりません。
各スキームハンドラ関数は、以下のフォーマットでコールされます。
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)
値を返しません。
例1 xslt_set_scheme_handlers() の例
たとえば、これは PHP の関数 "file_exists()" を実装したものです。
<?php
// ハンドラの定義
function mySchemeHandler($processor, $scheme, $rest)
{
$rest = substr($rest,1); // to remove the first / automatically added by the engine
if ($scheme == 'file_exists') {
// result is embedded in a small xml string
return '<?xml version="1.0" encoding="UTF-8"?><root>' . (file_exists($rest) ? 'true' : 'false') . '</root>';
}
}
$SchemeHandlerArray = array('get_all' => 'mySchemeHandler');
// エンジンを開始します
$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;
?>
これで、スタイルシート側で特定のファイルが存在するかどうかを調べることができます。
<xsl:if test="document('file_exists:anotherXMLfile.xml')/root='true'"> <!-- ファイルが存在する --> </xsl:if>
NPO法人の設立(東京・大阪) 東京や大阪などNPO法人を設立する場合の注意点等を紹介
不動産・賃貸・マンション 不動産・賃貸・マンションに関する用語集です。
堺市の入院・内科大阪の賃貸探し 大阪で賃貸を探している方は大阪ホームへ
東京の賃貸マンション 東京で賃貸を探すなら東京賃貸.orgへ