Модераторы: diadiavova
  

Поиск:

Ответ в темуСоздание новой темы Создание опроса
> XSL: function, как использовать XSL: function 
:(
    Опции темы
dimi4
Дата 26.2.2009, 11:03 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 2
Регистрация: 25.2.2009

Репутация: нет
Всего: нет



Есть XSL шаблон. он не работает. Покажите, пожалуйста где ошибка.
Или выложите примеры с использованием xsl:function

<?xml version="1.0" encoding="windows-1251" ?>
<!--<xsl:transform  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:str="http://user.com/namespace" version="2.0" exclude-result-prefixes="str">-->
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:f="f:namespace" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="f">

<xsl:template match="/values">
    <div>
        <div align="right" ><img src="modules/Documents/reports/images/logo.png" /></div>    
        <p  align="center" style='text-align:center'>
            <b>
            <span style='font-size:14.0pt;line-height:115%'>Карточка входящего документа</span>
            </b>
        </p>
        <p  style='margin-bottom:6.0pt'>
            <span style="font-size:10.0pt;line-height:115%">Входящий документ:
            <span style="mso-tab-count:2">                 </span></span>
            <b style='mso-bidi-font-weight:normal'>
                <xsl:value-of select="vhodyaschiy_registracionnaya_kartochka_registracionniy_nomer"/></b>
            <span style='font-size:10.0pt;line-height:115%'></span>
        </p>
        <p  style='margin-bottom:6.0pt'>
            <span style='font-size:10.0pt;line-height:115%'>Зарегестрирован:
                <!--<xsl:variable name="date" select="vhodyaschiy_registracionnaya_kartochka_data_ot"/>-->
                <xsl:value-of select="vhodyaschiy_registracionnaya_kartochka_data_ot"/>
                <!--<xsl:value-of select="str:timestampTodate($date)"/>-->
            </span>
        </p>    
        <p style='margin-bottom:6.0pt'>
            <span style='font-size:10.0pt;line-height:115%'>Адресат:            
                <xsl:for-each select="vhodyaschiy_registracionnaya_kartochka_komu/grid/row">
                    <b>
                        <xsl:value-of select="text"/>
                    </b>
                    <xsl:text> &#xA0; </xsl:text>
                </xsl:for-each>
            </span>
        </p>
        
        <p style='margin-bottom:6.0pt'>
            <span style='font-size:10.0pt;line-height:115%'>Отправители:            
                <xsl:for-each select="vhodyaschiy_registracionnaya_kartochka_otpraviteli/grid/row">                    
                    <xsl:value-of select="organizacija"/> (<xsl:value-of select="sotrudnik"/>)<xsl:text>&#xA0;</xsl:text>                    
                </xsl:for-each>
            </span>
        </p>
        
        <p style='margin-bottom:6.0pt'>
            <span style='font-size:10.0pt;line-height:115%'>Исходящий отправителя:            
                <span style='mso-tab-count:3'></span>
                <b style='mso-bidi-font-weight:normal'>
                    <xsl:value-of select="vhodyaschiy_registracionnaya_kartochka_ishodyaschiy_nomer"/>
                </b>    
            </span>
        </p>        
        <p style='margin-bottom:6.0pt'>
            <span style='font-size:10.0pt;line-height:115%'>Вид документа:
                <xsl:value-of select="vhodyaschiy_registracionnaya_kartochka_vid_normativnogo_dokumenta"/>
            </span>
        </p>
        <p style='margin-bottom:6.0pt'>
            <span style='font-size:10.0pt;line-height:115%'>Вид доставки:
                <xsl:value-of select="vhodyaschiy_registracionnaya_kartochka_vid_dostavki"/>
            </span>
        </p>
        <p style='margin-bottom:6.0pt'>
            <span style='font-size:10.0pt;line-height:115%'>Кол-во листов:
                <xsl:value-of select="vhodyaschiy_registracionnaya_kartochka_kolichestvo_stranic"/>
            </span>
        </p>
        <p style='margin-bottom:6.0pt'>
            <span style='font-size:10.0pt;line-height:115%'>документы-основание:
                <xsl:for-each select="vhodyaschiy_registracionnaya_kartochka_formirovat_svyazki/grid/row">
                    <xsl:value-of select="ieName"/><xsl:text>&#xA0;</xsl:text>
                </xsl:for-each>
            </span>
        </p>
        <p style='margin-bottom:6.0pt'>
            <span style='font-size:10.0pt;line-height:115%'>Производние документы:
                <xsl:for-each select="vhodyaschiy_registracionnaya_kartochka_pokazat_svyazki/grid/row">
                    <xsl:value-of select="ieName"/><xsl:text>&#xA0;</xsl:text>    
                </xsl:for-each>
            </span>
        </p>
        
        <p  style='margin-bottom:6.0pt'>
        <table cellpadding="0" cellspacing="0">
        <tr>
        <td width="100pt" style="white-space:nowrap; vertical-align:top" >
            <span style='font-size:10.0pt'>Краткое содержание:<xsl:text>&#xA0;</xsl:text></span>
        </td>
        <td width="100%" height="99" bgcolor="white" style="border:.75pt solid black;vertical-align:top;background:white">            
            <table cellpadding="0" cellspacing="0" width="100%">
            <tr>            
            <td>
                <div style="padding:4.35pt 4.35pt 4.35pt 4.35pt">
                <!--    <p> -->
                        <xsl:value-of select="vhodyaschiy_registracionnaya_kartochka_soderzhanie_dokumenta"/>
                <!--    </p>  -->
                </div>            
            </td>
            </tr>
            </table>            
        </td>
        </tr>
        </table>        
        </p>

        <p><span style='font-size:10.0pt;line-height:115%'></span></p>

        <p><span style='font-size:10.0pt;line-height:115%'></span></p>

        
        <p style='margin-top:12.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm'>
            <b style='mso-bidi-font-weight:normal'>
            <span style='font-size:12.0pt;line-height:115%'>Резолюции</span>
            </b>
        </p>
        <table border="1" cellspacing="0" cellpadding="0"    style="margin-left:4.35pt;border-collapse:collapse;border:none;mso-border-alt:
            solid windowtext .5pt;mso-padding-alt:0cm 5.4pt 0cm 5.4pt;mso-border-insideh:.5pt solid windowtext;mso-border-insidev:.5pt solid windowtext">
        <tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes;height:33.75pt'>
            <td width="96" valign="top" style="width:71.95pt;border:solid windowtext 1.0pt;    mso-border-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt;height:33.75pt">
                <p align="center" style="text-align:center">
                <span style="font-size:10.0pt;line-height:115%">автор<br/> резолюции</span>
                </p>
            </td>
            <td width="75" valign="top" style="width:56.4pt;border:solid windowtext 1.0pt;border-left:none;mso-border-left-alt:solid windowtext .5pt;mso-border-alt: solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt;height:33.75pt">
                <p align="center" style="text-align:center">
                <span style="font-size:10.0pt;line-height:115%">Дата</span>
                </p>
            </td>
            <td width="113" valign="top" style="width:3.0cm;border:solid windowtext 1.0pt;border-left:none;mso-border-left-alt:solid windowtext .5pt;mso-border-alt:      solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt;height:33.75pt">
                <p align="center" style="text-align:center">
                <span style='font-size:10.0pt;line-height:115%'>Исполнитель,<br/>соисполнгители</span></p>
            </td>
            <td width="246" valign="top" style="width:184.55pt;border:solid windowtext 1.0pt; border-left:none;mso-border-left-alt:solid windowtext .5pt;mso-border-alt:      solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt;height:33.75pt">
                <p align="center" style="text-align:center">
                <span style="font-size:10.0pt;line-height:115%">Содержание</span>
                </p>
            </td>
            <td width="85" valign="top" style="width:63.8pt;border:solid windowtext 1.0pt; border-left:none;mso-border-left-alt:solid windowtext .5pt;mso-border-alt:      solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt;height:33.75pt">
                <p align="center" style="text-align:center">
                <span style="font-size:10.0pt;line-height:115%">Плановая<br/>дата</span></p>
            </td>
        </tr>    
        <xsl:for-each select="vhodyaschiy_rezolyucii_i_zadaniya_rezolyucii_all/grid/row">   
        <tr style="page-break-inside:avoid;height:25.1pt">
            <td width="149" valign="top"  style="border-top:none;border-left:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;border-bottom:solid windowtext 1.0pt;  padding:0cm 5.4pt 0cm 5.4pt;height:25.1pt">
                <p style="text-align:justify;text-justify:inter-ideograph">
                    <span  style="font-size:11.0pt">
                    <xsl:variable  name="var" select="avtor"/>
                    <xsl:if test="string-length(normalize-space($var))>0">  
                        <xsl:value-of select="avtor"/>
                    </xsl:if>
                    <xsl:if test="string-length(normalize-space($var))=0">
                    <xsl:text> &#xA0; </xsl:text>
                    </xsl:if>
                    </span>
                    </p>
            </td>
            <td width="149" valign="top" style="width:111.75pt;border-top:none;border-left:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;border-bottom:solid windowtext 1.0pt;  padding:0cm 5.4pt 0cm 5.4pt;height:25.1pt">
                            <p  style="text-align:justify;text-justify:inter-ideograph">
                                <span  style="font-size:11.0pt">
                                <xsl:variable  name="var" select="data"/>
                                    <xsl:if test="string-length(normalize-space($var))>0">  
                                        <xsl:value-of select="data"/>
                                    </xsl:if>
                                    <xsl:if test="string-length(normalize-space($var))=0">
                                    <xsl:text> &#xA0; </xsl:text>
                                    </xsl:if>
                                </span>    
                            </p>                              
            </td>
            <td width="161" valign="top" style="width:120.45pt;border-top:none;border-left:  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;  padding:0cm 5.4pt 0cm 5.4pt;height:25.1pt">
                            <p style="text-align:justify;text-justify:inter-ideograph">
                                <span  style="font-size:11.0pt"><b>
                                    <xsl:variable  name="var" select="punkty/array/obj/rezoluciya_otvetstvennie/array/obj/text"/>
                                    <xsl:if test="string-length(normalize-space($var))>0">  
                                        <xsl:value-of select="punkty/array/obj/rezoluciya_otvetstvennie/array/obj/text"/>,<br/>
                                        <xsl:value-of select="punkty/array/obj/rezoluciya_soispolniteli_arr/array/obj/text"/>
                                    </xsl:if>
                                    <xsl:if test="string-length(normalize-space($var))=0">
                                    <xsl:text> &#xA0; </xsl:text>
                                    </xsl:if>
                                </b></span>
                            </p>
            </td>
            <td width="331" valign="top" style="width:248.1pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;  padding:0cm 5.4pt 0cm 5.4pt;height:25.1pt">
                              <p style="text-align:justify;text-justify:inter-ideograph">
                              <span  style="font-size:11.0pt">
                                <xsl:variable  name="var" select="ko_vsem_punktam"/>
                                    <xsl:if test="string-length(normalize-space($var))>0">  
                                        <xsl:value-of select="ko_vsem_punktam"/>
                                    </xsl:if>
                                    <xsl:if test="string-length(normalize-space($var))=0">
                                    <xsl:text> &#xA0; </xsl:text>
                                    </xsl:if>                              
                              </span></p>
            </td>
            <td width="85" valign="top" style="width:63.75pt;border-top:none;border-left:  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;  padding:0cm 5.4pt 0cm 5.4pt;height:25.1pt">
                              <p style="text-align:justify;text-justify:inter-ideograph">
                              <span style="font-size:11.0pt">
                                <xsl:variable  name="var" select="punkty/array/obj/rezoluciya_data_planovaya"/>
                                    <xsl:if test="string-length(normalize-space($var))>0">
                                        <xsl:value-of select="punkty/array/obj/rezoluciya_data_planovaya"/>
                                        
                                    </xsl:if>
                                    <xsl:if test="string-length(normalize-space($var))=0">
                                    <xsl:text> &#xA0; </xsl:text>
                                    </xsl:if>
                              </span>
                              </p>
            </td>
            </tr>                
        </xsl:for-each>
        </table>
        
        <p><span style='font-size:10.0pt;line-height:115%'></span></p>    
        <p>
            <span style='font-size:10.0pt;line-height:115%'>Закрыт:
            <xsl:value-of select="vhodyaschiy_registracionnaya_kartochka_zakryt"/></span>
        </p>
        <p>
            <span style='font-size:10.0pt;line-height:115%'></span>
        </p>
    </div>
</xsl:template>

<xsl:function name="f:timestampTodate">
    <xsl:param name="date"/>
    <xsl:result select="$date"/>
</xsl:function>

</xsl:stylesheet>
<!--</xsl:transform>-->
PM MAIL   Вверх
lemonade
Дата 26.2.2009, 15:15 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 20
Регистрация: 7.12.2006
Где: Беларусь, Минск

Репутация: нет
Всего: 2



вот пример, работает под saxon 9
Код

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="2.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:litems="http://www.litems.com/functions">

  <xsl:output method="text" encoding="UTF-8" media-type="text/plain"/>
  <xsl:strip-space elements="*"/>
  <!--========================================-->
  <!--global scope variables -->
  <!--========================================-->
  
  <!--Punctuation-->
  <xsl:variable name="symbols">
    <dquotesb value="“">"</dquotesb>
    <dquotese value="”">"</dquotese>
    <quotesb value="‘">'</quotesb>
    <quotese value="’">'</quotese>
    <bdef value="—">--</bdef>
    <def value="–">-</def>
    <mult value="×">x</mult>
    <tm value="™">(tm)</tm>
    <r value="®">(r)</r>
    <c value="©">(c)</c>
  </xsl:variable>
  <!--========================================-->
  <!--Temlpates-->
  <!--========================================-->
  <xsl:template match="/">
    <xsl:apply-templates/>
  </xsl:template>
 
  <!--Apply punctuation to plain test-->
  <xsl:template match="text()">
    <xsl:value-of select="litems:punct(.,1)"/>
  </xsl:template>
 
  <!--========================================-->
  <!--functions-->
  <!--========================================-->
  <xsl:function name="litems:punct">
    <xsl:param name="what"/>
    <xsl:param name="n"/>
    <xsl:value-of select="if($n &lt; count($symbols/*)) then 
     litems:punct(replace($what,$symbols/*[$n]/@value, $symbols/*[$n]),number($n)+1)
     else $what"/>
  </xsl:function>
</xsl:stylesheet>
                      

PM MAIL ICQ Skype   Вверх
lemonade
Дата 27.2.2009, 04:23 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 20
Регистрация: 7.12.2006
Где: Беларусь, Минск

Репутация: нет
Всего: 2



блин, тупинг
http://www.w3.org/TR/xslt20/#element-syntax-summary
 <xsl:result/> такого тега нет, смени на value-of = заработает

Это сообщение отредактировал(а) lemonade - 27.2.2009, 04:25
PM MAIL ICQ Skype   Вверх
dimi4
Дата 4.3.2009, 14:09 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 2
Регистрация: 25.2.2009

Репутация: нет
Всего: нет



Спасибо всем за помощь. Наконецто я разобоался.Решил след образом
php-------------------------
$filename="modules/Documents/template/in.xsl";
            if(file_exists($filename)){
                $handle=fopen($filename,"r");
                $XSL= fread($handle, filesize($filename));
                fclose($handle);
            }            
            $xml = new DOMDocument;
            $res = $xml->loadXML($data);
            $xsl = new DOMDocument;
            $res = $xsl->loadXML($XSL);
            $proc = new XSLTProcessor;
            $proc->registerPHPFunctions();
            $res = $proc->importStyleSheet($xsl); // attach the xsl rules                        
            $html=$proc->transformToXML($xml);
xsl------------------------------------------------------------------
<?xml version="1.0" encoding="windows-1251" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  xmlns:php="http://php.net/xsl">
<xsl:output method="html" indent="yes" /> 
........
<xsl:value-of select="php:function('date','d.m.Y',number(vhodyaschiy_registracionnaya_kartochka_data_ot))"/>
........
PM MAIL   Вверх
  
Ответ в темуСоздание новой темы Создание опроса
Правила форума "XML/XSLT"
diadiavova

Прежде чем опубликовать вопрос, попробуйте воспользоваться поиском - возможно тема уже поднималась.

Также рекомендуем Вам зайти в раздел FAQ ,раздел дополняется и, возможно, там вы увидите готовое решение.

Для ответов на часто задаваемые вопросы существует FAQ раздела. Новости можно публиковать в разделе новостей. Для статей так же есть специальный раздел

Желаем удачи в Вашем деле!


Если Вам понравилась атмосфера форума, заходите к нам чаще! С уважением, diadiavova.

 
1 Пользователей читают эту тему (1 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | XML, XSL | Следующая тема »


 




[ Время генерации скрипта: 0.0758 ]   [ Использовано запросов: 20 ]   [ GZIP включён ]


Реклама на сайте     Информационное спонсорство

 
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности     Powered by Invision Power Board(R) 1.3 © 2003  IPS, Inc.