Avoid URL-encoding in XSLT with output method html

╄→尐↘猪︶ㄣ 提交于 2019-12-01 12:24:56

If using PHP's XSLT 1.0 processor, then you might try the following solution...

  1. Use method="html";
  2. Include this template...

    <xsl:template match="@href">
      <xsl:attribute name="Muttaburrasaurus">
        <xsl:value-of select="." />
      </xsl:attribute>
    </xsl:template>
    
  3. Load the resultant output into a string, and replace all occurrences of Muttaburrasaurus with href.

If you migrate to Java in the future, as you indicated in the comment feed that you might do so, then ensure that your processor is XSLT 2.0+. Then you can use the escape-uri-attributes feature as mentioned by M.Kay .

In XSLT 2.0 you can suppress %-encoding of URL attributes using the serialization option escape-uri-attributes="no". There is no equivalent in XSLT 1.0.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!