开发者

xsl concat function

I am having a hard time in printing an attribute in a tag using xsl. This is my input xml

<input>
   <subscriptons>
       <services>
          <service-info>
               First
          </service-info>
          <service-info>
               Second
          </service-info>
       </services>
   </subscriptons>
</input>

Now using XSL I am trying to convert the above xml to

<Main_Subscriptions elem="0">
    <M开发者_如何转开发ain_Services elem="0">
        First Service
    </Main_Services>
</Main_Subscriptions>
<Main_Subscriptions elem="1">
    <Main_Services elem="1">
       Second Service
    </Main_Services>
</Main_Subscriptions>

Using XSL I am able to get everything except the arguments elem="x", basically whenever I am trying to use " or < my xsl fails, e.g. this is what I am doing to get the Main_Subscriptions tag:

<xsl:value-of select="concat('&lt;Main_Subscriptions elem=&quot;', position(), '&quot;&gt;')" disable-output-escaping="yes" />

Any ideas why it is not working ?

Thanks !


you can simply use below code:

 <xsl:element name="Main_Subscriptions">
    <xsl:attribute name="elem">
       <xsl:value-of select="position()"/>
     </xsl:attribute>
</xsl:element>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜