I
Ian Gibbs
Dear all,
I'd like to know in the following XML, when I am looping through the
server elements, how many of the previous servers had ldap-role values
of YES or MASTER.
<install-config>
<servers>
<server hostname="server1">
<ldap-role>NO</ldap-role>
</server>
<server hostname="server2">
<ldap-role>MASTER</ldap-role>
</server>
<server hostname="server3">
<ldap-role>YES</ldap-role>
</server>
</servers>
</install-config>
So for server 2, I want a value of 0, because there are 0 preceding
siblings that have ldap-role values of YES/MASTER, and a value of 1
for server3. I think everything I've tried hasn't worked because I
haven't quite grasped how what I want relates to the context node
(which I think is the server). Here's my XSLT:
<xsl:template match="install-config">
<install-config>
<servers>
<xsl:for-each select="servers/server"> <!-- for each server -->
<server>
<xsl:if test="ldap-role='MASTER' or ldap-role='YES'">
<ldap-role>
<instance-alias><xsl:value-of
select="insert-expression-here"/></instance-alias>
</ldap-role>
</xsl:if>
</server>
</xsl:for-each>
</servers>
</install-config>
</xsl:template>
Many thanks in advance for anybody's help.
Regards,
Ian Gibbs
I'd like to know in the following XML, when I am looping through the
server elements, how many of the previous servers had ldap-role values
of YES or MASTER.
<install-config>
<servers>
<server hostname="server1">
<ldap-role>NO</ldap-role>
</server>
<server hostname="server2">
<ldap-role>MASTER</ldap-role>
</server>
<server hostname="server3">
<ldap-role>YES</ldap-role>
</server>
</servers>
</install-config>
So for server 2, I want a value of 0, because there are 0 preceding
siblings that have ldap-role values of YES/MASTER, and a value of 1
for server3. I think everything I've tried hasn't worked because I
haven't quite grasped how what I want relates to the context node
(which I think is the server). Here's my XSLT:
<xsl:template match="install-config">
<install-config>
<servers>
<xsl:for-each select="servers/server"> <!-- for each server -->
<server>
<xsl:if test="ldap-role='MASTER' or ldap-role='YES'">
<ldap-role>
<instance-alias><xsl:value-of
select="insert-expression-here"/></instance-alias>
</ldap-role>
</xsl:if>
</server>
</xsl:for-each>
</servers>
</install-config>
</xsl:template>
Many thanks in advance for anybody's help.
Regards,
Ian Gibbs