Bug 734627 - CDATAs in TopicXML are converted to <foo> when you export the XML
Summary: CDATAs in TopicXML are converted to <foo> when you export the XML
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: PressGang CCMS
Classification: Community
Component: Web-UI
Version: 1.x
Hardware: Unspecified
OS: Unspecified
urgent
urgent
Target Milestone: ---
: ---
Assignee: sgilda
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-08-31 00:33 UTC by sgilda
Modified: 2012-08-21 00:50 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-10-19 23:08:28 UTC


Attachments (Terms of Use)

Description sgilda 2011-08-31 00:33:07 UTC
Description of problem:
I enter and save topic XML containing the following:
    <programlisting language="XML">
        <![CDATA[<servlet-mapping>
            <servlet-name>javax.ws.rs.core.Application</servlet-name>
            <url-pattern>/hello/*</url-pattern>
        </servlet-mapping>]]>
    </programlisting>
When I export the TopicXML for that topic, it exports like this:
    <programlisting language="XML">
        &lt;servlet-mapping&gt;
           &lt;servlet-name&gt;javax.ws.rs.core.Application&lt;/servlet-name&gt;
           &lt;url-pattern&gt;/hello/*&lt;/url-pattern&gt;
        &lt;/servlet-mapping&gt;
    </programlisting>


Version-Release number of selected component (if applicable):


How reproducible:
Add the topicXML data as described above. Save the topic. Then export that topicXML.

Steps to Reproduce:
1. Add the topicXML data as described above. 
2. Then export that topicXML.
3.
  
Actual results:


Expected results:


Additional info:

Comment 1 sgilda 2011-08-31 00:48:15 UTC
Many of my topics contain xml snippets. I am not able to edit those topics without messing up all the CDATAs until this bug is fixed. The topic displays fine, but it would be a maintenance nightmare to try to maintain the source code with &lt; instead of CDATAs. Is there an option on the XML API to prevent converting CDATAs?

Comment 2 Matthew Casperson 2011-08-31 23:58:23 UTC
Fixed in 20110901-0957

Turns out this code:

final DOMImplementationLS impl = (DOMImplementationLS)DOMImplementationRegistry.newInstance().getDOMImplementation("LS");
final LSParser builder = impl.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null);
final LSInput xmlFile = impl.createLSInput();					
xmlFile.setByteStream(new ByteArrayInputStream(xml.getBytes(encoding)));
final Document document = builder.parse(xmlFile);

will coalesce CDATA elements. I couldn't find any way to disable it. Changed to this code:

final DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
final DocumentBuilder builder = builderFactory.newDocumentBuilder();
final Document document = builder.parse(new ByteArrayInputStream(xml.getBytes(encoding)));

Comment 3 sgilda 2011-10-19 23:08:28 UTC
works as expected.


Note You need to log in before you can comment on or make changes to this bug.