Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1094293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:57:12+00:00 2026-05-16T23:57:12+00:00

We have an email template which needs to be processed using Java. We have

  • 0

We have an email template which needs to be processed using Java. We have to replace the variables in the template with actual values. We were able to achieve this using pattern matching , ie; by searching the template for particular patters and replace them with actual values.
Now we need have conditions in the XML file.For example

$if($subject!=null)
 sample subject
$endif

We need to check for this condition also. subject is a variable whose value needs to be repalced.
We are not allowed to use Velocity template processor.

Please suggest the best ways of implementing this.Is it good to have to ways of parsing it, like applying values for variables in the first parse and then checking the logic in the second parse. It will be of great help if anyone can provide their valuable suggestions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T23:57:13+00:00Added an answer on May 16, 2026 at 11:57 pm

    If you can’t use Velocity, you might be interested in other template processors. I’ve used FreeMarker successfully in a few projects.

    If you general template is XML-based, you could use an XSLT transform with parameters to express this template. You’re likely to get more support out of the box for this.

    After this, if you really want to do it the hard way, you could build your own template processor using lexers and parsers such as JFlex and CUP. This being said, in your example, you’re using the $ notation for both keywords ($if, $endif) and variables ($subject). While there’s nothing wrong with that in principle, it would probably be easier to come up with a different notation for the two types to make the lexer easier (fewer exceptions/reserved words). Better delimiters to distinguish actual content from template instructions would help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have applied a template filter, which extracts the domain from an email address.
I have a django template which I have to send as email body, the
I have a controller's method which renders a template. This works fine to render
I have an e-mail template which is just a plain, static HTML page. I
I am trying to build a responsive email template but have run into some
We have an email confirmation page for registration which can be hit with a
I have this email sending code that does not show a chooser (good). How
Is their a solution to generate an email template using an ASP.NET MVC View
I have two files the one which hosts my actual contact form and then
I was provided a template which I have changed the text. The site displays

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.