Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9106079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:15:13+00:00 2026-06-17T02:15:13+00:00

I have a transformation that outputs HTML. In order to avoid self-closing tags that

  • 0

I have a transformation that outputs HTML. In order to avoid self-closing tags that could break in older browsers (e.g. <img /> instead of <img></img>) output-method has to be html. Then though URL-encoding is applied so that it breaks my application. See for example:

Input

<html>
<head>
</head>
<body>
{{example}}
<a href="{{example}}" >abc</a>
<img src="http://placehold.it/20x20"></img>
</body>
</html>

Transformation

<?xml version="1.0" encoding="utf-8"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" /><!-- either -->
<xsl:output method="html" indent="yes" /><!-- or -->
<xsl:template match="@*|node()">
    <xsl:copy><xsl:apply-templates select="@*|node()" /></xsl:copy>
</xsl:template>
</xsl:transform>

In the first case the output is:

<?xml version="1.0"?>
<html>
<head>
</head>
<body>
{{example}}
<a href="{{example}}">abc</a>
<img src="http://placehold.it/20x20"/>
</body>
</html>

In the second case the output is:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
{{example}}
<a href="%7B%7Bexample%7D%7D">abc</a>
<img src="http://placehold.it/20x20">
</body>
</html>

What is good about the first case is that the @href attribute is not URL-encoded. This is a must for my application. What is bad though and better achieved by the second variant is, that the <img> is self-closing. This must not be for <img> tags and some others.

Is there a way to have the benefits of method="html" without the URL-encoding? If yes, how?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T02:15:14+00:00Added an answer on June 17, 2026 at 2:15 am

    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
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program that outputs reports in HTML format. On average, they are
I have a transformation sequence of models that eventually outputs an EMF model, instance
I am designing a Proxy Service sequence that includes an XQuery transformation. I have
I have an XML file that I am creating an XSLT transformation for. (XML
I have an imported MSBuild project (appconfig.transformation.targets) that defines some tasks and puts them
I have a Pentaho Kettle (PDI) transformation that starts with a Table Output step
I have an xslt transformation that works fine when run in Altova XML Spy,
In my XSLT transformation I have two analyze-strings that I need to use to
I have a problem with 2D transformation program I have the source code import
I have written a C# code for triggering an XML to XML (XSLT) transformation.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.