Freemarker ● Introduction ● Core features ● Java part example ● Template example ● Expressions ● Builtins ● Assigning value ● Conditions ● Loops ● Macros.

Slides:



Advertisements
Similar presentations
Chungnam National University DataBase System Lab
Advertisements

Introduction to XSL XSL-BASIC ELEMENTS. Transforming XML XSL file 1 XSLT Processor WML fileXSL file 2HTML fileXML file Contenuto Forma Documento.
XML: Managing Data Exchange Stylesheets. Lesson Contents CSS The basic XSL file XSL transforms Templates Sort Numbering Parameters and Variables Datatypes.
Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
DT211/3 Internet Application Development
Guide To UNIX Using Linux Third Edition
XML Technologies and Applications Rajshekhar Sunderraman Department of Computer Science Georgia State University Atlanta, GA 30302
MC 365 – Software Engineering Presented by: John Ristuccia Shawn Posts Ndi Sampson XSLT Introduction BCi.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 25 – Perl and CGI (Common Gateway Interface) Outline 25.1 Introduction 25.2 Perl 25.3 String Processing.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
XML files (with LINQ). Introduction to LINQ ( Language Integrated Query ) C#’s new LINQ capabilities allow you to write query expressions that retrieve.
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 9 JavaServer Pages (JSP) (Based on Møller.
June 2008 Florida Atlantic University Department of Computer Science & Engineering ISM 4052 –Internet Application Programming Dr. Roy Levow Session 2.
JSP Standard Tag Library
PHP Overview CS PHP PHP = PHP: Hypertext Preprocessor Server-side scripting language that may be embedded into HTML One goal is to get PHP files.
Tutorial 14 Working with Forms and Regular Expressions.
XML for E-commerce III Helena Ahonen-Myka. In this part... n Transforming XML n Traversing XML n Web publishing frameworks.
XSLT for Data Manipulation By: April Fleming. What We Will Cover The What, Why, When, and How of XSLT What tools you will need to get started A sample.
WORKING WITH XSLT AND XPATH
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
Introduction to JavaServer Pages (JSP) Slides from Dr. Mark Llewellyn.
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 6 XSLT (Based on Møller and Schwartzbach,
Processing of structured documents Spring 2002, Part 2 Helena Ahonen-Myka.
® IBM Software Group © 2007 IBM Corporation JSP Expression Language
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
1 XSLT An Introduction. 2 XSLT XSLT (extensible Stylesheet Language:Transformations) is a language primarily designed for transforming the structure of.
JSTL, XML and XSLT An introduction to JSP Standard Tag Library and XML/XSLT transformation for Web layout.
XSLT Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Utilizing XML in ColdFusion MX by Attila Domokos.
1 © 2002, Cisco Systems, Inc. All rights reserved. Arrays Chapter 7.
PHP - Basic Language Constructs CSCI 297 Scripting Languages - Day Two.
JSTL Lec Umair©2006, All rights reserved JSTL (ni) Acronym of  JavaServer Pages Standard Tag Library JSTL (like JSP) is a specification, not an.
EXist Indexing Using the right index for you data Date: 9/29/2008 Dan McCreary President Dan McCreary & Associates (952) M.
VB and C# Programming Basics. Overview Basic operations String processing Date processing Control structures Functions and subroutines.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
AxKit A member of the Apache XML project Ryan Maslyn Kyle Bechtel.
Dr. Chunbo Chu Week 3. XML Not a replacement for HTML. XML and HTML were designed with different goals: XML was designed to transport and store data,
Introduction To JavaScript. Putting it Together (page 11) All javascript must go in-between the script tags. All javascript must go in-between the script.
More XML XPATH, XSLT CS 431 – February 23, 2005 Carl Lagoze – Cornell University.
CSCI 3327 Visual Basic Chapter 8: Introduction to LINQ and Collections UTPA – Fall 2011.
XP New Perspectives on XML, 2 nd Edition Tutorial 7 1 TUTORIAL 7 CREATING A COMPUTATIONAL STYLESHEET.
JAVA BEANS JSP - Standard Tag Library (JSTL) JAVA Enterprise Edition.
COP 3813 Intro to Internet Computing Prof. Roy Levow Lecture 4 JavaScript.
University of Nottingham School of Computer Science & Information Technology Introduction to XML 2. XSLT Tim Brailsford.
STRUCTURE OF JSP PRESENTED BY: SIDDHARTHA SINGH ( ) SOMYA SHRIVASTAV ( ) SONAM JINDAL ( )
Martin Kruliš by Martin Kruliš (v1.1)1.
LING 408/508: Programming for Linguists Lecture 11 October 5 th.
Rich Internet Applications 2. Core JavaScript. The importance of JavaScript Many choices open to the developer for server-side Can choose server technology.
1 Java Server Pages A Java Server Page is a file consisting of HTML or XML markup into which special tags and code blocks are inserted When the page is.
XSLT: How Do We Use It? Nancy Hallberg Nikki Massaro Kauffman.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Web Database Programming Using PHP.
Chapter 6 Chapter 6 Server Side Programming (JSP) Part 1 1 (IS 203) WebProgramming (IS 203) Web Programming.
10 Copyright © 2004, Oracle. All rights reserved. Building ADF View Components.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
XML Extensible Markup Language
XML Schema – XSLT Week 8 Web site:
Apache Cocoon – XML Publishing Framework 데이터베이스 연구실 박사 1 학기 이 세영.
Lecture Transforming Data: Using Apache Xalan to apply XSLT transformations Marc Dumontier Blueprint Initiative Samuel Lunenfeld Research Institute.
TK-UI – Toolkit for User Interface CSS Engine. Akrogen TK-UI CSS Engine – Goal Try to improve Matt work ge=sub/&id=3631.
JSP: Actions elements and JSTL
XML in Web Technologies
The XML Language.
PHP.
Web DB Programming: PHP
Web Programming Language
More XML XML schema, XPATH, XSLT
Presentation transcript:

Freemarker ● Introduction ● Core features ● Java part example ● Template example ● Expressions ● Builtins ● Assigning value ● Conditions ● Loops ● Macros ● Import ● Include

What is Freemarker? ● Freemarker is a template engine ● It is used to generate text output ● Example: HTML, XML, , SQL, Java code ● Programmer prepares environment in Java ● Designer writes template referencing the environment ● Freemarker produces output

Core Features ● Powerful template language ● Versatile data model - object wrappers ● Internationalization / localization ready ● Configurable and extensible ● Generic - output goes to any Writer ● Templates can be loaded from file, jar, web, db.. ● XML, Ant and Jython support

Java Part - Environment Person person = new Person(1234); person.setName("Jon Smith"); List phones = new ArrayList(); phones.add(" "); phones.add(" "); person.setPhones(phones); Map env = new HashMap(); env.put("PERSON", person);

Java Part - Configuration Configuration config = new Configuration(); config.setObjectWrapper(BEANS_WRAPPER); config.setOutputEncoding("ISO "); config.setDirectoryForTemplateLoading(templates); config.setSetting("number_format", "0"); config.setSharedVariable("TODAY", new Date()); config.setTemplateExceptionHandler(DEBUG_HANDLER);

Java Part - Process Template Template template = config.getTemplate("person.ftl"); FileWriter writer = new FileWriter("person.txt"); template.process(env, writer); writer.close();

Template Example Dear ${PERSON.name}, you have successfully registered with account id ${PERSON.id}. You have set following contact phone numbers: ${phone}, ${TODAY?string.medium}, Prague

FTL Expressions ● Expressions are usually surrounded by ${} ● Variable is accessed by its name ${TODAY} ● Support for JavaBean properties, map keys and collection indexes ${PERSON.phones[1]} ● Arithmetics: +, -, *, /, %, floating point supported ● Logical operations: &&, ||, !, ==, !=,, = ● Sequence slices: ${PERSON.name[2..]}

FTL - Built-ins ● Function appended after expression with ? char ● Undefined: default, exists, if_exists, has_content ● String: html, xml, url, left_pad, right_pad, length, split, replace, index_of, matches, word_list ● Sequence: first, last, reverse, size, sort ● Hashes: keys, values ● XML: parent, children, root, ancestors, node_type

FTL - Assigning Value ● ● value ● Possible to create/overwrite top level variable in specifed (or default) namespace.

FTL - Conditions ●,, ● Expression must evaluate to boolean ● There is no ${} inside directive tags ● is pair tag, it must be closed ● Character < must be escaped or surrounded by () No No Yes ● switch, case, default, break directives supported

FTL - Loops ●, ● Iterates over each element in sequence ● Local variable item is introduced within tags ● Variables item_has_next and item_index are available ${phone_index}. ${phone}

FTL - Macros ●,, ● Macro is a repetitive template fragment ● Default values, variable number of parameters ● Parameter passing by name or positional Hello

FTL - Import ● Imports given library into the namespace ● Namespaces allows reusability without conflicts

FTL - Include ● Include is used to merge specified template ● Parent directories may be searched wap/cz/header.ftl, cz/header.ftl, header.ftl ● Localization support - like ResourceBundles header.ftl_cs_CZ, header_cs.ftl, header.ftl

FTL - XML support ● You can parse XML or wrap DOM tree root.put( "doc", NodeModel.parse(file))); ● You can access elements by name, attribute ${doc.invoice.person.name} ${item} - USD ● Declarative support available via