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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:54:58+00:00 2026-05-26T06:54:58+00:00

in input XML I have a tag <name>Sample ‘</name> in XSL I transform this

  • 0

in input XML I have a tag

<name>Sample " '</name>

in XSL I transform this tag with:

<xsl:variable name="productName" select="substring($elemXPath/name,1,50)"/>
<someTag someAttr="{$productName}"/>

When I run XSLT the output is:

<someTag someAttr="Sample &quot; '"/>

but I’d like to get

<someTag someAttr="Sample &quot; &apos;"/>

instead. I don’t want to wrap every use of input data with separate escaping template because there is a waste number of such a places in my xslt.

I tried to encode apostrophes in the input file but when I put

<name>Sample &apos;</name>

to the input file then I got

<someTag someAttr="Sample &amp;apos;"/>

instead of

<someTag someAttr="Sample &apos;"/>

My question is how to force/configure XSLT to encode apostrophes as it does for quotes?

  • 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-26T06:54:58+00:00Added an answer on May 26, 2026 at 6:54 am

    There isn’t a way to control serialization to this level in XSLT 1.0.

    In XSLT 2.0 use <xsl:character-map> as in the following example:

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                     version="2.0">
     <xsl:output method="xml" use-character-maps="myChars" omit-xml-declaration="yes"/>
    
     <xsl:character-map name="myChars">
      <xsl:output-character character="&quot;" string="&amp;quot;"/>
      <xsl:output-character character="&apos;" string="&amp;apos;"/>
     </xsl:character-map>
    
     <xsl:template match="/">
         <someTag someAttr="Sample &quot; &apos;"   />
     </xsl:template>
    </xsl:stylesheet>
    

    This produces the wanted result:

    <someTag someAttr="Sample &quot; &apos;"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this use case of an xml file with input like Input: <abc
The input XML tag must be validated for a pattern which is like this:
I am looking to transform a input xml given below <profile name=default> <color id=forecolor
<input src=LOGO.JPG type=image name=imagem> I have an xml element that contains the image path
I have an input XML document something like this: <text> <p> Download the software
At some point in an XSLT program, I have the following: <xsl:for-each select=tags/tag> <xsl:apply-templates
I have an asp:xml tag that holds XSL Information: <asp:xml id=XmlMetadataFields TransformSource=ShowClientTypesPerItemActivity.xsl ></asp:xml> Inside
I have an XML input file and I'm trying to output the result of
I have rather large input XML files that must be converted to a given
My sample input XML is: <root> <a> <b>item</b> <b>item1</b> <b>item2</b> <b>item3</b> <b>item4</b> </a> </root>

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.