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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T16:02:50+00:00 2026-05-10T16:02:50+00:00

This is a followup question of How to encode characters from Oracle to Xml?

  • 0

This is a followup question of How to encode characters from Oracle to Xml?

In my environment here I use Java to serialize the result set to xml. I have no access to the output stream itself, only to a org.xml.sax.ContentHandler.

When I try to output characters in a CDATA Section:

It happens basically like this:

xmlHandler.startElement(uri, lname, 'column', attributes); String chars = '<![CDATA['+rs.getString(i)+']]>'; xmlHandler.characters(chars.toCharArray(), 0, chars.length()); xmlHandler.endElement(uri, lname, 'column'); 

I get this:

<column>&lt;![CDATA[33665]]&gt;</column> 

But I want this:

<column><![CDATA[33665]]></column> 

So how can I output a CDATA section with a Sax ContentHandler?

  • 1 1 Answer
  • 2 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. 2026-05-10T16:02:50+00:00Added an answer on May 10, 2026 at 4:02 pm

    It is getting escaped because the handler.characters function is designed to escape and the <![CDATA[ part isn’t considered part of the value.

    You need to use the newly exposed methods in DefaultHandler2 or use the TransformerHandler approach where you can set the output key CDATA_SECTION_ELEMENTS, which takes a whitespace delimited list of tag names that should output sub text sections enclosed in CDATA.

    StreamResult streamResult = new StreamResult(out); SAXTransformerFactory tf = (SAXTransformerFactory) SAXTransformerFactory.newInstance(); TransformerHandler hd = tf.newTransformerHandler(); Transformer serializer = hd.getTransformer(); serializer.setOutputProperty(OutputKeys.CDATA_SECTION_ELEMENTS, 'column'); hd.setResult(streamResult); hd.startDocument(); hd.startElement('','','column',atts); hd.characters(asdf,0, asdf.length()); hd.endElement('','','column'); hd.endDocument(); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a followup question to one I previously asked: start-program-if-not-already-running-in-java I didn't get
This is a followup question from a previous question, which is hopefully a little
This is a followup to the question I asked here: Class Hierarchy - Data
As a followup on this question discussing the use of the ThreadPool vs a
This is a followup to this question . I seem to be stuck on
As kind of a followup to this question I've gotten a solution working on
THis is a followup to my previous question Font-dependent control positioning. It's an attempt
This is a follow up question . So, Java store's integers in two's-complements and
This is a followup question to this question: select all contents of textbox when
This is a followup question to my other widget-related question . I'd like to

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.