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

  • Home
  • SEARCH
  • 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 3403088
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:13:04+00:00 2026-05-18T05:13:04+00:00

I have some XML that looks like <?xml version=1.0?> <root> <![CDATA[ > foo ]]>

  • 0

I have some XML that looks like

<?xml version="1.0"?>
<root>
    <![CDATA[
    > foo 
    ]]>
</root>

(Note the > sign in “> foo”) and an XSLT stylesheet

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/root">
    <foo><xsl:value-of select='.'/></foo>
</xsl:template>
</xsl:stylesheet>

When I run xsltproc stylesheet.xsl data.xml I get

<?xml version="1.0"?>
<foo>

    &gt; foo

</foo>

but the output I want is

<?xml version="1.0"?>
<foo>

    > foo

</foo>

i.e. keep the “>” as it is instead of converting it to an entity. How can I accomplish this?

  • 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-18T05:13:05+00:00Added an answer on May 18, 2026 at 5:13 am

    @Oded, @khachik,

    Try checking his desired output for well-formedness. It is indeed well-formed XML. (“Valid” is not even a question here, as there is no schema.)

    It is a common misconception that “>” is not legal in well-formed XML.
    In most contexts, “<” is not legal, but “>” is legal everywhere with one rare exception. The relevant paragraph of the spec:

    The ampersand character (&) and the
    left angle bracket (<) MUST NOT appear
    in their literal form, except when
    used as markup delimiters, or within a
    comment, a processing instruction, or
    a CDATA section. If they are needed
    elsewhere, they MUST be escaped using
    either numeric character references or
    the strings ” & ” and ” < ”
    respectively. The right angle bracket
    (>) may
    be represented using the
    string ” &gt; “, and MUST, for
    compatibility, be escaped using either
    ” &gt; ” or a character reference when
    it appears in the string ” ]]> ” in
    content,
    when that string is not
    marking the end of a CDATA section.

    With XSLT 2.0, the “right” way to do what you want is to use <xsl:character-map>.
    With XSLT 1.0, I think the only way to force the use of “>” in the output is to use disable-output-escaping, as @khachik suggested. Note however that XSLT processors are not required to honor DOE or character maps, and some can’t (e.g. if they’re in a pipeline and are not connected to serialization). But you probably know by now whether yours can, and if it can’t, you’ll need to handle serialization issues at the end of the pipeline.

    However, it is worth asking, why do you want the “>” serialized as “>”? As seen in the spec, &gt; is a perfectly acceptable way to express exactly the same information as far as XML is concerned. No downstream XML consumer should know the difference or care. Do you want it for aesthetic reasons?

    Update: the OP wants that because the output needs to be not only well-formed XML, it also needs to be well-formed Literate Haskell.

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

Sidebar

Related Questions

I have some XML code that looks like this <SEARCHRESULTS> <FUNCTION name=BarGraph> <PARAMETER name=numList></PARAMETER>
Greetings! I have some XML like this: <Root> <AlphaSection> . . . </AlphaSection> <BetaSection>
Greetings! I have some XML like this: <Root> <MainSection> <SomeNode>Some Node Value</SomeNode> <SomeOtherNode>Some Other
I have a file which is an XML representation of some data that is
i have some xml with math ml inside, and i would like to find
Let's say I have some XML like this <channel> <item> <title>This is title 1</title>
I have some XML in an XmlDocument, and I want to display it on
So I have some XML in the following format: <somenode> <html xmlns=http://www.w3.org/1999/xhtml> <head> <title/>
I'm not even sure if it's possible but say I have some XML: <source>
How do I escape '<' and '>' character in sed. I have some xml

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.