I have a requirement where the xml might have one or more services (name might be different), and I am having a content which should have all of these available services from the xml something like below
<li><a href="#_cms">CMS</a></li>
<li><a href="#_dis">DIS</a></li>
but above I have hardcoded the a
tag content and href
since I know these are the values, but in real time I would not be knowing these names, so how to set href
and anchor tag contents
based on xml values?
So far I got the below for-each
statement, which gets me all the service names from the xml
<xsl:variable name="number">
<xsl:number/>
</xsl:variable>
<xsl:for-each select="csmclient/product/domainmetadata/domainmetadata_service">
<li><a href="#_ser{$number}"><xsl:value-of select="@name"/><xsl:value-of select="position()"/></a></li>
</xsl:for-each>
.
.
.
<!--far below end-->
<xsl:for-each select="domainmetadata/domainmetadata_service">
<h3>Service Name: <span style="color:#328aa4"><a name="_ser{$number}" href="#_top"><xsl:value-of select="@name"/></a></span></h3>
.
.
.
</xsl:for-each>
but it does not seem to work, it gives me all my services but the link does not work. Any other ideas?
Note: I took help from this question link which had a similar requirement.
Use something like below, should work
What you are trying to write is this (not discussing at all if this uniquely identifies the node):
There is a xslt function
generate-id()
which gives and unique textual identifier for any node in the xml.http://www.w3.org/TR/xslt#function-generate-id