tutorials.de Buch-Aktion 05/2012
RSS-Feed anzeigen

Stammtisch

XSL: dynamischer test-Ausdruck

Bewerten
von Sven Mintel am 06.08.10 um 03:09 (1454 Hits)
Ihr kennt das garantiert, euch schwirrt etwas durch den Kopf, was ihr uuuuuuunbedingt braucht, ihr sucht es tagelang, ihr fangt es an selbst zu schreiben, es wird aber murksig, ihr sucht nochmal, weil ihr euch nicht vorstellen könnt, dass es das nicht gibt.

Ihr findet wieder nichts, schmollt, die Tastatur ist schon arg gefährdet....ihr sucht nochmal uuuund:
Heureka, da isses

Heute hatte ich dies AHA-Erlebnis mal wieder.
Ich suchte nach einer Möglichkeit, einen dynamischen Ausdruck zu testen, also bspw. den Ausdruck aus einem Textknoten oder Attribut zu erstellen, evtl. sogar aus mehreren davon.

Da ich nichts fand, fing ich da an mit PHP-Hilfsmitteln, create_function, eval, Tokenizer....fand aber alles doof.

Da muss es doch was geben(zur Not nehm ich auch was von ratiopharm), ...und es gibt was

Was, will ich euch nicht vorenthalten, vielleicht benötigt es ja mal jemand von euch:

Zitat Zitat von kekoajs at yahoo dot com
Wow, I spent the better part of a day looking for how one could pass an entire test expression to an XSL stylesheet. It seems that the XSLT 1.0 specification doesn't support it but PHP 5 (and maybe 4s) inclusion of EXSLT allows one to do exactly that...

simply add these lines...

xmlns:dyn="http://exslt.org/dynamic"
extension-element-prefixes="dyn"

to the <xsl:stylesheet> element and when using an expression stored in a <xsl:param> element write

<xsl:if test="dyn:evaluate($param-name)">

and viola! you can now use expressions generated externally in your stylesheet!

EXSLT adds many useful functions that can be integrated into your XSL in a similar fashion. You can go to [url]http://exslt.org/[/url] to learn more...
http://www.php.net/manual/de/book.xsl.php#48416
http://exslt.org/dyn/functions/evaluate/index.html




.

"XSL: dynamischer test-Ausdruck" bei Twitter speichern "XSL: dynamischer test-Ausdruck" bei Facebook speichern

Kategorien
Programming , ‎ Webmaster , ‎ xml & xsl

Kommentare