Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [XSL] Zmiana wszystkich znaczników na HTMLowe
Sizix
post
Post #1





Grupa: Zarejestrowani
Postów: 4
Pomógł: 0
Dołączył: 23.02.2004

Ostrzeżenie: (0%)
-----


Mam dokument XML w którym używam tagu <nl /> jako określenia miejsca w ktorym ma byc przełamanie linii. Chciałbym za pomocą transformacji by wszystkie te tagi zostały zamienione na br / niezaleznie od miejsca w ktorym sie znajdują. Tj. zeby nie tworzyl petnli w kazdym wezle.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
MrMag
post
Post #2





Grupa: Zarejestrowani
Postów: 154
Pomógł: 5
Dołączył: 24.02.2004

Ostrzeżenie: (0%)
-----


topic stary ale aktualny (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)

probowalem na rozne sposoby ale ciagle cos jest nie tak:

Generalnie chce zamienic znaczniki w <text> </text> takie jak <p/> i <grin/> (pozniej bedzie wiecej) na znaczniki htmlowe.

Edycja: owszem, parsuje mi <text> i pojawia sie to co chce, ALE w miejscu gdzie mial byc text, drugi raz pojawiaja sie date i author a tego nie chce (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

struktura xml
  1. <document>
  2. <post>
  3. <author>Autor</author>
  4. <date>Data</date>
  5. <text>Jakis tekst hasdkhfjsdfhsjdf jfkjdkfg <grin/><p/>fgdfg d idfg df</text>
  6. </post>
  7.  
  8. <post>
  9. <author>Autor2</author>
  10. <date>Data2</date>
  11. <text>itp</text>
  12. </post>
  13. </document>


struktura xsl (tu pewnie bedzie syf bo dopiero zaczynam (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg) )
  1. <?xml version="1.0" encoding="ISO-8859-2" ?>
  2.  
  3. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  4. <xsl:output method="html"/>
  5.  
  6. <xsl:template match="/">  
  7.      <HTML><HEAD></HEAD>
  8.            <BODY>      
  9.                          <xsl:apply-templates />
  10.            </BODY>
  11.      </HTML>
  12. </xsl:template>
  13.  
  14. <xsl:template match="document" >
  15.      <table border="1" width="100%">
  16.      <tr><td colspan="2" align="</span>"><h2>tytul</h2></td></tr>
  17.            <xsl:apply-templates/>
  18.      </table>
  19. </xsl:template>
  20.  
  21. <xsl:template match="document/post/text" >
  22.      <xsl:apply-templates/>
  23. </xsl:template>
  24.  
  25. <xsl:template match="document/post">
  26. <tr>
  27.      <td width="115" align="center"><b><xsl:value-of select="author"/></b></td>
  28.      <td rowspan="2" valign="top"><xsl:apply-templates/></td>
  29. </tr>
  30. <tr>
  31.      <td valign="top"><small>
  32.            <xsl:value-of select="date"/></small><br/><div align="center">
  33.            <xsl:if test="author = 'A'"><img src="a.gif" alt="</span>" border="0"/></xsl:if>
  34.            <xsl:if test="author = 'B'"><img src="b.jpeg" alt="</span>" border="0"/></xsl:if>
  35.            <<<span style='color:blue'>span style='<span style='color:orange'>color:blue'>/div>
  36.      </td>
  37. </tr>
  38.  
  39. <tr>
  40.      <td colspan="2" align="center"><p>--------------------------------------------------------------------------</p></td>
  41. </tr>
  42.      
  43. </xsl:template>
  44.  
  45.  
  46. <xsl:template match="p">
  47.      <br/><br/>
  48. </xsl:template>
  49.  
  50. <xsl:template match="grin">
  51.      <img src="grin.gif" alt=""/>
  52. </xsl:template>
  53.  
  54. </xsl:stylesheet>


Ten post edytował MrMag 25.11.2005, 10:46:26
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 10.10.2025 - 03:08