Project

General

Profile

Часто задаваемые вопросы » vais.xsl

Tatiana Zharkova, 04/10/2010 12:31

 
<?xml version="1.0" encoding="utf-8"?>
<!--
Rao report template file version 1.0
24 jan 2008
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:tractt="urn:www.tract.ru:digispot2:report-template" xmlns:tracts="urn:www.tract.ru:digispot2:report-script" xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" version="1.0">
<tractt:environment>
<tractt:fields>
<tractt:field name="report-start-date" type="time" subtype="date" title="Дата начала отчета" format="%d %B %Y" visible="0" />
<tractt:field name="report-end-date" type="time" subtype="date" title="Дата окончания отчета" format="%d %B %Y" visible="0" />
<tractt:field name="report-date" type="time" subtype="date" title="Дата отчета" format="%d.%m.%Y" />
<tractt:field name="attr-genre" type="string" title="Аттрибут:Жанр произведения" value="Genre" />
<tractt:field name="attr-genre-def" type="string" title="Жанр по умолчанию" value="Песня" />
<tractt:field name="attr-source" type="string" title="Аттрибут:источик заимствования" value="Source" />
<tractt:field name="attr-source-def" type="string" title="Источик по умолчанию" value="Фонотека радиостанции" />
</tractt:fields>
<tractt:source-template src="vais_hdr.xml" name="ehead" />
</tractt:environment>
<xsl:output method="xml" version="1.0" omit-xml-declaration="yes" indent="yes" />
<xsl:key name="artist_search" match="//tractt:tract-data//tractt:item" use="tractt:artist" />
<xsl:key name="title_search" match="//tractt:tract-data//tractt:item" use="concat(tractt:artist, '=&gt;', tractt:title)" />
<xsl:template match="/">
<xsl:processing-instruction name="mso-application">progid="Excel.Sheet"</xsl:processing-instruction>
<xsl:apply-templates select="//ss:Workbook" />
</xsl:template>
<!-- stubs -->
<xsl:template match="//ss:Table/@ss:ExpandedRowCount" />
<xsl:template match="//ss:Table/@ss:ExpandedColumnCount" />
<xsl:template match="//ss:Row/@ss:Index" />
<xsl:template match="//ss:Workbook">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="//ss:Styles">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
<Style ss:ID="TractLongHourTime">
<NumberFormat ss:Format="[h]:mm:ss" />
</Style>
<Style ss:ID="TractMmSsTime">
<NumberFormat ss:Format="mm:ss" />
</Style>
</xsl:copy>
</xsl:template>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="//ss:Data[starts-with(string(.),'tt:')]">
<xsl:copy>
<xsl:for-each select="@*">
<xsl:copy />
</xsl:for-each>
<xsl:value-of select="//tractt:header/*[local-name(.)=substring-after(current(),':')]" />
</xsl:copy>
</xsl:template>
<xsl:template match="//ss:Row[string(.//ss:Data)='tp:report-list']">
<!-- <xsl:copy-of select="." /> -->
<xsl:for-each select="//tractt:report-data/tractt:item[count( . | key('artist_search',tractt:artist)[1])=1]">
<!-- один раз для артиста. Контекст=первый item c таким артистом-->
<xsl:sort select="tractt:artist" />
<xsl:variable name="songs" select="key('artist_search',tractt:artist)" />
<xsl:variable name="artsongs" select="$songs[generate-id()=generate-id(key('title_search',concat(tractt:artist, '=&gt;', tractt:title))[1])]" />
<xsl:call-template name="songsofartist">
<xsl:with-param name="songs" select="$artsongs" />
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<xsl:template name="songsofartist">
<xsl:param name="songs" />
<xsl:for-each select="$songs">
<!-- Вызывается один раз для уникальной пары artist-title.
текущий узел - первый item с такими artist-title. -->
<xsl:sort select="tractt:title" />
<xsl:variable name="samesongs" select="key('title_search', concat(tractt:artist, '=&gt;', tractt:title))" />
<Row>
<Cell>
<Data ss:Type="String">
<xsl:for-each select="$samesongs">
<xsl:value-of select="tractt:playdate" />
<xsl:if test="position() != last()">
<xsl:text>, </xsl:text>
</xsl:if>
</xsl:for-each>
</Data>
</Cell>
<Cell>
<Data ss:Type="String">
<xsl:value-of select="tractt:title" />
</Data>
</Cell>
<Cell>
<Data ss:Type="String">
<xsl:value-of select="tractt:author" />
</Data>
</Cell>
<Cell ss:StyleID="TractMmSsTime" ss:Formula="=TIME(0,0,{number($samesongs[1]/tractt:playtime)})">
<Data ss:Type="DateTime">1899-12-31T00:00:00</Data>
</Cell>
<Cell>
<Data ss:Type="Number">
<xsl:value-of select="count($samesongs)" />
</Data>
</Cell>
<Cell ss:StyleID="TractLongHourTime" ss:Formula="=RC[-2]*RC[-1]">
<Data ss:Type="DateTime">1899-12-31T00:00:00</Data>
</Cell>
<Cell>
<Data ss:Type="String">
<xsl:variable name="genre" select="tractt:attr[@type=//tractt:header/*[local-name(.)='attr-genre'] ]" />
<xsl:choose>
<xsl:when test="count( $genre) != 0">
<xsl:value-of select="$genre" />
</xsl:when>
<xsl:otherwise><xsl:value-of select="//tractt:header/*[local-name(.)='attr-genre-def']" /></xsl:otherwise>
</xsl:choose>
</Data>
</Cell>
<Cell>
<Data ss:Type="String">
<xsl:value-of select="tractt:artist" />
</Data>
</Cell>
<Cell>
<Data ss:Type="String">
<xsl:variable name="srcname" select="tractt:attr[@type=//tractt:header/*[local-name(.)='attr-source'] ]" />
<xsl:choose>
<xsl:when test="count( $srcname) != 0">
<xsl:value-of select="$srcname" />
</xsl:when>
<xsl:otherwise><xsl:value-of select="//tractt:header/*[local-name(.)='attr-source-def']" /></xsl:otherwise>
</xsl:choose>
</Data>
</Cell>
<Cell>
<Data ss:Type="String">
<xsl:value-of select="tractt:publisher" />
</Data>
</Cell>
</Row>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
(5-5/13)
Add picture from clipboard (Maximum size: 742 MB)