Skip to main content
Skip table of contents

CDATA Placeholder

USE_CDATA

Any parameter value can be set from a CDATA block provided it is set to USE_CDATA:

XML
<ytriaAutomation>
	<SetVar varInCDATA="Insert the text you want"/>
	<SetVar testCDATA="USE_CDATA">
		<![CDATA[
		Within this Character Data block I can
		use double dashes as much as I want (along with <, &, ', and ")
		*and* %MyParamEntity; will be expanded to the text
		"Has been expanded" ... however, I can't use
		the CEND sequence. If I need to use CEND I must escape one of the
		brackets or the greater-than sign using concatenated CDATA sections.
		Let's do some <a href=http://www.ytria.com>HTML</a> & then "sleep".
		{%varInCDATA%}
		]]>
	</SetVar>
	<MsgBox Title="Please read this title now" Message="{%testCDATA%}" MessageExtended="USE_CDATA" ButtonOkLabel="Thank you" Image="consentReminder">
		<![CDATA[
		<DOES NOT DISPLAY IN HTML.>
		READ ME IN PLAIN TEXT.
		]]>
	</MsgBox>
	<echo value="{%testCDATA%}"/>
</ytriaAutomation>



This allows for larger texts to be used in the script without making it unreadable and without having to escape the text to fit the XML norm.


The CDATA enclosing notation is not mandatory, but then all the proper escapes must be used.


All consecutive CDATA sections are concatenated. This allows the use of 'nested' CDATA', especially usefull if a var value is not valid in xml (unescaped)

XML
<ytriaAutomation>
	<SetVar v_UserEdit_SetParam='USE_CDATA'>
		<![CDATA[
		<SetParam Field='{%v_FieldID%}' Value='USE_CDATA'>
		<![CDATA[
		{%v_Value%}
		]]]]>
		<![CDATA[>
		</SetParam>
		]]>
	</SetVar>
</ytriaAutomation>


> How to nest CDATA?

This doesn't work:

XML
<ytriaAutomation>
	<SetVar v_UserEdit_SetParam='USE_CDATA'>
		<![CDATA[
		<SetParam Field='{%v_FieldID%}' Value='USE_CDATA'>
		<![CDATA[
		{%v_Value%}
		]]><----------------- FORBIDDEN IN A CDATA
		</SetParam>
		]]>
	</SetVar>
</ytriaAutomation>


Solution

Replace the nested closing sequence
]]>
by
]]]]><![CDATA[>

The reason is that the only character sequence forbidden in a CDATA is the closing sequence, so we have to split it over two CDATAs.

The first CDATA section contains

<SetParam Field='{%v_FieldID%}' Value='USE_CDATA'>
<![CDATA[
{%v_Value%}
]]

The second CDATA section contains

>
</SetParam>

When you concatenate both, you have

XML
<SetParam Field='{%v_FieldID%}' Value='USE_CDATA'>
	<![CDATA[
	{%v_Value%}
	]]>
</SetParam>
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.