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 502239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:16:15+00:00 2026-05-13T06:16:15+00:00

I have an XML file which is transformed with XSL. Some elements have to

  • 0

I have an XML file which is transformed with XSL. Some elements have to be changed, some have to be left as is – specifically, text with entities ", &, ', <, > should be left as is, and in my case " and ' are changed to " and ' accordingly.

Test XML:

<?xml version="1.0" encoding="UTF-8" ?>
<root>
    <element>
        &quot;
        &amp;
        &apos;
        &lt;
        &gt;
    </element>
</root>

transformation file:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="no" indent="no" />
    <xsl:template match="element">
        <xsl:copy>
            <xsl:value-of disable-output-escaping="no" select="." />
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>

result:

<?xml version="1.0" encoding="UTF-8"?>
    <element>
        "
        &amp;
        '
        &lt;
        &gt;
    </element>

desired result:

<?xml version="1.0" encoding="UTF-8"?>
    <element>
        &quot;
        &amp;
        &apos;
        &lt;
        &gt;
    </element>

I have 2 questions:

  • why does some of those entities are transformed and other not?
  • how can I get a desired result?
  • 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-05-13T06:16:16+00:00Added an answer on May 13, 2026 at 6:16 am

    The reason is, that <, > and & always must be escaped in XML. They have special meaning in XML, so they must be treated specially if they are part of data (instead of markup).

    The other two, ' and ", can be escaped, their entity names are known to XML (mainly, to enable correctly functioning attribute values, like this:

    <xml ackbar="He said, &quot;It's a trap!&quot;" />
    <xml ackbar='He said, "It&apos;s a trap!"' />
    

    In all places where their escaping is not absolutely necessary, they can occur literally.

    The resulting info set (e.g. in form of a DOM) will be exactly the same, and you should not care too much whether they occur literally or as an entity in the XML file.

    In fact, all of your data could occur in escaped form (numbered entities, as in &#10;) without changing the actual document – only the serialized representation differs.

    As long as you work with XML-aware tools (e.g. DOM parsers), you will never notice a difference. Corollary: If you don’t work with XML-aware tools (e.g. regex or string manipulation), you should stop that immediately. 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML file which has to be transformed using XSLT, I am
I have this xml file which has text init. i.e Hi my name is
I have an XML file which I'd like to parse into a non-XML (text)
Let's assume I have a simple XML file: <data> <text>Hello world!&lt;br&gt;Nice to see you
I have an xml file which describes (among other things) elements with attribute values
I have a xml file which I need to open with Microsoft Word 2007.
I have an XML file which I need to parse using PHP and send
I have an XML file which XML parser choke on. A part of it
I have an XML file which has many section like the one below: <Operations>
I have written xml file which contains html tags as element like <component> <input

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.