views:

50

answers:

3
<?xml version="1.0" encoding="windows-1251"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
<xsl:output method="html" indent="no" encoding="windows-1251"/>

<xsl:template match="/">
    <xsl:for-each select="document('')//w">
        <xsl:value-of select="@e"/>
    </xsl:for-each>
</xsl:template>

<my:translations xmlns:my="my:my">
    <w e="name" r="Название"/>
    <w e="model" r="Модель"/>
    <w e="year" r="Год"/>
    <w e="glass_type" r="Тип"/>
    <w e="scancode" r="Сканкод"/>
    <w e="eurocode" r="Еврокод"/>
    <w e="comment" r="Комментарий"/>
    <w e="glass_size" r="Размер"/>
    <w e="vendor" r="Производитель"/>
    <w e="trademark" r="Торговая марка"/>
    <w e="fprice" r="Цена"/>
</my:translations> 

</xsl:stylesheet>

I have no result. What the mistake?


Excuse my carelessness in the formulation of questions.

A: 

There should not be any problem. This stylesheet:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > 

<my:translations xmlns:my="my:my"> 
    <w e="name" r="Название"/> 
    <w e="model" r="Модель"/> 
    <w e="year" r="Год"/> 
    <w e="glass_type" r="Тип"/> 
    <w e="scancode" r="Сканкод"/> 
    <w e="eurocode" r="Еврокод"/> 
    <w e="comment" r="Комментарий"/> 
    <w e="glass_size" r="Размер"/> 
    <w e="vendor" r="Производитель"/> 
    <w e="trademark" r="Торговая марка"/> 
    <w e="fprice" r="Цена"/> 
</my:translations>  

<xsl:template match="/"> 
<root> 
<xsl:value-of select="count(document('')//w)"/>
</root> 
</xsl:template> 

</xsl:stylesheet> 

This is the result with any input:

<root>11</root>

Edit: With the new stylesheet you post, I get the expected result:

namemodelyearglass_typescancodeeurocodecommentglass_sizevendortrademarkfprice
Alejandro
@Alejandro, `count` function returns the result - 0.
Kalinin
@Kalinin: Did you run this transformation? I get the exact result. What processor did you use? Also, I don't understand your edit. What do you need?
Alejandro
@kalinin: We can't help you find the bug in your unpublished code.
Dimitre Novatchev
@Dimitre Novatchev, i publish whole my code.
Kalinin
@Alejandro, i take pause. i have to understand how is working our CMS.
Kalinin
A: 

The most probable problem -- in the code that you politely haven't shown -- is a probable default namespace.

If this is the case (beside that I am good at fortune-telling) this will mean that the solution will look like the following:

document('')//x:w

where the prefic x: is bound to your default namespace.

Dimitre Novatchev
A: 

Update: The OP has finally published his code. There is no problem in the code.

When the provided transformation:

<?xml version="1.0" encoding="windows-1251"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
<xsl:output method="html" indent="no" encoding="windows-1251"/>

<xsl:template match="/">
    <xsl:for-each select="document('')//w">
        <xsl:value-of select="@e"/>
    </xsl:for-each>
</xsl:template>

<my:translations xmlns:my="my:my">
    <w e="name" r="Название"/>
    <w e="model" r="Модель"/>
    <w e="year" r="Год"/>
    <w e="glass_type" r="Тип"/>
    <w e="scancode" r="Сканкод"/>
    <w e="eurocode" r="Еврокод"/>
    <w e="comment" r="Комментарий"/>
    <w e="glass_size" r="Размер"/>
    <w e="vendor" r="Производитель"/>
    <w e="trademark" r="Торговая марка"/>
    <w e="fprice" r="Цена"/>
</my:translations>

</xsl:stylesheet>

is run with 7 XSLT 1.0 processors and 2 XSLT 2.0 processors on any XML document (not used), all of them produce the same correct and wanted result:

namemodelyearglass_typescancodeeurocodecommentglass_sizevendortrademarkfprice
Dimitre Novatchev
@Dimitre Novatchev, I did not understand what was happening (what is my problem). perhaps this is because how we have formed the output document. No sense to make you suffer any longer. I have to understand how our CMS generates an output html. I take pause.
Kalinin