【问题标题】:Need to remove '#" symbol when it is come at the end of the link链接末尾的“#”符号需要删除
【发布时间】:2017-02-27 05:44:35
【问题描述】:

当超链接末尾出现“#”符号时,我想删除它。

我的输入 xml 是:

<Uri>http://www.tneb.nih.gov/lifeafter#</Uri>

XSL 我用作:

   <xsl:template match="Uri">
      <xref format="html" href="{.}" outputclass="">
         <xsl:value-of select="."/>
      </xref>
   </xsl:template>

我得到的输出为:

<xref format="html"
               href="http://www.tneb.nih.gov/lifeafter#"
               outputclass="">http://www.tneb.nih.gov/lifeafter#</xref>

预期输出:

<xref format="html"
               href="http://www.tneb.nih.gov/lifeafter"
               outputclass="">http://www.tneb.nih.gov/lifeafter#</xref>

我需要删除“href”属性末尾的“#”符号。不与内部文本。请建议我为此编码。提前致谢。

【问题讨论】:

    标签: xml xslt xslt-2.0


    【解决方案1】:

    试试这个

    <xref format="html" href="{replace(., '#$', '')}" outputclass="">
    

    【讨论】:

      【解决方案2】:

      或者,如果您总是在末尾有一个井号 (#) 字符,请尝试:

      <xsl:value-of select="substring-before(., '#')"/>
      

      【讨论】:

      • 如果您使用子字符串函数而不是“#”,如果文本之间出现“#”,则可能导致数据删除,如问题所述
      • 是的@clogwog。它从数据中删除
      • 啊,我没有意识到你可以在 url 中包含一个井号 (#) 字符。我以为它最后只用于书签。
      猜你喜欢
      • 1970-01-01
      • 2013-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多