PHP Doku:: Applies the XSLT-Transformation on a DomDocument Object - function.domxsltstylesheet-process.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzXML-ManipulationDOM-XMLDOM-XML-FunktionenDomXsltStylesheet->process

Ein Service von Reinhard Neidl - Webprogrammierung.

DOM-XML-Funktionen

<<DomProcessingInstruction->target

DomXsltStylesheet->result_dump_file>>

DomXsltStylesheet->process

(PHP 4 >= 4.1.0)

DomXsltStylesheet->process Applies the XSLT-Transformation on a DomDocument Object

Beschreibung

DomDocument DomXsltStylesheet::process ( DomDocument $xml_doc [, array $xslt_params [, bool $is_xpath_param [, string $profile_filename ]]] )

Applies an XSLT Transformation on the given DomDocument object.

Parameter-Liste

xml_doc

The XML document being transformed, as a DomDocument object.

xslt_params

An associative array that takes pairs of parameter names and values.

is_xpath_param

If set to FALSE the values of the xslt_params will be quoted. This is the default behavior. It allows you to pass the values as PHP strings.

Hinweis:

If your strings contains both single and double quotes, you must take care of quoting all the values by yourself and set this parameter to TRUE.

profile_filename

Set this to the path of a filename, if you want profiling information.

Rückgabewerte

Returns the result of the processing, as a DomDocument object.

Migrating to PHP 5

Use XSLTProcessor::setParameter() and XSLTProcessor::transform-to-doc().

Changelog

Version Beschreibung
4.3.0 The profile_filename parameter was added.

Siehe auch


3 BenutzerBeiträge:
- Beiträge aktualisieren...
msh at 247ms dot com
29.10.2006 20:36
Seems that the transformer is not handling "namespace-alias" correctly. I have been trying to generate XSL with my XML/XSL using this nice feature as described here:

http://www.topxml.com/xsl/examplegenss.asp
http://www.w3schools.com/xsl/el_namespace-alias.asp

Not sure if this is "correct" or "wrong" depending on how you look at it - but just make a note of it so you dont spend an entire Sunday trying to figure out what you did wrong since the basic examples aren't working :-)
Thomas Broyer
23.08.2005 9:54
Within LibXML/LibXSLT, the values of the parameters passed in to the XSLT stylesheet for processing are treated as being XPath expressions to be applied to the source document. This allows you to pass parameters of type "node-set".

This is actually the same as if you modified your XSLT stylesheet to change the default value of the top-level xsl:param to <xsl:param name="param-name" select="param-value" />

As this behavior might be a bit misleading, the PHP/DOMXML binding defaults to "converting" every parameter value to a string, as if you modified your XSLT stylesheet to change the default value of the top-level xsl:param to <xsl:param name="param-name" select="'param-value'" /> (note the single-quotes around the value and enclosed in double-quotes).

If you want to turn back to the original LibXML/LibXSLT behavior, just pass TRUE as the "is_param_xpath" argument.
regis at nvision dot lu
10.06.2004 23:48
Needless to say that xslt_parameters is an associative array. So for instance:

<?php
$document
= new DOMDocument('/path/to/xmldata');
// Unfortunately there's no such method for DomXsltStylesheet
$stylesheet = domxml_xslt_stylesheet_file('/path/to/stylesheet');
$params = array(
  
'param1' => 'value1'
  
...
   ,
'paramN' => 'valueN' );
$result = $stylesheet->process($document, $params);
?>

As far as the param_is_xpath argument is concerned, XPath W3REC doesn't mention any parameter at any time ! That must be a DOM feature, which I'm not keen with yet...

Bye



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)