PHP 7.1.19 Released

XSLT (PHP 4) Funkcje

Spis treści

add a note add a note

User Contributed Notes 9 notes

hentaidream at gmx dot de
6 years ago
How to make a XSLT Side with function

<xsl:output method="xhtml"/>
  <xsl:template match="/">
        <xsl:apply-templates select="aktien/aktie"></xsl:apply-templates>
  <xsl:template match="aktie">
     <xsl:if test="@isin">
       <xsl:value-of select="name" />
       <xsl:value-of select="fn:format-number(fn:sum(kurse/kurs/ausgabepreis) div fn:count(kurse/kurs), '##.00')" />    

10 years ago
In addition to the contibution of "tom at kornack dot com" about converting an Apple plist (iPhoto or iTunes library or other) into a more general XML format, I have tried to simplify his xsl file a little further:

<?xml version="1.0"?>
<xsl:transform xmlns:xsl="" version="1.0">
<xsl:output method="xml" indent="no"/>                
<!-- XSL file based on example on by -->

<xsl:template match="dict">                           
  <xsl:for-each select="key">
    <xsl:variable name="n1" select="translate(.,' ','_')"/>
    <xsl:variable name="pName"><xsl:choose>           
      <xsl:when test="string(number($n1))='NaN'">     
        <xsl:value-of select="$n1"/>                  
        <xsl:value-of select="concat('_',$n1,'_')"/>  
    <xsl:element name="{$pName}">                     
      <xsl:apply-templates select="following-sibling::*[1]"/>

<xsl:template match="array">                          
  <xsl:for-each select="*"><xsl:element name="item">  
    <xsl:attribute name="nr"><xsl:number/></xsl:attribute>
    <xsl:apply-templates select="."/>                 

<xsl:template match="string|integer|real|date|data">  
  <xsl:value-of select="."/>                          

<xsl:template match="true|false">                     
  <xsl:value-of select="name()"/>                     

<xsl:template match="text()|@*">                      

nicolas_rainardNOSPAM at yahoo dot fr
10 years ago
The XSLTProcessor, when transforming a document, always resolves entities.
To avoid this (if you want to keep HTML entitities by ex.), you have two solutions:

- if you have full control over the input document, you can encapsulate every text element which contains entities in a CDATA section.

- the previous solution is the smarter and the less computing intensive, but it is not always possible. In other cases, what you can do is to replace every occurence of '&' (entity mark) by something which will be considered as normal text by the parser (let's say '[AMP]' by ex) in the input document before the transformation. After the transformation, you can get these entitites back in the output document by reversing the previous operation.


= $input_dom->saveXML();
$xml = str_replace('&', '[AMP]', $xml);

$xml = $xsl->transformToXML($input_dom);
$xml = str_replace('[AMP]', '&', $xml);


Warning : this second method "escapes" ALL entities, even those you wouldn't want to be escaped. This is a raw explanation, fine-tune it to your own situation.
11 years ago
bat at flurf, you said that Sablotron implements XSLT 1.1, but according to its makers, "Sablotron is ...implementing XSLT 1.0, DOM Level2 and XPath 1.0" []
will at NOSPAM dot wdp dot ndo dot co dot uk
14 years ago
As an update to the previous advice about the undefined references problem when installing PHP with Sablotron, PHP 4.3.4 has a new EXTRA_LDFLAGS_PROGRAM line added to the Makefile. Make sure to add -lstdc++ to this line as well as the EXTRA_LDFLAGS line.
crtn at users dot sourceforge dot net
15 years ago
Another way to get around the EXPAT-SABLOTRON problems (seg faults) is supposedly to recompile apache with:
d dot brotherstone at pobox dot com
15 years ago
If you get problems with undefined references to gxx_s type stuff, UPDATE LIBTOOL!  I found 1.4.1 worked for some configurations, 1.4.3 worked for almost none, but 1.5 worked for every combination of Sablotron/gettext/sybase/zlib/postgres --with options I tried. 

Make sure you follow the advice of adding -lstdc++ to EXTRA_LD_FLAGS in Makefile after you've run ./configure, and BEFORE you've run make (if you issue make, you'll need to do a make clean before you make again, after changing the Makefile, or it still won't work reliably).

Cheers, Dave.
jw at shapers dot nl
15 years ago
In addition to "tk dot lists at fastmail dot fm"'s comment on Windows dependencies: You'll also need iconv.dll in your SYSTEM32 folder. At least, that's what I needed to get it working on my PHP4.2.3-Win install.
dennisNOSPAM at infoleak dot com
16 years ago
Building Sablotron on Solaris with.
gcc 3.0.3 and native linker
libtool (sunfreeware)
apache 1.3.24

When configuring Apache you might experience this error.. undefined reference to `operator new[](unsigned)' undefined reference to `__cxa_call_unexpected' undefined reference to `vtable for __cxxabiv1::__si_class_type_info' undefined reference to `operator delete(void*)' undefined reference to `__gxx_personality_v0' undefined reference to `vtable for __cxxabiv1::__class_type_info' undefined reference to `operator delete[](void*)' undefined reference to `vtable for __cxxabiv1::__vmi_class_type_info' undefined reference to `operator new(unsigned)'

To cure it make sure that during the configure stage you feed configure LDFLAGS variable like so.

LDFLAGS=' -lstdc++' ./configure

Otherwise Apache's compiler sanity check will balk.
To Top