Nodes set of the same type with if-test. Make it less.
Posted
by Kalinin
on Stack Overflow
See other posts from Stack Overflow
or by Kalinin
Published on 2010-06-11T12:03:02Z
Indexed on
2010/06/15
10:52 UTC
Read the original article
Hit count: 256
How to make the code more beautiful (compact)?
<xsl:template match="part">
<table class="part">
<xsl:if test="name != ''">
<tr>
<td>????????</td><td><xsl:value-of select="name"/></td>
</tr>
</xsl:if>
<xsl:if test="model != ''">
<tr>
<td>??????</td><td><xsl:value-of select="model"/></td>
</tr>
</xsl:if>
<xsl:if test="year != ''">
<tr>
<td>???</td><td><xsl:value-of select="year"/></td>
</tr>
</xsl:if>
<xsl:if test="glass_type != ''">
<tr>
<td>???</td><td><xsl:value-of select="glass_type"/></td>
</tr>
</xsl:if>
<xsl:if test="scancode != ''">
<tr>
<td>???????</td><td><xsl:value-of select="scancode"/></td>
</tr>
</xsl:if>
<xsl:if test="eurocode != ''">
<tr>
<td>???????</td><td><xsl:value-of select="eurocode"/></td>
</tr>
</xsl:if>
<xsl:if test="coment != ''">
<tr>
<td>???????????</td><td><xsl:value-of select="coment"/></td>
</tr>
</xsl:if>
<xsl:if test="glass_size != ''">
<tr>
<td>??????</td><td><xsl:value-of select="glass_size"/></td>
</tr>
</xsl:if>
<xsl:if test="vendor != ''">
<tr>
<td>?????????????</td><td><xsl:value-of select="vendor"/></td>
</tr>
</xsl:if>
<xsl:if test="trademark != ''">
<tr>
<td>???????? ?????</td><td><xsl:value-of select="trademark"/></td>
</tr>
</xsl:if>
<xsl:if test="fprice != ''">
<tr>
<td>????</td><td><xsl:value-of select="fprice"/></td>
</tr>
</xsl:if>
</table>
</xsl:template>
Update:
i wrote:
<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:value-of select="//w/@r"/>
And have no result from this code. Is it normal? And how can i get new element w
?
© Stack Overflow or respective owner