在 contains 中嵌套 XSLT 函数子字符串

nesting XSLT functions substring within contains

我可以正常工作,但我想知道是否有办法将子字符串 fx 嵌套在 contains 函数中

XML:

<patientRole> 
    <telecom use="HP" value="tel:555-555-2004" />
    <telecom use="HP" value="mailto:aaeveryman@email.com" />

工作 XSLT:

<xsl:variable name="PtTelecom" select="ClinicalDocument/recordTarget/patientRole/telecom/@value"/>
<xsl:variable name="PtPhoneNumber" select="$PtTelecom[contains(., 'tel')]"/>
<xsl:variable name="PtPhoneNumberFormat" select="substring-after($PtPhoneNumber, 'tel:')"/>
<xsl:variable name="PtEmail" select="$PtTelecom[contains(., 'mailto')]"/>
<xsl:variable name="PtEmailFormat" select="substring-after($PtEmail, 'mailto:')"/>

它是否可以嵌套,比如我想要电话后的子串:如果它包含电话:

<xsl:variable name="PtPhoneNumber" select="substring-after(contains($PtTelecom, 'tel'), 'tel:')"/>
<xsl:variable name="PtEmail" select="substring-after(contains($PtTelecom, 'mailto'), 'mailto:')"/>

这 return 没有任何价值,所以我觉得 a) 它不能嵌套或 b) 我有问题。感谢任何帮助

所以,与其这样做...

<xsl:variable name="PtPhoneNumber" select="$PtTelecom[contains(., 'tel')]"/>
<xsl:variable name="PtPhoneNumberFormat" select="substring-after($PtPhoneNumber, 'tel:')"/>

这样做..

<xsl:variable name="PtPhoneNumberFormat" select="substring-after($PtTelecom[contains(., 'tel')], 'tel:')"/>

因此,您实际上是在用变量的声明替换变量的使用。当然,您现在可以使用不同的变量名....

<xsl:variable name="PtPhoneNumber" select="substring-after($PtTelecom[contains(., 'tel')], 'tel:')"/>

对于电子邮件也是如此..

<xsl:variable name="PtEmail" select="substring-after($PtTelecom[contains(., 'mailto')], 'mailto:')"/>