Avoid URL-encoding in XSLT with output method html

后端 未结 2 1505
挽巷
挽巷 2021-01-16 05:52

I have a transformation that outputs HTML. In order to avoid self-closing tags that could break in older browsers (e.g. instead of

相关标签:
2条回答
  • 2021-01-16 06:02

    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.

    0 讨论(0)
  • 2021-01-16 06:20

    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 .

    0 讨论(0)
提交回复
热议问题