【问题标题】:nesting XSLT functions substring within contains在 contains 中嵌套 XSLT 函数子字符串
【发布时间】:2018-10-11 19:38:55
【问题描述】:

我的工作正常,但我想知道是否有办法将子字符串 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:')"/>

它可以嵌套像我想要子字符串之后的东西吗 tel: 如果它包含 tel:

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

这没有返回任何值,所以我觉得a)它不能嵌套或b)我有问题。任何帮助表示赞赏

【问题讨论】:

    标签: xml function xslt nested contains


    【解决方案1】:

    所以,不要这样做......

    <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:')"/>
    

    【讨论】:

    • 谢谢蒂姆!我是如此接近......我一直在自学,所以我正在慢慢掌握它。感谢您的帮助:)
    猜你喜欢
    • 1970-01-01
    • 2012-12-03
    • 1970-01-01
    • 2012-09-06
    • 1970-01-01
    • 2013-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多