xml - XSLT - Substitute code for string -


i'm working on xslt inside program , uses xml 1.0. so, because it's inside program can't use other languages this. in program can select options data i'm not been able xslt. code this:

<!-- md_dataidentification.topiccategory--> <div class="iteminfo">        <span style="color: black; font-size: 13;">        <span style="color: black; font-size: 15; font-weight:bold;">categoria temática:<br /></span>     <xsl:choose>         <xsl:when test="/metadata/dataidinfo[1]/tpcat/topiccatcd[(. != '001') , (. != '002') , (. != '003') , (. != '004') , (. != '005') , (. != '006') , (. != '007') , (. != '008') , (. != '009') , (. != '010')]">             <xsl:for-each select="/metadata/dataidinfo[1]/tpcat/topiccatcd[(. != '001') , (. != '002') , (. != '003') , (. != '004') , (. != '005') , (. != '006') , (. != '007') , (. != '008') , (. != '009') , (. != '010')]">                 <xsl:value-of select="."/>                 <xsl:if test="not(position()=last())">, </xsl:if>             </xsl:for-each>         </xsl:when>         <xsl:otherwise>             <span class="nocontent">no information (mandatory)</span>         </xsl:otherwise>         </xsl:choose>     </span> </div> 

the answer 'for-each' number of blank space itens select. wanna associate code de information represents. 001 = farming, 002 = biologic, 003 = economic, , on. can me this? how can force xslt show name of code? try code doesnt work:

    <xsl:choose>         <xsl:when test="/metadata/dataidinfo[1]/tpcat/topiccatcd[(. != '001') , (. != '002') , (. != '003') , (. != '004') , (. != '005') , (. != '006') , (. != '007') , (. != '008') , (. != '009') , (. != '010')]">         <xsl:if test="/metadata/dataidinfo[1]/tpcat/topiccatcd[(. != '001')]">          farming |         </xsl:if>            <xsl:if test="/metadata/dataidinfo[1]/tpcat/topiccatcd[(. != '002')]">          biologic |         </xsl:if>            <xsl:if test="/metadata/dataidinfo[1]/tpcat/topiccatcd[(. != '003')]">         boundaries |         </xsl:if>         <xsl:if test="/metadata/dataidinfo[1]/tpcat/topiccatcd[(. != '004')]">         atmospheric |         </xsl:if>         <xsl:if test="/metadata/dataidinfo[1]/tpcat/topiccatcd[(. != '005')]">         economy |         </xsl:if>        </xsl:when>        </xsl:choose> 

but when use receive names not importing if select or not. if me i'll grateful. :)


i have question too. in < (. != '004') >, point meaning? thanks!

it difficult answer question because did not provide context or expected output. in general, given input this:

xml

<root>     <code>001</code>     <code>002</code>     <code>003</code>     <code>004</code>     <code>005</code> </root> 

and stylesheet:

xslt 1.0

<xsl:stylesheet version="1.0"  xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:output method="html" encoding="utf-8"/>  <xsl:template match="/root">     <div>         <xsl:for-each select="code">             <xsl:choose>                 <xsl:when test=". = '001'">farming</xsl:when>                 <xsl:when test=". = '002'">biologic</xsl:when>                 <xsl:when test=". = '003'">economic</xsl:when>                 <xsl:otherwise>                     <span class="nocontent">no information (mandatory)</span>                 </xsl:otherwise>             </xsl:choose>             <xsl:if test="position() != last()">, </xsl:if>         </xsl:for-each>     </div> </xsl:template>  </xsl:stylesheet> 

the result be:

<div>farming, biologic, economic, <span class="nocontent">no information (mandatory)</span>, <span class="nocontent">no information (mandatory)</span></div> 

Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -