Перейти из форума на сайт.

НовостиФайловые архивы
ПоискАктивные темыТоп лист
ПравилаКто в on-line?
Вход Забыли пароль? Первый раз на этом сайте? Регистрация
Компьютерный форум Ru.Board » Интернет » В помощь вебмастеру » XSL: отображение данных из одной таблицы в другой

Модерирует : Cheery

Cheery (15-05-2012 04:23): Перемещено в форум "Web-программирование"  Версия для печати • ПодписатьсяДобавить в закладки

   

BogdaniCH



Newbie
Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору
Мне нужно отобразить значение одной таблицы в другой таблице!!! Точнее вставить таблицу в таблицу.... вот коды:
 

Код:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output indent="yes" method="xml" media-type="text/xhtml" omit-xml-declaration="yes" />
 
    <xsl:template match="/data">
        <html>
    <title>q</title>
            <body>
                <xsl:apply-templates select="description"/>
                <hr/>
                <xsl:apply-templates select="record[@type='person']" mode="person"/>
                <hr/>
                <xsl:apply-templates select="record[@type='department']" mode="department"/>
            </body>
        </html>
    </xsl:template>
    <xsl:template match="description">
        <h1><center>
            <xsl:value-of select="caption"/>
        </center></h1>
        <h2>
            <xsl:value-of select="author"/>
            <br/>
            <i><xsl:value-of select="department"/></i>
        </h2>
    </xsl:template>
    <xsl:template match="record" mode="person">
        <table id="333" border="0" width="100%">
            <thead>
                <tr bgcolor="#dddddd"><xsl:if test="position() mod 2 = 0">
<xsl:attribute name="bgcolor">#CCCCCC</xsl:attribute>
</xsl:if>
                    <th>ID</th>
                    <th>Name</th>
                    <th>Salary</th>
                    <th>Department</th>
          <th>ID</th>
          <th>Name</th>
                </tr>
            </thead>
        <tbody>
                <xsl:apply-templates select="person">
                    <xsl:sort order="ascending" select="@departmentId"/>
                </xsl:apply-templates>
            </tbody>
        </table>
    </xsl:template>
    <xsl:template match="person">
        <xsl:param name="depId" select="@departmentId"/>
        <xsl:param name="depName" select="/data/record/department[@id=$depId]"/>
        <tr bgcolor="green" style="color:blue" onmouseover="this.style.color='red'" onmouseout="this.style.color='black'"><xsl:if test="position() mod 2 = 0">
<xsl:attribute name="bgcolor">"orange"</xsl:attribute>
</xsl:if>
            <td align="center"><xsl:value-of select="@id"/></td>
            <td align="center"><xsl:value-of select="name"/></td>
            <td align="center"><xsl:value-of select="salary"/></td>
            <td align="center"><a href="#id">
                <xsl:value-of select="$depName"/></a>
            </td>
            <td align="center">
                <xsl:value-of select="$depId"/>
            </td>
            <td align="center"><xsl:value-of select="$depName"/>
            </td>
        </tr>    
  </xsl:template>
   
   
   
    <xsl:template match="record" mode="department">
        <table border="25" width="100%">
            <thead>
                <tr bgcolor="#dddddd">
                    <th>ID</th>
          <th>Name</th>
          <th>Sum Salary</th>
        </tr>
            </thead>
            <tbody>
                <xsl:apply-templates select="department"/>
 
 
                        
                    
            
            </tbody>
        </table>
    </xsl:template>
    <xsl:template match="department">
        <tr style="color:blue" onmouseover="this.style.color='red'" onmouseout="this.style.color='black'"><xsl:if test="position() mod 2 = 0">
<xsl:attribute name="bgcolor">"orange"</xsl:attribute>
</xsl:if>
            <td align="center" border="20"><a name="id"><xsl:value-of select="@id"/></a></td>
            <td align="center"><xsl:value-of select="."/></td>
      <td align="center">
      <xsl:if test="@id=101">
          <xsl:value-of select="sum(//salary[../@departmentId='101'])"/>
        </xsl:if>
 
        <xsl:if test="@id=102">
          <xsl:value-of select="sum(//salary[../@departmentId='102'])"/>
        </xsl:if>
</td>
</tr>
<tr>
<xsl:if test="@id=101">
        <table align="center" border="5" bordercolor="orange" width="193%">
            <thead bgcolor="red">
<th align="center">ID</th>
<th align="center">Name</th>
<th align="center">Salary</th>
</thead>
<tbody>
<tr bgcolor="red">
<td align="center">444444</td>
<td align="center">11111111111</td>
<td align="center">2222222222</td>
</tr>
</tbody>
</table>
</xsl:if>
<xsl:if test="@id=102">
        <table align="center" border="5" bordercolor="orange" width="193%">
            <thead bgcolor="red">
<th align="center">ID</th>
<th align="center">Name</th>
<th align="center">Salary</th>
</thead>
<tbody>
<tr bgcolor="red">
<td align="center">444444</td>
<td align="center">11111111111</td>
<td align="center">2222222222</td>
</tr>
</tbody>
</table>
</xsl:if>
</tr>
</xsl:template>
</xsl:stylesheet>

 
 
 
 
Вот другой файл:
 

Код:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="t1.xsl"?>
<data>
    <description>
        <caption>Employees</caption>
        <author>Ivanova I.I.</author>
        <department>Personnel Department</department>
    </description>
    <record type='person'>
        <person id='1001' departmentId='101'>
            <name>Ivanova I.I.</name>
            <salary>1200</salary>
        </person>
        <person id='1002' departmentId='102'>
            <name>Petrova P.P.</name>
            <salary>1500</salary>
        </person>
        <person id='1003' departmentId='101'>
            <name>Sidorova S.S.</name>
            <salary>1100</salary>
        </person>
    </record>
    <record type='department'>
        <department id='101'>
            Personnel Department
        </department>
        <department id='102'>
            Analytics Department
        </department>
    </record>
</data>

 
 
 
Большое спасибо!!!!!!

Всего записей: 2 | Зарегистр. 15-05-2012 | Отправлено: 02:29 15-05-2012 | Исправлено: Cheery, 04:22 15-05-2012
   

Компьютерный форум Ru.Board » Интернет » В помощь вебмастеру » XSL: отображение данных из одной таблицы в другой
Cheery (15-05-2012 04:23): Перемещено в форум "Web-программирование"


Реклама на форуме Ru.Board.

Powered by Ikonboard "v2.1.7b" © 2000 Ikonboard.com
Modified by Ru.B0ard
© Ru.B0ard 2000-2024

BitCoin: 1NGG1chHtUvrtEqjeerQCKDMUi6S6CG4iC

Рейтинг.ru