Use Google to find help fast. For example, search on "xpressdox choosefromlist".

The EscapeForXml and GetValidXmlElementName Functions

The EscapeForXml and GetValidXmlElementName Functions

These two functions are used in the context where the XpressDox template is needed to generate XML.  (By the way, this demonstrates the power of XpressDox in being able to produce not just Word documents, but also text and, in this case, transform XML from one format into another).

«EscapeForXml(Text)» will translate XML reserved characters in the data element Text to their escaped values.  I.E.

< becomes &lt;
> becomes &gt;
& becomes &amp;

etc.

«GetValidXmlElementName(Description,'_and_')» will build a value from data element Description which is a valid XML element name, translating any ‘&’ characters to the string ‘_and_’.

Here follows a snippet from a template which converts an XML answer set produced by a well known document assembly system into an XpressDox data set:

«SaveAsText(Yes)»
«SetSavedDocumentFileName(XpressDoxDataSet.xml)»

<DataSet>
«ForEach(Answer)»
«SetVr(‘DENameA’,GetValidXmlElementName(Replace(Replace(Replace(@name,'(',''),')',''),'?','Q'),'_and_'))»
«If(TextValue != '')»
<«GetV(‘DENameA’)»>«EscapeForXml(TextValue)»</«GetV(‘DENameA’)»>
«End(TxtValue)»
«If(NumValue != '')»
<«GetV(‘DENameA’)»>«EscapeForXml(NumValue)»</«GetV(‘DENameA’)»>
«End(NumValue)»
«If(TFValue != '')»
<«GetV(‘DENameA’)»>«TFValue»</«GetV(‘DENameA’)»>
«End(TFValue)»
«End(ForEach Answer)»
</DataSet>

These functions are available in version 4 (and later) of XpressDox.

Leave a Reply