Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
Emmie
New Member.
480 views

c$xml and cdata/empty elements

I created a XML file for a third party with C$XML. This XML file is not accepted because:

 

1. my elements may contain &, ', < or >. In my XML file this is converted to &amp, &apos or &gt. This is not accepted by this third party. When I put the data between 

<![CDATA[              ]]>  and use those signs, the XML file is accepted. Is there an OP-CODE to automatically put the data between <![CDATA[              ]]> and not convert those signs in C$XML?

2. Empty elements are in my XML file like <Val/>. This is not accepted by this third party. They want the empty elements represented like <Val></Val>. Is there a way to do this automatically with C$XML?

 

Emmie

0 Likes
1 Reply
Knowledge Partner
Knowledge Partner

RE: c$xml and cdata/empty elements

Emmie,

Your third party is clearly not using one of the standard XML processors.  Instead, the third party is probably using some homemade processor.  What you are describing are two different lexical representations of identical data.  If you have any economic leverage over the third party, you might try to use it.

You can 'fix' the first issue by post-processing the XML document with an XSLT stylesheet.  There is a 'cdata-section-element' attribute in the xsl:output element that will cause the XSL processor to wrap the data in CDATA.

The second issue can also be fixed in XSLT using a more brute force approach.  Use an identity transform and use a template that matches empty elements; output the empty elements using text.  Not exactly a pretty thing, but it will get the result you need.


Tom Morrison
Consultant

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.