|
|
|
значение переменной
|
|||
|---|---|---|---|
|
#18+
Почему значение переменной не сохраняется? <xsl:template name="pos"> <xsl:param name="pos" /> <xsl:for-each select="object "> <xsl:variable name="stroka2">2</xsl:variable> <xsl:if test="(position() +$pos) mod $stroka2 = 0"> <xsl:if test="@perenos!=0"> <xsl:choose> <xsl:when test="@perenos=1"> <perenos_position> <xsl:value-of select="$stroka2 -@perenos"/> </perenos_position> <xsl:call-template name="pos"> <xsl:with-param select="$pos +1" name="pos" /> </xsl:call-template> </xsl:when> <xsl:when test="@perenos=2"> <perenos_position> <xsl:value-of select="$stroka2 -@perenos"/> </perenos_position> <xsl:call-template name="pos"> <xsl:with-param select="$pos +2" name="pos" /> </xsl:call-template> </xsl:when> <xsl:when test="@perenos=3"> <perenos_position> <xsl:value-of select="$stroka2 -@perenos"/> </perenos_position> <xsl:call-template name="pos"> <xsl:with-param select="$pos +3" name="pos" /> </xsl:call-template> </xsl:when> </xsl:choose> </xsl:if> </xsl:if> </xsl:if> </xsl:for-each> </xsl:template> ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 26.02.2007, 11:49 |
|
||
|
значение переменной
|
|||
|---|---|---|---|
|
#18+
кому не охота разбираться я тут приуменьшил эту операцию: xml: <?xml version="1.0" encoding="UTF-16"?> <root > <object name="Уровня 2"></object> <object name="Привет" ></object> <object name="Документация" ></object> <object name="Сборка" ></object> </root> xslt: <?xml version="1.0" encoding="windows-1251" ?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <xsl:copy> <xsl:apply-templates select="node()"/> </xsl:copy> </xsl:template> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="/root"> <root> <xsl:call-template name="pos"> <xsl:with-param name="pos">0</xsl:with-param> </xsl:call-template> </root> </xsl:template> <xsl:template name="pos"> <xsl:param name="pos"></xsl:param> <xsl:for-each select="object"> <PRINT> <xsl:value-of select="@name"/> <xsl:text>,</xsl:text> <xsl:value-of select="$pos"/> <xsl:text> </xsl:text> </PRINT> <xsl:call-template name="pos"> <xsl:with-param name="pos" select="$pos +1"></xsl:with-param> </xsl:call-template> </xsl:for-each> </xsl:template> </xsl:stylesheet> ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 26.02.2007, 13:09 |
|
||
|
значение переменной
|
|||
|---|---|---|---|
|
#18+
может XSL:FOR-EACH сбивает параметры моей рекурсии? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 26.02.2007, 13:23 |
|
||
|
значение переменной
|
|||
|---|---|---|---|
|
#18+
понял что я вызываю шаблон раньше чем даю xsl-for each завершится... но как ещё я могу передать переменную в xsl: for-each ...? судя по всему никак. как тогда можно обегать элементы? в этом случае? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 26.02.2007, 16:38 |
|
||
|
значение переменной
|
|||
|---|---|---|---|
|
#18+
XSLT декларативный язык, переприсваивать значения переменны нельзя - рекурсию юзать, предвычисления и т.п. А если честно я так и не понял, что вы хотите получить - из упрощенного примера цель не видна, а с первым разбираться не охота ;-) Может словами напишите что хотели то ? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 26.02.2007, 17:23 |
|
||
|
значение переменной
|
|||
|---|---|---|---|
|
#18+
Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 27.02.2007, 13:08 |
|
||
|
|

start [/forum/topic.php?fid=14&fpage=65&tid=1334435]: |
0ms |
get settings: |
8ms |
get forum list: |
14ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
46ms |
get topic data: |
7ms |
get forum data: |
2ms |
get page messages: |
33ms |
get tp. blocked users: |
1ms |
| others: | 211ms |
| total: | 328ms |

| 0 / 0 |
