domxml_xslt_stylesheet
(PHP 4 >= 4.2.0)
domxml_xslt_stylesheet — Создает объект DomXsltStylesheet из строки XSL
Описание
DomXsltStylesheet domxml_xslt_stylesheet
( string $xsl_buf
)
Создает объект класса DomXsltStylesheet из переданного XSL буфера.
Список параметров
- xsl_buf
-
XSL документ в виде строки.
Возвращаемые значения
Возвращает новый экземпляр класса DomXsltStylesheet.
Переход на PHP 5
Вызывайте XSLTProcessor::importStylesheet() с аргументом DOMDocument::loadXML($xsl_buf).
Смотрите также
- DomXsltStylesheet::process
- domxml_xslt_stylesheet_file() - Создает объект DomXsltStylesheet из XML файла
- domxml_xslt_stylesheet_doc() - Создает объект класса DomXsltStylesheet из объекта DomDocument
[an error occurred while processing the directive]
- DomAttribute::name
- DomAttribute::set_value
- DomAttribute::specified
- DomAttribute::value
- DomDocument::add_root
- DomDocument::create_attribute
- DomDocument::create_cdata_section
- DomDocument::create_comment
- DomDocument::create_element_ns
- DomDocument::create_element
- DomDocument::create_entity_reference
- DomDocument::create_processing_instruction
- DomDocument::create_text_node
- DomDocument::doctype
- DomDocument::document_element
- DomDocument::dump_file
- DomDocument::dump_mem
- DomDocument::get_element_by_id
- DomDocument::get_elements_by_tagname
- DomDocument::html_dump_mem
- DomDocument::xinclude
- DomDocumentType::entities
- DomDocumentType::internal_subset
- DomDocumentType::name
- DomDocumentType::notations
- DomDocumentType::public_id
- DomDocumentType::system_id
- DomElement::get_attribute_node
- DomElement::get_attribute
- DomElement::get_elements_by_tagname
- DomElement::has_attribute
- DomElement::remove_attribute
- DomElement::set_attribute_node
- DomElement::set_attribute
- DomElement::tagname
- DomNode::add_namespace
- DomNode::append_child
- DomNode::append_sibling
- DomNode::attributes
- DomNode::child_nodes
- DomNode::clone_node
- DomNode::dump_node
- DomNode::first_child
- DomNode::get_content
- DomNode::has_attributes
- DomNode::has_child_nodes
- DomNode::insert_before
- DomNode::is_blank_node
- DomNode::last_child
- DomNode::next_sibling
- DomNode::node_name
- DomNode::node_type
- DomNode::node_value
- DomNode::owner_document
- DomNode::parent_node
- DomNode::prefix
- DomNode::previous_sibling
- DomNode::remove_child
- DomNode::replace_child
- DomNode::replace_node
- DomNode::set_content
- DomNode::set_name
- DomNode::set_namespace
- DomNode::unlink_node
- DomProcessingInstruction::data
- DomProcessingInstruction::target
- DomXsltStylesheet::process
- DomXsltStylesheet::result_dump_file
- DomXsltStylesheet::result_dump_mem
- domxml_new_doc
- domxml_open_file
- domxml_open_mem
- domxml_version
- domxml_xmltree
- domxml_xslt_stylesheet_doc
- domxml_xslt_stylesheet_file
- domxml_xslt_stylesheet
- domxml_xslt_version
- xpath_eval_expression
- xpath_eval
- xpath_new_context
- xpath_register_ns_auto
- xpath_register_ns
- xptr_eval
- xptr_new_context
Коментарии
This is an exemple to change from XML to HTML by XSL utilising XML_DOM
File XML : Reunions.xml
<?xml version="1.0"?>
<reunions prev_id_reunion="2">
<reunion id_reunion="0">
<organisateur>Organisateur 1</organisateur>
<date>Date 1</date>
<heure>Heure 1</heure>
<lieu>Lieu 1</lieu>
<sujets>
<sujet>Sujet 11</sujet>
<sujet>Sujet 12</sujet>
</sujets>
<participants>
<participant>Participant11</participant>
<participant>Participant12</participant>
</participants>
</reunion>
<reunion id_reunion="1">
<organisateur>Organisateur 2</organisateur>
<date>Date 2</date>
<heure>Heure 2</heure>
<lieu>Lieu 2</lieu>
<sujets>
<sujet>Sujet21</sujet>
<sujet>Sujet22</sujet>
</sujets>
<participants>
<participant>Participant21</participant>
<participant>Participant22</participant>
</participants>
</reunion>
</reunions>
File PHP : Reunions.PhP
<?php
$StrXsl = '<?xml version="1.0" encoding="ISO-8859-1"?>'.
'<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">'.
'<xsl:template match="/">'.
'<html>'.
'<head>'.
'<title></title>'.
'</head>'.
'<body bgcolor="white" text="black" link="blue" vlink="purple" alink="red">'.
'<div align="center">'.
'<font face="Verdana" color="#4682b4" size="+2">La liste des reunions</font>'.
'<table border="0" cellpadding="0" cellspacing="0" width="300" bgcolor="#f5fffa">'.
'<tr>'.
'<th>'.
'<div align="center">'.
'<font face="Verdana" color="#4682b4" size="-1">Organisateur</font>'.
'</div>'.
'</th>'.
'<th>'.
'<div align="center">'.
'<font face="Verdana" color="#4682b4" size="-1">Date</font>'.
'</div>'.
'</th>'.
'<th>'.
'<div align="center">'.
'<font face="Verdana" color="#4682b4" size="-1">Heure</font>'.
'</div>'.
'</th>'.
'<th>'.
'<div align="center">'.
'<font face="Verdana" color="#4682b4" size="-1">Lieu</font>'.
'</div>'.
'</th>'.
'</tr>'.
'<xsl:apply-templates select="reunions/reunion">'.
'<xsl:sort select="organisateur" order="ascending"/>'.
'</xsl:apply-templates>'.
'</table>'.
'</div>'.
'</body>'.
'</html>'.
'</xsl:template>'.
'<xsl:template match="reunion">'.
'<tr>'.
'<td bgcolor="white">'.
'<font face="Verdana" color="#4682b4" size="-1"><xsl:value-of select="organisateur"/></font>'.
'</td>'.
'<td bgcolor="white">'.
'<font face="Verdana" color="#4682b4" size="-1"><xsl:value-of select="date"/></font>'.
'</td>'.
'<td bgcolor="white">'.
'<font face="Verdana" color="#4682b4" size="-1"><xsl:value-of select="heure"/></font>'.
'</td>'.
'<td bgcolor="white">'.
'<font face="Verdana" color="#4682b4" size="-1"><xsl:value-of select="lieu"/></font>'.
'</td>'.
'</tr>'.
'</xsl:template>'.
'</xsl:stylesheet>';
//Transformer XML -> HTML par XSL
$CurrentDir = dirname(__FILE__);
$xmldoc = domxml_open_file("$CurrentDir\\Reunions.xml");
$xsldoc = domxml_xslt_stylesheet ($StrXsl);
$result = $xsldoc->process($xmldoc);
print $xsldoc->result_dump_mem($result);
?>