PHP.mk документација

XSLTProcessor::importStylesheet

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

xsltprocessor.importstylesheet.php PHP.net прокси Преводот се освежува
Оригинал на PHP.net
Патека xsltprocessor.importstylesheet.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + превод во позадина Кодовите, табелите и белешките остануваат читливи во истиот тек.
XSLTProcessor::importStylesheet

Референца за `xsltprocessor.importstylesheet.php` со подобрена типографија и навигација.

xsltprocessor.importstylesheet.php

XSLTProcessor::importStylesheet

класата mysqli_driver

XSLTProcessor::importStylesheetУвоз на стилскиот лист

= NULL

public XSLTProcessor::importStylesheet(object $stylesheet): bool

Овој метод го увезува стилскиот лист во XSLTProcessor за трансформации.

Параметри

stylesheet

Увезениот стилски лист како Dom\Document, DOMDocument or SimpleXMLElement object.

Вратени вредности

Патеката до PHP скриптата што треба да се провери. true на успех или false при неуспех.

Errors/Exceptions

Фрла TypeError if stylesheet не е XML објект.

Дневник на промени

Верзија = NULL
8.4.0 Додадена е поддршка за Dom\Document.
8.4.0 Сега фрла TypeError наместо ValueError if stylesheet не е XML објект.

Белешки од корисници 5 белешки

kevin at metalaxe dot com
пред 18 години
Just for reference, as of this writing, this function does not support importing multiple stylesheets. The following will output only the stylesheet transformation of the second imported sheet:

<?php

# LOAD XML FILE
$XML = new DOMDocument();
$XML->load( 'data.xml' );

# START XSLT
$xslt = new XSLTProcessor();

# IMPORT STYLESHEET 1
$XSL = new DOMDocument();
$XSL->load( 'template1.xsl' );
$xslt->importStylesheet( $XSL );

#IMPORT STYLESHEET 2
$XSL = new DOMDocument();
$XSL->load( 'template2.xsl' );
$xslt->importStylesheet( $XSL );

#PRINT
print $xslt->transformToXML( $XML );
?>

This wasn't documented and quite dissapointing.
bbrosseau at gmail
21 години пред
For those who wants to use external documents, it is important not to use the DomDocument::loadXML because the processor will not have the path to look for other files
 
So if you want to transform some xml with a pre-generated stylesheet $f:

<?php
$f = 'somestylesheet.xsl';
$xsl = DomDocument::loadXML(file_get_contents($f));
?>

document('other.xml') will not work with relative path and <?php $xsl = DomDocument::load($f); ?> will!
diesel at spbnet dot ru
19 години пред
This is not a problem. You may set DOMDocument's documentURI property. 
Something like this 

<?php
$xsl = new DOMDocument('1.0','UTF-8');
     
$xsl->loadXML(file_get_contents('/foo/bar/somefile.xsl');
$xsl->documentURI = '/foo/bar/somefile.xsl';

$xslProc = new XSLTProcessor();
$xslProc->importStylesheet($xsl);
?>

and document('other.xsl') will work fine!
fcartegnie
пред 18 години
PHP5 xsl processor has a different behaviour than PHP4's one with CDATA sections. (see http://bugs.php.net/bug.php?id=29837)
Loaded XSL sheet CDATA sections does not allow, by default, output-escaping handling (everything in the CDATA is escaped by default).

So in this case you can't build your XSL Dom the usual way:
    $xsldom = DomDocument::loadXML(file_get_contents('sheet.xsl'));

and must go through this one (allowing LIBXML_NOCDATA parameter):
    $xsldom = new DomDocument;
    $xsldom->load('sheet.xsl', LIBXML_NOCDATA);

Then the CDATA output-escaping behaviour will be correct.
rbmeo at yahoo dot com
пред 13 години
To make your import dynamic, try this code:

<?php
$dom = new DOMDocument();
$dom->load('main.xsl');
$xpath = new DomXPath($dom);
$importnode= $questionsXsl->createElement('xsl:include');
$attr= $questionsXsl->createAttribute('href');
$attr->value = 'import.xsl';
$importnode->appendChild($attr);
$dom->documentElement->insertBefore($importnode,$ref);
$dom->loadXml($dom->saveXml());
?>

this code basically loads the main stylesheet, prepend the import xsl code then reload as xml string so the imported stylesheet will be loaded at dom.
На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.