Jump to: navigation, search

M2T-JET-FAQ/How to I escape JET special characters?

< M2T-JET-FAQ
Revision as of 08:36, 15 October 2012 by Pelder.ca.ibm.com (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

JET recognizes a number of characters is lead-ins to tags, comments, directives and embedded XPath expressions. If you need to include these characters in your template output, you need to escape them. Different techniques are required for different types of characters:

Tag lead-in characters: < and </

To escape a < characters, place a backslash (\) in front of it. Example:

JET template text:

\<some text>

Template output:

<some text>

== Comment lead-in and closing characters: <%-- and --%>

JET comment lead-in and closing characters can be escaped by placing a backslash (\) before the % sign on the lead-in and the > on the closing:

JET template text:

<\%-- this is not a JET comment --%\>

Template output:

<%-- this is not a JET comment --%>

== Directive lead-in: <%@

The JET directive lead-in can be escaped by placing a backslash (\) before the % sign:

JET template text:

<\%@NOT a JET Directive%>

Template output:

<%@NOT a JET Directive%>

Embedded XPath expression lead-in: ${

The embedded XPath lead-in can be escaped by putting part or all of the lead-in into an enclosing embedded XPath expression that returns a string.

JET template text. Here ${'$'} is an embedded XPath expression ('$'), which returns a single character $:

The minimum needed: ${'$'}{someStaticText}

Template output:

The minimum needed: ${someStaticText}

JET template text. Here, an embedded XPath expression returns the entire string ${someStaticText}:

An alternative - quote the entire expression: ${'${someStaticText}'}

Template output:

An alternative - quote the entire expression: ${someStaticText}