Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Domain Specific Language generation based on a XML Schema.

50 views

Published on

An overview of the process used to generate fluent Java interfaces to use a domain specific language previously defined in the XSD language.

Published in: Engineering
  • Be the first to comment

  • Be the first to like this

Domain Specific Language generation based on a XML Schema.

  1. 1. Domain Specific Language generation based on a XML Schema 13/12/2018 ÁREA DEPARTAMENTAL DE ENGENHARIA DE ELETRÓNICA E TELECOMUNICAÇÕES E DE COMPUTADORES MESTRADO EM ENGENHARIA INFORMÁTICA E DE COMPUTADORES 1 Author: Luís Duarte Nº 39378 Adviser: Fernando Miguel Gamboa de Carvalho
  2. 2. 13/12/2018 ADEETC – MEIC - DISSERTAÇÃO 2 • What are they? • External DSLs. • XSD. Domain Specific Languages
  3. 3. 13/12/2018 ADEETC – MEIC - DISSERTAÇÃO 3 • What are they? • External DSLs. • XSD. • Regular expressions. Domain Specific Languages
  4. 4. 13/12/2018 ADEETC – MEIC - DISSERTAÇÃO 4 • What are they? • External DSLs. • XSD. • Regular expressions. • Internal. • LINQ. Domain Specific Languages
  5. 5. 13/12/2018 ADEETC – MEIC - DISSERTAÇÃO 5 External Domain Specific Language - HTML Static Component Dynamic Component
  6. 6. 13/12/2018 ADEETC – MEIC - DISSERTAÇÃO 6 Template Engines Apache Velocity ASP.NE T Laravel Blade CodeCharge Studio ColdFusion CTPP Django FreeMarker eRuby Genshi Go Templates Haml Hamlets Thymeleaf Smarty Razor PHP Open Power Template Mustache Kid Jinja JSP vlibTemplat e WebMarc o Twi g Handlebars
  7. 7. 13/12/2018 ADEETC – MEIC - DISSERTAÇÃO 7 • Security. • Well formed documents. • HTML language rule validation. • Context object validation. Template Engines - Issues
  8. 8. 13/12/2018 ADEETC – MEIC - DISSERTAÇÃO 8 • Security. • Well formed documents. • HTML language rule validation. • Context object validation. • Performance. Template Engines - Issues
  9. 9. 13/12/2018 ADEETC – MEIC - DISSERTAÇÃO 9 • Security. • Well formed documents. • HTML language rule validation. • Context object validation. • Performance. • Flexibility. Template Engines - Issues If/Else: For:
  10. 10. 13/12/2018 ADEETC – MEIC - DISSERTAÇÃO 10 • Security. • Well formed documents. • HTML language rule validation. • Context object validation. • Performance. • Flexibility. • Complexity. Template Engines - Issues
  11. 11. 13/12/2018 ADEETC – MEIC - DISSERTAÇÃO 11 Template Engines – The Breakthroughs J2Html KotlinHtml HtmlFlow1 Rocke r
  12. 12. 13/12/2018 ADEETC – MEIC - DISSERTAÇÃO 12 Template Engines – The Breakthroughs – J2Html Java templates. Well formed documents. HTML rule validation. Performance. Incomplete.
  13. 13. 13/12/2018 ADEETC – MEIC - DISSERTAÇÃO 13 Template Engines – The Breakthroughs - Rocker Performance. Context object validation. Complete. Uses text templates. Well formed documents. HTML rule validation.
  14. 14. 13/12/2018 ADEETC – MEIC - DISSERTAÇÃO 14 Template Engines – The Breakthroughs - KotlinHtml Security. HTML rule validation. Kotlin Templates. Well formed documents. Performance.
  15. 15. 13/12/2018 ADEETC – MEIC - DISSERTAÇÃO 15 Template Engines – The Breakthroughs – HtmlFlow1 First approach at a HTML DSL. Some HTML rule validation. Java Templates. Well formed documents. Performance. Only validates some HTML rules. Incomplete.
  16. 16. 13/12/2018 ADEETC – MEIC - DISSERTAÇÃO 16 Template Engines – The Breakthroughs - Summary Functional Templates Element Validation Attribute Validation Full HTML support Well formed documents Performance
  17. 17. 13/12/2018 ADEETC – MEIC - DISSERTAÇÃO 17 xmlet Approach HtmlApiFaster XsdAsmFaster XsdParser 1) XSD file, DSL name 2) XSD file 3) XSD element list 4) Generated classes • Generation of a Java DSL.
  18. 18. 13/12/2018 ADEETC – MEIC - DISSERTAÇÃO 18 • Security. • Language Rules. • Automation + Reuse. • Fast. • Avoids human error. • Intuitive. • Transparent. xmlet Objectives
  19. 19. 13/12/2018 ADEETC – MEIC - DISSERTAÇÃO 19 • Complete support to the HTML language. • Performance. • Maintenance. • Templates defined as functions. New HtmlFlow – HtmlFlow + xmlet
  20. 20. 13/12/2018 ADEETC – MEIC - DISSERTAÇÃO 20 • Introduction. • The motivation. • “(...) That's about a thousand times faster than Apache Velocity.” • Used Benchmarks. • Spring Benchmark. • Template Benchmark. Benchmarks
  21. 21. 13/12/2018 ADEETC – MEIC - DISSERTAÇÃO 21 • Approach. • Reliability. • Results. Benchmarks – Spring Benchmark - Results
  22. 22. 13/12/2018 ADEETC – MEIC - DISSERTAÇÃO 22 Benchmarks – Spring Benchmark - Results
  23. 23. 13/12/2018 ADEETC – MEIC - DISSERTAÇÃO 23 • Approach. • JMH. • Results. Benchmarks – Template Benchmark - Results
  24. 24. 13/12/2018 ADEETC – MEIC - DISSERTAÇÃO 24 Benchmarks – Template Benchmark - Results
  25. 25. 13/12/2018 ADEETC – MEIC - DISSERTAÇÃO 25 Benchmarks – Template Benchmark - Results
  26. 26. 13/12/2018 ADEETC – MEIC - DISSERTAÇÃO 26 Versatility – Android Visual Layouts
  27. 27. 13/12/2018 ADEETC – MEIC - DISSERTAÇÃO 27 Versatility – Android Visual Layouts Android android = new Android(androidObj -> androidObj.layout() .linearLayout() .attrLayoutWidth("wrap_content") .attrLayoutHeight("wrap_content") .attrGravity(EnumGravityLinearLayout.CENTER) .textView() .attrText("Hello MEIC!") .attrLayoutWidth("wrap_content") .attrLayoutHeight("wrap_content") .attrTextSize("36sp") .attrTextColor("@android:color/black") .attrBackground("#ccddff") .attrPadding("20dp") .__() .__()); String layout = android.getLayout();
  28. 28. 13/12/2018 ADEETC – MEIC - DISSERTAÇÃO 28 Versatility – Regular Expressions String toMatch = "regulares"; Challenge: Find all characters between ‘a’ and ‘d’ or between ‘r’ and ‘z’. Regular Expression: [a-d]|[r-z] Results: r u a r s
  29. 29. 13/12/2018 ADEETC – MEIC - DISSERTAÇÃO 29 Versatility – Regular Expressions String toMatch = "regulares"; Regex regex = new Regex(expr -> expr.matchRegex() .fromFirstUntilLast().attrFirst("a").attrLast("d") .or() .fromFirstUntilLast().attrFirst("r").attrLast("z")); List<String> result = regex.match(toMatch);
  30. 30. 13/12/2018 ADEETC – MEIC - DISSERTAÇÃO 30 • What is it? • Element mapping. • XSD rule validation. Versatility – XsdParser
  31. 31. 13/12/2018 ADEETC – MEIC - DISSERTAÇÃO 31 • HtmlFlow v3.0. • Multiple published DSLs. • Sub-projects with multiple usages. Conclusions
  32. 32. 13/12/2018 ADEETC – MEIC - DISSERTAÇÃO 32 Conclusions - Article Article Part 1 Article Part 2
  33. 33. 13/12/2018 ADEETC – MEIC - DISSERTAÇÃO 33 Questions “Template engines are a great way to build dynamic HTML pages, but are you using the best template engine for your purposes?” - DZone

×