But before that we have to check if the attibute i.e "use" is present or not. this can be done using the If conditional statement.
So, the full code for this is :
<xsl:if test="patient/telecom[@use]"> ---> checking whether the attribute is present or absent
<xsl:value-of select="patient/telecom/@value"/> ---> get the value of telecom tag i.e phone number
</xsl:if>
In the above example the tag in the XML file is used once but if the tag is repeated more than one times or if the parent element may be different means instead pf patient/telecom, if we have person/telecom or student/telecom or physician/telecom etc. then instead of writing four times (for patient, person, student, physician) we create one function and pass that value and change the path in select clause. Here in xsl file the function is called as template.
<xsl:if test="patient/telecom[@use]">
<xsl:call-template name="getTelecom"> --->Call the getTelecom function
<xsl:with-param name="telecom" select="patient/telecom[@use]"/>
</xsl:call-template>
</xsl:if>
The following code for template calling.
<xsl:call-template name="getTelecom">
<xsl:with-param name="telecom" select="patient/telecom"/>
</xsl:call-template>
To use the email address see the code below:
<xsl:for-each select="patient/telecom/@value">
<xsl:variable name="telecomPrefix" select="substring(.,1,7)"></xsl:variable>
<xsl:if test="$telecomPrefix = 'mailto:'">
<xsl:value-of select="substring(.,8)"/>
</xsl:if>
</xsl:for-each>