Witam !

Mam bardzo ciekawy problem. Otoz mam zarejestrowana funkce php ktore wywoluje z xsl. Zwraca mi ona DOMDocument.
Wg dokumentacji php mozna zwrocic do XSL DOMDocument, jest to oczywiscie prawda, ale nie wiedziec czemu for-each na takim zbiorze wezlow
dziala jakby wogle ich nie bylo. Natomiast wypisanie wartosci za pomoca value-of zwraca string z wartosciami ktore trzymalem w przekazywanym DOMDocumencie.

  1. <xsl:stylesheet version='1.0'
  2. xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
  3. xmlns:x="http://www.w3.org/1999/xhtml"
  4. xmlns="http://xml.wikidot.org/wikiml"
  5. xmlns:php="http://php.net/xsl">
  6.  
  7. <xsl:template match="x:div">
  8.      <block>
  9.      <xsl:if test="boolean(string(@style))">
  10.            <xsl:for-each select="php:function('wikidot_style_parser', string(@style))/attr">  <!-- tu jak widac przekazuje funkce ktora zwraca mi node-set .-->
  11.                  <xsl:value-of select="key" />
  12.            </xsl:for-each>
  13.      </xsl:if>
  14.            <xsl:apply-templates />
  15.      </block>
  16. </xsl:template>
  17.  
  18.  
  19. </xsl:stylesheet>


A to funkcja ktora przekazuje.

  1. <?php
  2. function style_parser($cssString) {
  3. $parser = StyleStringParser();
  4. $parser->setAllowedGroups(array('all'));
  5. $attributes = $parser->parse($cssString);
  6. $xml = '<css>' ;
  7. foreach ($attributes as $key => $value) {
  8. $xml.= '<attr><key>'.$key.'</key><value>'.$value.'</value></attr>';
  9. }
  10. $xml.='</css>';
  11. $doc = new DOMDocument('1.0', 'UTF-8');
  12. $doc->loadXML($xml);
  13. return $doc;
  14. }
  15. ?>



Czy ktos ma pomysl jak ten problem rozwiazac ? :-)
Pozdrawiam.