27-01-2012, 04:50
Witam wszystkich
piszę gdyż napotkałem na pewien problem podczas tworzenia stylów xsl, liczę na waszą pomoc poniżej
plik xml
plik xsl
Problem polega na tym że wyświetla mi się tylko nazwa firmy i Testowa struktura firmy na szarym tle. Nie mam pomysłu czemu nie chce pojawić się reszta. Poniżej zamieszczę jeszcze
plik dtd

plik xml
Kod:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="przyklad.xsl"?>
<firma:firma xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schematLocation="www.polciu.com.pl. przyklad.dtd"
xmlns:firma="http://www.polciu.com.pl/">
<firma:nazwa> Polciu </firma:nazwa>
<firma:dyrektor imie="aaaa" nazwisko="bbbb">
<firma:wicedyrektor imie="cccc" nazwisko="ffff">
</firma:wicedyrektor>
</firma:dyrektor>
</firma:firma>
plik xsl
Kod:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:firma="http://www.polciu.com.pl/">
<xsl:template match="/">
<html>
<body>
<title>
<xsl:value-of select="firma:firma/firma:nazwa"/>
</title>
<style>
body {font-family:Verdana, Arial, helvetica, sans-serif; font-size:large; }
</style>
</body>
<body style ="background-color:#EEEEEE">
<center>
<h2>
<xsl:value-of select="firma:firma/firma:nazwa"/>
</h2>
<p>
<h3>Testowa struktura firmy</h3>
</p>
</center>
<xsl:value-of select="firma:firma/firma:dyrektor"/>
</body>
</html>
</xsl:template>
<xsl:template match="firma:dyrektor">
<SPAN STYLE="background-color:#FF5000; color:white; padding:4px">
<SPAN STYLE="font-weight:bold; color:white">
Dyrektor:
<xsl:value-of select="@imie"/> <xsl:value-of select="@nazwisko"/>
</SPAN>
</SPAN>
<xsl:apply-templates select="firma:wicedyrektor"/>
</xsl:template>
<xsl:template match="firma:wicedyrektor">
<DIV STYLE="background-color:#0B610B; color:green; padding:20px">
Wicedyrektor:
<SPAN STYLE="font-weight:bold; color:white">
<xsl:value-of select="@imie"/> <xsl:value-of select="@nazwisko"/>
</SPAN>
</DIV>
</xsl:template>
</xsl:stylesheet>
plik dtd
Kod:
<!ELEMENT firma:dyrektor ( firma:wicedyrektor ) >
<!ATTLIST firma:dyrektor imie NMTOKEN #REQUIRED >
<!ATTLIST firma:dyrektor nazwisko NMTOKEN #REQUIRED >
<!ELEMENT firma:firma ( firma:nazwa, firma:dyrektor ) >
<!ATTLIST firma:firma xmlns:firma CDATA #REQUIRED >
<!ATTLIST firma:firma xmlns:xsi CDATA #REQUIRED >
<!ATTLIST firma:firma xsi:schematLocation CDATA #REQUIRED >
<!ELEMENT firma:nazwa ( #PCDATA ) >
<!ELEMENT firma:wicedyrektor EMPTY >
<!ATTLIST firma:wicedyrektor imie NMTOKEN #REQUIRED >
<!ATTLIST firma:wicedyrektor nazwisko NMTOKEN #REQUIRED >