XSLT Функции
Содержание
- xslt_backend_info — Returns the information on the compilation settings of the backend
- xslt_backend_name — Returns the name of the backend
- xslt_backend_version — Returns the version number of Sablotron
- xslt_create — Create a new XSLT processor
- xslt_errno — Returns an error number
- xslt_error — Returns an error string
- xslt_free — Free XSLT processor
- xslt_getopt — Get options on a given xsl processor
- xslt_process — Perform an XSLT transformation
- xslt_set_base — Set the base URI for all XSLT transformations
- xslt_set_encoding — Set the encoding for the parsing of XML documents
- xslt_set_error_handler — Set an error handler for a XSLT processor
- xslt_set_log — Set the log file to write log messages to
- xslt_set_object — Sets the object in which to resolve callback functions
- xslt_set_sax_handler — Set SAX handlers for a XSLT processor
- xslt_set_sax_handlers — Set the SAX handlers to be called when the XML document gets processed
- xslt_set_scheme_handler — Set Scheme handlers for a XSLT processor
- xslt_set_scheme_handlers — Set the scheme handlers for the XSLT processor
- xslt_setopt — Set options on a given xsl processor
[an error occurred while processing the directive]
Коментарии
Building Sablotron on Solaris with.
gcc 3.0.3 and native linker
libtool (sunfreeware)
apache 1.3.24
php-4.2.1
sablotron-0.90
expat-1.95.2
When configuring Apache you might experience this error..
libsablot.so: undefined reference to `operator new[](unsigned)'
libsablot.so: undefined reference to `__cxa_call_unexpected'
libsablot.so: undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
libsablot.so: undefined reference to `operator delete(void*)'
libsablot.so: undefined reference to `__gxx_personality_v0'
libsablot.so: undefined reference to `vtable for __cxxabiv1::__class_type_info'
libsablot.so: undefined reference to `operator delete[](void*)'
libsablot.so: undefined reference to `vtable for __cxxabiv1::__vmi_class_type_info'
libsablot.so: 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.
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.
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.
Another way to get around the EXPAT-SABLOTRON problems (seg faults) is supposedly to recompile apache with:
--disable-rule=EXPAT
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.
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" [http://www.gingerall.org/sablotron.html]
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.
<?php
$xml = $input_dom->saveXML();
$xml = str_replace('&', '[AMP]', $xml);
$input_dom->loadXML($xml);
$xml = $xsl->transformToXML($input_dom);
$xml = str_replace('[AMP]', '&', $xml);
$output_dom->loadXML($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.
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="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="no"/>
<!-- XSL file based on example on php.net by tom@kornack.com -->
<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:when>
<xsl:otherwise>
<xsl:value-of select="concat('_',$n1,'_')"/>
</xsl:otherwise>
</xsl:choose></xsl:variable>
<xsl:element name="{$pName}">
<xsl:apply-templates select="following-sibling::*[1]"/>
</xsl:element>
</xsl:for-each>
</xsl:template>
<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:element></xsl:for-each>
</xsl:template>
<xsl:template match="string|integer|real|date|data">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="true|false">
<xsl:value-of select="name()"/>
</xsl:template>
<xsl:template match="text()|@*">
</xsl:template>
</xsl:transform>
How to make a XSLT Side with function
<code>
<xsl:output method="xhtml"/>
<xsl:template match="/">
<html>
<head><title>Ausgabe</title></head>
<body>
<xsl:apply-templates select="aktien/aktie"></xsl:apply-templates>
</body>
</html>
</xsl:template>
<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')" />
</xsl:if>
</xsl:template>
</xsl:stylesheet>
</code>