Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> przechodzenie po kolekcji elementówo id pobranych z idrefs
adamb156
post 24.04.2013, 20:33:59
Post #1





Grupa: Zarejestrowani
Postów: 3
Pomógł: 0
Dołączył: 11.04.2013

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


Mam plik xml w którym w głównym elemencie mam elementy <książki> który zawiera książki i <autor> zawierający autorów.
Każdy autor ma atrybut id.
A każda książka ma jednego lub więcej autorów.
Autorzy Ci zdefiniowani są za pomocą atrybutu typu IDREFS zawierającego jeden lub kilka ID autorów.

  1. <xsl:key name="preg" match="autor" use="./@id"/>
  2. <xsl:template match="/">
  3. <html>
  4. <body>
  5. <table border="1">
  6. <tr bgcolor="#9acd32">
  7. <th>Tytuł</th>
  8. <th>Autor</th>
  9. </tr>
  10. <xsl:for-each select="//książki/książka">
  11. <tr>
  12. <td><xsl:value-of select="tytuł"/></td>
  13. <xsl:variable name="autorzy" select="@autorzy"/>
  14. <xsl:for-each select="str:tokenize($autorzy, ' ')" xmlns:str="http://exslt.org/strings">
  15. <td><xsl:value-of select="key('preg',./text())/@imie"/></td>
  16. </xsl:for-each>
  17. </tr>
  18. </xsl:for-each>
  19. </table>
  20. </body>
  21. </html>
  22. </xsl:template>
  23.  

w środku drugiego for-eacha kiedy w select jest poptostu "." to wypisuje mi te ID ale kiedy chcę wyciągnąć elementy a z nich atrybut imie to nic nie wyciąga.
Co robię źle?
Go to the top of the page
+Quote Post

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

 



RSS Wersja Lo-Fi Aktualny czas: 27.04.2024 - 15:42