xslt遍历xml文件 怎么动态添加div的id值
xslt遍历xml文件 如何动态添加div的id值
本人现在需要遍历一个xml文件
需要遍历之后产生一个div
div中的id需要自动生成id id类似"tab1"/"tab2"/"tab3"....
希望高手帮忙解答
------解决方案--------------------
<xsl:for-each select="projects/project[position()<5]">
<div class="tab2" id="tab{position()}"> </div>
</xsl:for-each>
------解决方案--------------------
本人现在需要遍历一个xml文件
- XML code
<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="projects.xsl"?> <projects> <project> <Name>Project 1</Name> <ShortName></ShortName> <RepositoryHome></RepositoryHome> <CITarget></CITarget> <CheckStyleReport></CheckStyleReport> <PMDReport></PMDReport> <BuildSchedule></BuildSchedule> <TeamLead></TeamLead> <CCList></CCList> </project> <project> <Name>Project 2</Name> <ShortName></ShortName> <RepositoryHome></RepositoryHome> <CITarget></CITarget> <CheckStyleReport></CheckStyleReport> <PMDReport></PMDReport> <BuildSchedule></BuildSchedule> <TeamLead></TeamLead> <CCList></CCList> </project> </projects>
需要遍历之后产生一个div
- HTML code
<xsl:for-each select="projects/project[position()<5]"> <div class="tab2" id="@Id"> </div> </xsl:for-each>
div中的id需要自动生成id id类似"tab1"/"tab2"/"tab3"....
希望高手帮忙解答
------解决方案--------------------
<xsl:for-each select="projects/project[position()<5]">
<div class="tab2" id="tab{position()}"> </div>
</xsl:for-each>
------解决方案--------------------
- XML code
<xsl:for-each select="projects/project"> <div class="tab2"> <xsl:attribute name="id"> <xsl:value-of select="concat('tab',position())"/> </xsl:attribute> </div> </xsl:for-each>