Portrety Uliczne Nieznajomych - zobacz wyjątkową galerię portretów z warszawskich ulic
ZALOGUJ SIĘ
login:
hasło:
przypomnij hasło
załóż konto użytkownika
(i zobacz kilka porad gratis)
   
WYSZUKIWARKA I DZIAŁY
całe porady  tytuły
zaznacz działy do przeszukania
(brak wyboru = wszystkie działy)
PHP
MySQL >
PostgreSQL
SQLite
Perl
Java
XML
XSLT
XPath
WML
SVG
RegExp
Wyszukiwarki
Ochrona
VBScript
Google Plus
XHTML/CSS
JavaScript
Grafika
Flash
Photoshop
Windows
Linux
Bash
Apache
Procmail
E-biznes
Explorer
Opera
Firefox
Inne porady
   
KURSY, DOKUMENTACJE
Własne:
XHTML/CSS
JavaScript
ActionScript
WML, RSS, SSI
Pozostałe:
PHP
MySQL
Java API
więcej...
   
użytkowników online: 63
W CZYM MOGĘ POMÓC?


   
OPINIE UŻYTKOWNIKÓW
Nie jestem webmasterem, ale i na mnie zrobiła wrażenie szybkość reakcji Darka na mój problem. Jego kompetencja i przede wszystkim zupełnie niemodna w dzisiejszych skomercjalizowanych czasach - zwykła ludzka życzliwość dla innego człowieka. Tacy ludzie to dziś gatunek niemal wymarły...

Leszek
Wojskowy Instytut Medyczny

   
GALERIA FOTOGRAFII
   
PODRĘCZNIK PHP 5.x, 4.x, 3.x - częściowo spolszczony / źródło: www.php.net

[Spis] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [X] [W] [Z]

CXXXVII. XSL functions

Wstęp

The XSL extension implements the XSL standard, performing XSLT transformations using the libxslt library

Wymagania

This extension uses libxslt which can be found at http://xmlsoft.org/XSLT/. libxslt version 1.0.18 or greater is required.

Instalacja

PHP 5 includes the XSL extension by default and can be enabled by adding the argument --with-xsl[=DIR] to your configure line. DIR is the libxslt installation directory.

Klasy predefiniowane

XSLTProcessor

Konstructor

Metody

Przykłady

Many examples in this reference require both an XML and an XSL file. We will use collection.xml and collection.xsl that contains the following:

Przykład 1. collection.xml

<collection>
 <cd>
  <title>Fight for your mind</title>
  <artist>Ben Harper</artist>
  <year>1995</year>
 </cd>
 <cd>
  <title>Electric Ladyland</title>
  <artist>Jimi Hendrix</artist>
  <year>1997</year>
 </cd>
</collection>

Przykład 2. collection.xsl

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:param name="owner" select="'Nicolas Eliaszewicz'"/>
 <xsl:output method="html" encoding="iso-8859-1" indent="no"/>
 <xsl:template match="collection">
  Hey! Welcome to <xsl:value-of select="$owner"/>'s sweet CD collection! 
  <xsl:apply-templates/>
 </xsl:template>
 <xsl:template match="cd">
  <h1><xsl:value-of select="title"/></h1>
  <h2>by <xsl:value-of select="artist"/> - <xsl:value-of select="year"/></h2>
  <hr />
 </xsl:template>
</xsl:stylesheet>

Stałe predefinopwane

Poniższe stałe są zdefiniowane w tym rozszerzeniu i stają się dostępne, gdy rozszerzenie jest dokompilowane do PHP, lub załadowane dynamicznie przy starcie.

XSL_CLONE_AUTO (integer)

XSL_CLONE_NEVER (integer)

XSL_CLONE_ALWAYS (integer)

Spis treści
XSLTProcessor->__construct() -- Creates a new XSLTProcessor object
XSLTProcessor->getParameter() -- Get value of a parameter
XSLTProcessor->hasExsltSupport() -- Determine if PHP has EXSLT support
XSLTProcessor->importStylesheet() -- Import stylesheet
XSLTProcessor->registerPHPFunctions() -- Enables the ability to use PHP functions as XSLT functions
XSLTProcessor->removeParameter() -- Remove parameter
XSLTProcessor->setParameter() -- Set value for a parameter
XSLTProcessor->transformToDoc() -- Transform to a DOMDocument
XSLTProcessor->transformToURI() -- Transform to URI
XSLTProcessor->transformToXML() -- Transform to XML



User Contributed Notes

mikko dot wuokko at evtek dot fi
16-Dec-2005 08:41

Little addition for the to the requirements.

In PHP5 you only need to uncomment the php_xsl.dll in php.ini.

Another is that you cannot have php_domxml.dll also in the configuration. After a little research I found out that when both of these are used in the sametime the xsl functionality wont work. It doesn't give you an error message either and the execution stops at the point where first file is loaded.


claus at hommels-lorenz dot de
21-Oct-2005 10:00

It took me while and Justin's help (see above) to install PHP5 correct in order to provide the XSL stuff. This is what it takes to make the XSL functionality avaliable with PHP5 (on MS-Windows):

   libxslt.dll
     - provided by http://xmlsoft.org/XSLT/
     - installed into the php directory or any other
       directory which is in the search path

   php_xsl.dll
     - provided by the "PHP 5.x.x zip package" on http://www.php.net
     - installed into the php extensions directory

   php.ini configuration
     - enable extension=php_xsl.dll

And I still wonder why there is no detailled installation manual on the net..


olivier dot sow at alias dot france
05-Aug-2005 03:27

if you have 'XML parser error 4: not well-formed (invalid token)' error without but your are sure to do no error at all, try this:
<?
function
XSL_transformation($XMLFile,$XSLFile,$ResultFile,$xsl_params){
  
      
$Str = '';

      
$xp = xslt_create() or trigger_error('Could not create XSLT process.', E_USER_ERROR);

      
xslt_set_encoding($xp, 'ISO-8859-1');

      
// read the files into memory
      
$xsl_string = join('', file($XSLFile));
      
$xml_string = join('', file($XMLFile));

      
// set the argument buffer
      
$arg_buffer = array('/xml' => $xml_string, '/xsl' => $xsl_string);

      
// process the two files to get the desired output
      
if (($Str = xslt_process($xp, 'arg:/xml', 'arg:/xsl', NULL, $arg_buffer, $xsl_params))){

          
//Saves transformation result into '$ResultFile'
          
$fp = fopen($ResultFile,"w+");
          
fwrite($fp,$Str);
          
fclose($fp);
          
           return
true;
       }
      
       return
false;

   }
?>

found here: http://bugs.php.net/bug.php?id=16193


justin at justindz dot o r g
01-Apr-2005 10:19

I had trouble using XSLT with PHP 5.0.3 on Windows XP Pro/IIS 5.  Researching on the internet revealed several reports of trouble with "XSLTProcessor class not found."  The solution in almost every case was to uncomment include php_xsl.dll which did not work in my case (and many of those reported).  Also, a large body of documentation dealt with compiling the modules for Apache on Linux, which did not apply in my case.

I finally resolved this issue by downloading libxslt and adding the associated dlls and exe to c:\php (not system32 or ext) which is in my path.  I had previously added sablotron, libxml2, expat, and iconv based on posted solutions that I now think may only apply to older PHP versions.  I have removed sablotron and expat and verified that XSLTProcessor still works.

Hopefully someone finds this information useful as I had one heck of a time getting this to work and found many false leads on Google and Zend.


venkatesh at lammersmedical dot com
01-Mar-2005 03:17

Here is function to read from the XSL sheet which is saved as a text file.

function ReadExcelSheet($filename){
             $test=file($filename);
             $ar1=str_replace("~[^\t]*\t","\t",$test);
             $ar2=str_replace("~","",$ar1);
             $ar=str_replace("

 

 
  © 1996-2012 & Reporter.plmiejscao serwisieabonamentwarunki korzystaniaRSSkontakt