【问题标题】:XSLT create hyperlink for umbraco form in contourXSLT 为轮廓中的 umbraco 形式创建超链接
【发布时间】:2012-06-14 16:15:55
【问题描述】:

Contour for Umbraco 带有一个工作流选项,可让您在用户提交表单后发送带有 XSLT 文件的电子邮件。

它带有这个示例:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="urn:my-scripts"
xmlns:umbraco.library="urn:umbraco.library"
exclude-result-prefixes="xsl msxsl user umbraco.library">

  <xsl:output method="html" media-type="text/html" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
  doctype-system="DTD/xhtml1-strict.dtd"
  cdata-section-elements="script style"
  indent="yes"
  encoding="utf-8"/>

  <xsl:param name="records" />

  <xsl:template match="/">

    <h3>Intro</h3>
    <p>
      Hello, this is a sample email using xslt to convert a record into a custom email
    </p>

    <h3>the fields</h3>
    <ul>
      <xsl:for-each select="$records//fields/child::*">
        <li>
          <h4>
            Caption: <xsl:value-of select="./caption"/>
          </h4>
          <p>
            <xsl:value-of select=".//value"/>
          </p>
        </li>
      </xsl:for-each>
    </ul>

    <h3>The actual xml</h3>
    <xsl:copy-of select="$records"/>

  </xsl:template>



</xsl:stylesheet>  

其中一个表单字段是简历的文件上传字段

如果我能输出正确的链接,我希望它。

字段名称是“上传简历”,目前类似这样的内容正在其发送的电子邮件中作为简单文本输出:

'/umbraco/plugins/umbracoContour/files/e105a66a-7478-4f95-95ad-d4da3190c6ce/d9e0087e-733b-4b4d-9b54-41d4aa979c11/mycv.pdf'

我如何重新调整这个 xslt,以便当它遇到“上传简历”字段时,它会创建一个超链接,而不仅仅是原始文本。

超链接的 href 最终会是这样的:

“http://www.example.com/umbraco/plugins/umbracoContour/files/e105a66a-7478-4f95-95ad-d4da3190c6ce/d9e0087e-733b-4b4d-9b54-41d4aa979c11/mycv.pdf”

【问题讨论】:

  • 您忘记提供源 XML 文档(请尽可能小)。要编写或修改转换,需要源 XML 文档和预期结果(加上对转换必须实现的要求的描述)。请编辑问题并提供这些。

标签: xml xslt xpath umbraco umbraco-contour


【解决方案1】:

您可以使用 XSLT when/otherwise 构造来检查这一点(我猜包含“/umbraco/plugins/umbracoContour/files/”的路径会这样做,然后您可以使用适当的值在锚标记中写入 -在 href 需要的地方附加 http:// 位。

http://www.w3schools.com/xsl/el_when.asp

http://www.w3schools.com/xsl/el_otherwise.asp

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-03-05
    • 2014-11-28
    • 1970-01-01
    • 2021-07-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多