SlideShare une entreprise Scribd logo
1  sur  31
Télécharger pour lire hors ligne
DAX: Where Flowscript
     meets XSLT
     Lars Trieloff, Mindquarry
Lars Trieloff

•   Entrepreneur, Blogger,
    Open Source Coder

•   OSS Projects

    •   Apache Cocoon

    •   Mindquarry

    •   Goshaky

    •   DAX
What is DAX

• DAX means Declarative API for XML
• A way to process XML
• By expressing what parts of a document
  you want to process
• Based on Java, Javascript and Cocoon
DAX History
• Feb 2005: Kim Wolk writes XMLTO, a .NET
  library that transforms XML into objects
• March 2005: Ryan Cox ports it to Java 5,
  using Annotations and dom4j‘s Transformer
  API
• 2006 to 2007: DAX is used in production at
  Mindquarry, adopted to Cocoon
DAX Modules and
 Dependencies
      DAX
DAX Modules and
  Dependencies
           DAX




DAX-Java
DAX Modules and
  Dependencies
           DAX




DAX-Java




 dom4j
DAX Modules and
  Dependencies
             DAX



             DAX-
DAX-Java
           Javascript



 dom4j
DAX Modules and
  Dependencies
             DAX



             DAX-
DAX-Java
           Javascript



 dom4j       Rhino
DAX Modules and
  Dependencies
             DAX



             DAX-        DAX-
DAX-Java
           Javascript   Cocoon



 dom4j       Rhino
DAX Modules and
  Dependencies
             DAX



             DAX-        DAX-
DAX-Java
           Javascript   Cocoon



 dom4j       Rhino      Cocoon
DAX-Java
DAX-Java         How to use it
public class ElementCounter extends Transformer {
  Map elements = new Hashmap<String, Integer>();
  public void processElement(Node context) {
    String name = context.getName();
    if (elements.hasKey(name)) {
      elements.put(name, elements.get(name) + 1);
    } else {
      elements.put(name, 1);
    }
  }
}
DAX-Java         How to use it
public class ElementCounter extends Transformer {
  Map elements = new Hashmap<String, Integer>();
  @Path(quot;*quot;) //select all elements
  public void processElement(Node context) {
    String name = context.getName();
    if (elements.hasKey(name)) {
      elements.put(name, elements.get(name) + 1);
    } else {
      elements.put(name, 1);
    }
  }
}
DAX-Java         How to use it
public class SourceCounter extends Transformer {
  Map sources = new Hashmap<String, Integer>();
  @Path(quot;img[@src]quot;) //select all elements
  public void processElement(Node context) {
    String name = this.valueOf(quot;@srcquot;);
    if (elements.hasKey(name)) {
      elements.put(name, elements.get(name) + 1);
    } else {
      elements.put(name, 1);
    }
  }
}
DAX-Java      How it works
 • Simple parsing algorithm:
  • traverse the DOM of the XML document
  • for each node, find an annotated method
     • with matching XPath
  • execute this method
 • Just like XSLT's templates
DAX-Java                   vs XSLT
                     DAX-Java                             XSLT

            @Path(quot;/foo/barquot;)
Templates   public void bar(Node context)
                                            <xsl:template match=quot;/foo/barquot;>




Value-Of    valueOf(quot;@barquot;)                 <xsl:value-of select=quot;@barquot; />



  Apply-    applyTemplates()                <xsl:apply-templates />
Templates
DAX-Javascript
DAX-Javascript    Why?
• XSLT is fine for transforming XML
• but no side-effects possible
• no access to external data model
    Input         XSLT          Output


                   ?
                  Model
DAX-Javascript       Background
   • Map most important XSLT concepts to
      Javascript concepts
          XSLT                          Javascript

   <xsl:stylesheet>                  Stylesheet object
                        template function of the Stylesheet
    <xsl:template>
                                        object
                          applyTemplate function of the
<xsl:apply-templates/>
                                 Stylesheet object
                       copy function of the Stylesheet object
      <xsl:copy/>
                            (with inlined body function)
DAX-Javascript    How to use it
<xsl:template match=quot;fooquot;>
  <bar>
    <xsl:comment>example code uses foo</xsl:comment>
    <xsl:apply-templates />
  </bar>
</xsl:template/>

Stylesheet.template({match:quot;fooquot;}, function(node) {
  this.element(quot;barquot;, function(node) {
    this.comment(quot;example code uses fooquot;);
    this.applyTemplates();
  });
});
DAX-Javascript     How to use it
<xsl:template match=quot;node()|@*quot;>
  <xsl:copy>
    <xsl:apply-templates select=quot;node()|@*quot; />
  </xsl:copy>
</xsl:template/>


Stylesheet.template({match:quot;node()|@*quot;}, function
(node) {
    this.copy(function(node) {
         this.applyTemplates({select:quot;node()|@*quot;})
    });
});
DAX-Javascript   How it works
  • Uses Rhino Javascript Engine
   • full access to Java object model
   • allows side-effects when transforming
      XML
  • Parses the incoming XML stream
  • Finds and fires matching functions
DAX-Cocoon
DAX-Cocoon        How to use it

<map:components>
  <map:transformers>
    <map:transformer name=quot;daxquot;
      src=quot;dax.cocoon.DAXTransformerquot; />
  </map:transformers>
</map:components>
DAX-Cocoon        How to use it
<map:match pattern=quot;/resource/*quot;>
  <map:select type=quot;request-methodquot;>
    <map:generate type=quot;streamquot; />
    <map:when test=quot;PUTquot;>
      <map:transform type=quot;daxquot; src=quot;dax/res.jsquot;>
        <map:parameter name=quot;resquot; value=quot;{1}quot; />
      </map:transform>
    </map:when>
  </map:select>
</map:match>
DAX-Cocoon        How to use it
var resourcemanager =
  cocoon.getComponent(quot;resourcemanagerquot;);

Stylesheet.template({match:quot;delquot;}, function(node) {
  var that = this;
  this.copy(function(node) {
    if (that.valueOf(quot;.quot;)==cocoon.parameters.res) {
      resourcemanager.delete(that.valueOf(quot;@nodequot;))
    }
    this.applyTemplates({select:quot;node()|@*quot;})
  });
});
DAX-Cocoon          How it works
 •   Implemented as a Cocoon Transformer
 •   Pull in quot;cocoonquot; object as Flowscript does
 •   Usage Scenario: REST Application
     •   validate using DAX (e.g. by checking
         database)
     •   transform using DAX (e.g by triggering
         actions)
     •   save using DAX (e.g. by changing model)
DAX-Cocoon           Open Questions

 •   Caching
     •   We do not know if a transformation has
         non-cacheable side-effects
 •   Mixing DAX and XSLT
     •   perhaps E4X is a way to conveniently
         embed XSLT
 •   Not all XSLT concepts implemented (sorting)
How to go on?
•   Read more

    •   http://www.asciiarmor.com/2005/03/03/introducing-
        dax-declarative-api-for-xml/

    •   https://www.mindquarry.org/wiki/dax/

    •   http://www.codeconsult.ch/bertrand/archives/
        000802.html

•   Download

    •   http://releases.mindquarry.org/dax/

    •   (Maven artifacts available)
Thank you very much
              lars@trieloff.net




 For more information, see my weblog at
 http://weblogs.goshaky.com/weblog/lars

Contenu connexe

Tendances

Spark Schema For Free with David Szakallas
 Spark Schema For Free with David Szakallas Spark Schema For Free with David Szakallas
Spark Schema For Free with David SzakallasDatabricks
 
Stratosphere System Overview Big Data Beers Berlin. 20.11.2013
Stratosphere System Overview Big Data Beers Berlin. 20.11.2013Stratosphere System Overview Big Data Beers Berlin. 20.11.2013
Stratosphere System Overview Big Data Beers Berlin. 20.11.2013Robert Metzger
 
AI&BigData Lab.Руденко Петр. Automation and optimisation of machine learning ...
AI&BigData Lab.Руденко Петр. Automation and optimisation of machine learning ...AI&BigData Lab.Руденко Петр. Automation and optimisation of machine learning ...
AI&BigData Lab.Руденко Петр. Automation and optimisation of machine learning ...GeeksLab Odessa
 
Deep Dive : Spark Data Frames, SQL and Catalyst Optimizer
Deep Dive : Spark Data Frames, SQL and Catalyst OptimizerDeep Dive : Spark Data Frames, SQL and Catalyst Optimizer
Deep Dive : Spark Data Frames, SQL and Catalyst OptimizerSachin Aggarwal
 
Spark Dataframe - Mr. Jyotiska
Spark Dataframe - Mr. JyotiskaSpark Dataframe - Mr. Jyotiska
Spark Dataframe - Mr. JyotiskaSigmoid
 
Hadoop MapReduce framework - Module 3
Hadoop MapReduce framework - Module 3Hadoop MapReduce framework - Module 3
Hadoop MapReduce framework - Module 3Rohit Agrawal
 
Stratosphere Intro (Java and Scala Interface)
Stratosphere Intro (Java and Scala Interface)Stratosphere Intro (Java and Scala Interface)
Stratosphere Intro (Java and Scala Interface)Robert Metzger
 
Practical Machine Learning Pipelines with MLlib
Practical Machine Learning Pipelines with MLlibPractical Machine Learning Pipelines with MLlib
Practical Machine Learning Pipelines with MLlibDatabricks
 
9781305078444 ppt ch07
9781305078444 ppt ch079781305078444 ppt ch07
9781305078444 ppt ch07Terry Yoast
 
Understanding C# in .NET
Understanding C# in .NETUnderstanding C# in .NET
Understanding C# in .NETmentorrbuddy
 
Collections Java e Google Collections
Collections Java e Google CollectionsCollections Java e Google Collections
Collections Java e Google CollectionsAndré Faria Gomes
 
Java8 training - class 3
Java8 training - class 3Java8 training - class 3
Java8 training - class 3Marut Singh
 
Introduction To R Language
Introduction To R LanguageIntroduction To R Language
Introduction To R LanguageGaurang Dobariya
 
Intro to Spark and Spark SQL
Intro to Spark and Spark SQLIntro to Spark and Spark SQL
Intro to Spark and Spark SQLjeykottalam
 
Photon Technical Deep Dive: How to Think Vectorized
Photon Technical Deep Dive: How to Think VectorizedPhoton Technical Deep Dive: How to Think Vectorized
Photon Technical Deep Dive: How to Think VectorizedDatabricks
 
Clojure - LISP on the JVM
Clojure - LISP on the JVM Clojure - LISP on the JVM
Clojure - LISP on the JVM Tikal Knowledge
 
Apache Flink Training Workshop @ HadoopCon2016 - #2 DataSet API Hands-On
Apache Flink Training Workshop @ HadoopCon2016 - #2 DataSet API Hands-OnApache Flink Training Workshop @ HadoopCon2016 - #2 DataSet API Hands-On
Apache Flink Training Workshop @ HadoopCon2016 - #2 DataSet API Hands-OnApache Flink Taiwan User Group
 

Tendances (20)

Spark Schema For Free with David Szakallas
 Spark Schema For Free with David Szakallas Spark Schema For Free with David Szakallas
Spark Schema For Free with David Szakallas
 
Stratosphere System Overview Big Data Beers Berlin. 20.11.2013
Stratosphere System Overview Big Data Beers Berlin. 20.11.2013Stratosphere System Overview Big Data Beers Berlin. 20.11.2013
Stratosphere System Overview Big Data Beers Berlin. 20.11.2013
 
Distributed computing with spark
Distributed computing with sparkDistributed computing with spark
Distributed computing with spark
 
AI&BigData Lab.Руденко Петр. Automation and optimisation of machine learning ...
AI&BigData Lab.Руденко Петр. Automation and optimisation of machine learning ...AI&BigData Lab.Руденко Петр. Automation and optimisation of machine learning ...
AI&BigData Lab.Руденко Петр. Automation and optimisation of machine learning ...
 
Deep Dive : Spark Data Frames, SQL and Catalyst Optimizer
Deep Dive : Spark Data Frames, SQL and Catalyst OptimizerDeep Dive : Spark Data Frames, SQL and Catalyst Optimizer
Deep Dive : Spark Data Frames, SQL and Catalyst Optimizer
 
Spark Dataframe - Mr. Jyotiska
Spark Dataframe - Mr. JyotiskaSpark Dataframe - Mr. Jyotiska
Spark Dataframe - Mr. Jyotiska
 
Hadoop MapReduce framework - Module 3
Hadoop MapReduce framework - Module 3Hadoop MapReduce framework - Module 3
Hadoop MapReduce framework - Module 3
 
Stratosphere Intro (Java and Scala Interface)
Stratosphere Intro (Java and Scala Interface)Stratosphere Intro (Java and Scala Interface)
Stratosphere Intro (Java and Scala Interface)
 
cb streams - gavin pickin
cb streams - gavin pickincb streams - gavin pickin
cb streams - gavin pickin
 
Practical Machine Learning Pipelines with MLlib
Practical Machine Learning Pipelines with MLlibPractical Machine Learning Pipelines with MLlib
Practical Machine Learning Pipelines with MLlib
 
9781305078444 ppt ch07
9781305078444 ppt ch079781305078444 ppt ch07
9781305078444 ppt ch07
 
Understanding C# in .NET
Understanding C# in .NETUnderstanding C# in .NET
Understanding C# in .NET
 
Collections Java e Google Collections
Collections Java e Google CollectionsCollections Java e Google Collections
Collections Java e Google Collections
 
Java8 training - class 3
Java8 training - class 3Java8 training - class 3
Java8 training - class 3
 
Introduction To R Language
Introduction To R LanguageIntroduction To R Language
Introduction To R Language
 
Intro to Spark and Spark SQL
Intro to Spark and Spark SQLIntro to Spark and Spark SQL
Intro to Spark and Spark SQL
 
Photon Technical Deep Dive: How to Think Vectorized
Photon Technical Deep Dive: How to Think VectorizedPhoton Technical Deep Dive: How to Think Vectorized
Photon Technical Deep Dive: How to Think Vectorized
 
Clojure - LISP on the JVM
Clojure - LISP on the JVM Clojure - LISP on the JVM
Clojure - LISP on the JVM
 
Streaming SQL
Streaming SQLStreaming SQL
Streaming SQL
 
Apache Flink Training Workshop @ HadoopCon2016 - #2 DataSet API Hands-On
Apache Flink Training Workshop @ HadoopCon2016 - #2 DataSet API Hands-OnApache Flink Training Workshop @ HadoopCon2016 - #2 DataSet API Hands-On
Apache Flink Training Workshop @ HadoopCon2016 - #2 DataSet API Hands-On
 

Similaire à Dax Declarative Api For Xml

Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of TonguesChoose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of TonguesCHOOSE
 
Introduction To Scala
Introduction To ScalaIntroduction To Scala
Introduction To ScalaPeter Maas
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Martin Odersky
 
Mazda Use of Third Generation Xml Tools
Mazda Use of Third Generation Xml ToolsMazda Use of Third Generation Xml Tools
Mazda Use of Third Generation Xml ToolsCardinaleWay Mazda
 
Red Hat Agile integration Workshop Labs
Red Hat Agile integration Workshop LabsRed Hat Agile integration Workshop Labs
Red Hat Agile integration Workshop LabsJudy Breedlove
 
eXtensible Markup Language (XML)
eXtensible Markup Language (XML)eXtensible Markup Language (XML)
eXtensible Markup Language (XML)Serhii Kartashov
 
No SQL, No problem - using MongoDB in Ruby
No SQL, No problem - using MongoDB in RubyNo SQL, No problem - using MongoDB in Ruby
No SQL, No problem - using MongoDB in Rubysbeam
 
MLlib sparkmeetup_8_6_13_final_reduced
MLlib sparkmeetup_8_6_13_final_reducedMLlib sparkmeetup_8_6_13_final_reduced
MLlib sparkmeetup_8_6_13_final_reducedChao Chen
 
Stepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to ScalaStepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to ScalaDerek Chen-Becker
 
Angular JS in 2017
Angular JS in 2017Angular JS in 2017
Angular JS in 2017Ayush Sharma
 
Scala4sling
Scala4slingScala4sling
Scala4slingday
 
Short intro to scala and the play framework
Short intro to scala and the play frameworkShort intro to scala and the play framework
Short intro to scala and the play frameworkFelipe
 
Ajax Introduction
Ajax IntroductionAjax Introduction
Ajax IntroductionOliver Cai
 
ApacheCon 2000 Everything you ever wanted to know about XML Parsing
ApacheCon 2000 Everything you ever wanted to know about XML ParsingApacheCon 2000 Everything you ever wanted to know about XML Parsing
ApacheCon 2000 Everything you ever wanted to know about XML ParsingTed Leung
 

Similaire à Dax Declarative Api For Xml (20)

Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of TonguesChoose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
 
Introduction To Scala
Introduction To ScalaIntroduction To Scala
Introduction To Scala
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009
 
treeview
treeviewtreeview
treeview
 
treeview
treeviewtreeview
treeview
 
Mazda Use of Third Generation Xml Tools
Mazda Use of Third Generation Xml ToolsMazda Use of Third Generation Xml Tools
Mazda Use of Third Generation Xml Tools
 
Red Hat Agile integration Workshop Labs
Red Hat Agile integration Workshop LabsRed Hat Agile integration Workshop Labs
Red Hat Agile integration Workshop Labs
 
eXtensible Markup Language (XML)
eXtensible Markup Language (XML)eXtensible Markup Language (XML)
eXtensible Markup Language (XML)
 
No SQL, No problem - using MongoDB in Ruby
No SQL, No problem - using MongoDB in RubyNo SQL, No problem - using MongoDB in Ruby
No SQL, No problem - using MongoDB in Ruby
 
MLlib sparkmeetup_8_6_13_final_reduced
MLlib sparkmeetup_8_6_13_final_reducedMLlib sparkmeetup_8_6_13_final_reduced
MLlib sparkmeetup_8_6_13_final_reduced
 
Sax Dom Tutorial
Sax Dom TutorialSax Dom Tutorial
Sax Dom Tutorial
 
Java XML Parsing
Java XML ParsingJava XML Parsing
Java XML Parsing
 
Stepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to ScalaStepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to Scala
 
Angular JS in 2017
Angular JS in 2017Angular JS in 2017
Angular JS in 2017
 
XML
XMLXML
XML
 
Reversing JavaScript
Reversing JavaScriptReversing JavaScript
Reversing JavaScript
 
Scala4sling
Scala4slingScala4sling
Scala4sling
 
Short intro to scala and the play framework
Short intro to scala and the play frameworkShort intro to scala and the play framework
Short intro to scala and the play framework
 
Ajax Introduction
Ajax IntroductionAjax Introduction
Ajax Introduction
 
ApacheCon 2000 Everything you ever wanted to know about XML Parsing
ApacheCon 2000 Everything you ever wanted to know about XML ParsingApacheCon 2000 Everything you ever wanted to know about XML Parsing
ApacheCon 2000 Everything you ever wanted to know about XML Parsing
 

Plus de Lars Trieloff

Putting the F in FaaS: Functional Compositional Patterns in a Serverless World
Putting the F in FaaS: Functional Compositional Patterns in a Serverless WorldPutting the F in FaaS: Functional Compositional Patterns in a Serverless World
Putting the F in FaaS: Functional Compositional Patterns in a Serverless WorldLars Trieloff
 
Serverless adventures with AWS Lambda and Clojure
Serverless adventures with AWS Lambda and ClojureServerless adventures with AWS Lambda and Clojure
Serverless adventures with AWS Lambda and ClojureLars Trieloff
 
Data Natives 2015: Predictive Applications are Going to Steal Your Job: this ...
Data Natives 2015: Predictive Applications are Going to Steal Your Job: this ...Data Natives 2015: Predictive Applications are Going to Steal Your Job: this ...
Data Natives 2015: Predictive Applications are Going to Steal Your Job: this ...Lars Trieloff
 
How to get value out of data
How to get value out of dataHow to get value out of data
How to get value out of dataLars Trieloff
 
Smartcon 2015 – Automated Decisions in the Supply Chain
Smartcon 2015 – Automated Decisions in the Supply ChainSmartcon 2015 – Automated Decisions in the Supply Chain
Smartcon 2015 – Automated Decisions in the Supply ChainLars Trieloff
 
Business Reasons for Predictive Applications
Business Reasons for Predictive ApplicationsBusiness Reasons for Predictive Applications
Business Reasons for Predictive ApplicationsLars Trieloff
 
ADDD (Automated Data Driven Decisions) – How To Make it Work
ADDD (Automated Data Driven Decisions) – How To Make it WorkADDD (Automated Data Driven Decisions) – How To Make it Work
ADDD (Automated Data Driven Decisions) – How To Make it WorkLars Trieloff
 
Automated decision making with predictive applications – Big Data Frankfurt
Automated decision making with predictive applications – Big Data FrankfurtAutomated decision making with predictive applications – Big Data Frankfurt
Automated decision making with predictive applications – Big Data FrankfurtLars Trieloff
 
Automated Decision making with Predictive Applications – Big Data Hamburg
Automated Decision making with Predictive Applications – Big Data HamburgAutomated Decision making with Predictive Applications – Big Data Hamburg
Automated Decision making with Predictive Applications – Big Data HamburgLars Trieloff
 
Automated Decision Making with Predictive Applications – Big Data Düsseldorf
Automated Decision Making with Predictive Applications – Big Data DüsseldorfAutomated Decision Making with Predictive Applications – Big Data Düsseldorf
Automated Decision Making with Predictive Applications – Big Data DüsseldorfLars Trieloff
 
Automated decision making with predictive applications – Big Data Brussels
Automated decision making with predictive applications – Big Data BrusselsAutomated decision making with predictive applications – Big Data Brussels
Automated decision making with predictive applications – Big Data BrusselsLars Trieloff
 
Automated decision making with predictive applications – Big Data Amsterdam
Automated decision making with predictive applications – Big Data AmsterdamAutomated decision making with predictive applications – Big Data Amsterdam
Automated decision making with predictive applications – Big Data AmsterdamLars Trieloff
 
Automated decision making using Predictive Applications – Big Data Paris
Automated decision making using Predictive Applications – Big Data ParisAutomated decision making using Predictive Applications – Big Data Paris
Automated decision making using Predictive Applications – Big Data ParisLars Trieloff
 
Automated decision making with big data – Big Data Vienna
Automated decision making with big data – Big Data ViennaAutomated decision making with big data – Big Data Vienna
Automated decision making with big data – Big Data ViennaLars Trieloff
 
Big Data Munich – Decision Automation and Big Data
Big Data Munich – Decision Automation and Big DataBig Data Munich – Decision Automation and Big Data
Big Data Munich – Decision Automation and Big DataLars Trieloff
 
10 Things I Learned About Pricing – Product Camp Berlin 2014
10 Things I Learned About Pricing – Product Camp Berlin 201410 Things I Learned About Pricing – Product Camp Berlin 2014
10 Things I Learned About Pricing – Product Camp Berlin 2014Lars Trieloff
 
Big Data Berlin – Automating Decisions is the Next Frontier for Big Data
Big Data Berlin – Automating Decisions is the Next Frontier for Big DataBig Data Berlin – Automating Decisions is the Next Frontier for Big Data
Big Data Berlin – Automating Decisions is the Next Frontier for Big DataLars Trieloff
 
The DNA of Marketing
The DNA of MarketingThe DNA of Marketing
The DNA of MarketingLars Trieloff
 
Cross community campaigns with CQ5
Cross community campaigns with CQ5Cross community campaigns with CQ5
Cross community campaigns with CQ5Lars Trieloff
 
Mastering the customer engagement ecosystem with CQ5
Mastering the customer engagement ecosystem with CQ5Mastering the customer engagement ecosystem with CQ5
Mastering the customer engagement ecosystem with CQ5Lars Trieloff
 

Plus de Lars Trieloff (20)

Putting the F in FaaS: Functional Compositional Patterns in a Serverless World
Putting the F in FaaS: Functional Compositional Patterns in a Serverless WorldPutting the F in FaaS: Functional Compositional Patterns in a Serverless World
Putting the F in FaaS: Functional Compositional Patterns in a Serverless World
 
Serverless adventures with AWS Lambda and Clojure
Serverless adventures with AWS Lambda and ClojureServerless adventures with AWS Lambda and Clojure
Serverless adventures with AWS Lambda and Clojure
 
Data Natives 2015: Predictive Applications are Going to Steal Your Job: this ...
Data Natives 2015: Predictive Applications are Going to Steal Your Job: this ...Data Natives 2015: Predictive Applications are Going to Steal Your Job: this ...
Data Natives 2015: Predictive Applications are Going to Steal Your Job: this ...
 
How to get value out of data
How to get value out of dataHow to get value out of data
How to get value out of data
 
Smartcon 2015 – Automated Decisions in the Supply Chain
Smartcon 2015 – Automated Decisions in the Supply ChainSmartcon 2015 – Automated Decisions in the Supply Chain
Smartcon 2015 – Automated Decisions in the Supply Chain
 
Business Reasons for Predictive Applications
Business Reasons for Predictive ApplicationsBusiness Reasons for Predictive Applications
Business Reasons for Predictive Applications
 
ADDD (Automated Data Driven Decisions) – How To Make it Work
ADDD (Automated Data Driven Decisions) – How To Make it WorkADDD (Automated Data Driven Decisions) – How To Make it Work
ADDD (Automated Data Driven Decisions) – How To Make it Work
 
Automated decision making with predictive applications – Big Data Frankfurt
Automated decision making with predictive applications – Big Data FrankfurtAutomated decision making with predictive applications – Big Data Frankfurt
Automated decision making with predictive applications – Big Data Frankfurt
 
Automated Decision making with Predictive Applications – Big Data Hamburg
Automated Decision making with Predictive Applications – Big Data HamburgAutomated Decision making with Predictive Applications – Big Data Hamburg
Automated Decision making with Predictive Applications – Big Data Hamburg
 
Automated Decision Making with Predictive Applications – Big Data Düsseldorf
Automated Decision Making with Predictive Applications – Big Data DüsseldorfAutomated Decision Making with Predictive Applications – Big Data Düsseldorf
Automated Decision Making with Predictive Applications – Big Data Düsseldorf
 
Automated decision making with predictive applications – Big Data Brussels
Automated decision making with predictive applications – Big Data BrusselsAutomated decision making with predictive applications – Big Data Brussels
Automated decision making with predictive applications – Big Data Brussels
 
Automated decision making with predictive applications – Big Data Amsterdam
Automated decision making with predictive applications – Big Data AmsterdamAutomated decision making with predictive applications – Big Data Amsterdam
Automated decision making with predictive applications – Big Data Amsterdam
 
Automated decision making using Predictive Applications – Big Data Paris
Automated decision making using Predictive Applications – Big Data ParisAutomated decision making using Predictive Applications – Big Data Paris
Automated decision making using Predictive Applications – Big Data Paris
 
Automated decision making with big data – Big Data Vienna
Automated decision making with big data – Big Data ViennaAutomated decision making with big data – Big Data Vienna
Automated decision making with big data – Big Data Vienna
 
Big Data Munich – Decision Automation and Big Data
Big Data Munich – Decision Automation and Big DataBig Data Munich – Decision Automation and Big Data
Big Data Munich – Decision Automation and Big Data
 
10 Things I Learned About Pricing – Product Camp Berlin 2014
10 Things I Learned About Pricing – Product Camp Berlin 201410 Things I Learned About Pricing – Product Camp Berlin 2014
10 Things I Learned About Pricing – Product Camp Berlin 2014
 
Big Data Berlin – Automating Decisions is the Next Frontier for Big Data
Big Data Berlin – Automating Decisions is the Next Frontier for Big DataBig Data Berlin – Automating Decisions is the Next Frontier for Big Data
Big Data Berlin – Automating Decisions is the Next Frontier for Big Data
 
The DNA of Marketing
The DNA of MarketingThe DNA of Marketing
The DNA of Marketing
 
Cross community campaigns with CQ5
Cross community campaigns with CQ5Cross community campaigns with CQ5
Cross community campaigns with CQ5
 
Mastering the customer engagement ecosystem with CQ5
Mastering the customer engagement ecosystem with CQ5Mastering the customer engagement ecosystem with CQ5
Mastering the customer engagement ecosystem with CQ5
 

Dernier

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 

Dernier (20)

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 

Dax Declarative Api For Xml

  • 1. DAX: Where Flowscript meets XSLT Lars Trieloff, Mindquarry
  • 2. Lars Trieloff • Entrepreneur, Blogger, Open Source Coder • OSS Projects • Apache Cocoon • Mindquarry • Goshaky • DAX
  • 3. What is DAX • DAX means Declarative API for XML • A way to process XML • By expressing what parts of a document you want to process • Based on Java, Javascript and Cocoon
  • 4. DAX History • Feb 2005: Kim Wolk writes XMLTO, a .NET library that transforms XML into objects • March 2005: Ryan Cox ports it to Java 5, using Annotations and dom4j‘s Transformer API • 2006 to 2007: DAX is used in production at Mindquarry, adopted to Cocoon
  • 5. DAX Modules and Dependencies DAX
  • 6. DAX Modules and Dependencies DAX DAX-Java
  • 7. DAX Modules and Dependencies DAX DAX-Java dom4j
  • 8. DAX Modules and Dependencies DAX DAX- DAX-Java Javascript dom4j
  • 9. DAX Modules and Dependencies DAX DAX- DAX-Java Javascript dom4j Rhino
  • 10. DAX Modules and Dependencies DAX DAX- DAX- DAX-Java Javascript Cocoon dom4j Rhino
  • 11. DAX Modules and Dependencies DAX DAX- DAX- DAX-Java Javascript Cocoon dom4j Rhino Cocoon
  • 13. DAX-Java How to use it public class ElementCounter extends Transformer { Map elements = new Hashmap<String, Integer>(); public void processElement(Node context) { String name = context.getName(); if (elements.hasKey(name)) { elements.put(name, elements.get(name) + 1); } else { elements.put(name, 1); } } }
  • 14. DAX-Java How to use it public class ElementCounter extends Transformer { Map elements = new Hashmap<String, Integer>(); @Path(quot;*quot;) //select all elements public void processElement(Node context) { String name = context.getName(); if (elements.hasKey(name)) { elements.put(name, elements.get(name) + 1); } else { elements.put(name, 1); } } }
  • 15. DAX-Java How to use it public class SourceCounter extends Transformer { Map sources = new Hashmap<String, Integer>(); @Path(quot;img[@src]quot;) //select all elements public void processElement(Node context) { String name = this.valueOf(quot;@srcquot;); if (elements.hasKey(name)) { elements.put(name, elements.get(name) + 1); } else { elements.put(name, 1); } } }
  • 16. DAX-Java How it works • Simple parsing algorithm: • traverse the DOM of the XML document • for each node, find an annotated method • with matching XPath • execute this method • Just like XSLT's templates
  • 17. DAX-Java vs XSLT DAX-Java XSLT @Path(quot;/foo/barquot;) Templates public void bar(Node context) <xsl:template match=quot;/foo/barquot;> Value-Of valueOf(quot;@barquot;) <xsl:value-of select=quot;@barquot; /> Apply- applyTemplates() <xsl:apply-templates /> Templates
  • 19. DAX-Javascript Why? • XSLT is fine for transforming XML • but no side-effects possible • no access to external data model Input XSLT Output ? Model
  • 20. DAX-Javascript Background • Map most important XSLT concepts to Javascript concepts XSLT Javascript <xsl:stylesheet> Stylesheet object template function of the Stylesheet <xsl:template> object applyTemplate function of the <xsl:apply-templates/> Stylesheet object copy function of the Stylesheet object <xsl:copy/> (with inlined body function)
  • 21. DAX-Javascript How to use it <xsl:template match=quot;fooquot;> <bar> <xsl:comment>example code uses foo</xsl:comment> <xsl:apply-templates /> </bar> </xsl:template/> Stylesheet.template({match:quot;fooquot;}, function(node) { this.element(quot;barquot;, function(node) { this.comment(quot;example code uses fooquot;); this.applyTemplates(); }); });
  • 22. DAX-Javascript How to use it <xsl:template match=quot;node()|@*quot;> <xsl:copy> <xsl:apply-templates select=quot;node()|@*quot; /> </xsl:copy> </xsl:template/> Stylesheet.template({match:quot;node()|@*quot;}, function (node) { this.copy(function(node) { this.applyTemplates({select:quot;node()|@*quot;}) }); });
  • 23. DAX-Javascript How it works • Uses Rhino Javascript Engine • full access to Java object model • allows side-effects when transforming XML • Parses the incoming XML stream • Finds and fires matching functions
  • 25. DAX-Cocoon How to use it <map:components> <map:transformers> <map:transformer name=quot;daxquot; src=quot;dax.cocoon.DAXTransformerquot; /> </map:transformers> </map:components>
  • 26. DAX-Cocoon How to use it <map:match pattern=quot;/resource/*quot;> <map:select type=quot;request-methodquot;> <map:generate type=quot;streamquot; /> <map:when test=quot;PUTquot;> <map:transform type=quot;daxquot; src=quot;dax/res.jsquot;> <map:parameter name=quot;resquot; value=quot;{1}quot; /> </map:transform> </map:when> </map:select> </map:match>
  • 27. DAX-Cocoon How to use it var resourcemanager = cocoon.getComponent(quot;resourcemanagerquot;); Stylesheet.template({match:quot;delquot;}, function(node) { var that = this; this.copy(function(node) { if (that.valueOf(quot;.quot;)==cocoon.parameters.res) { resourcemanager.delete(that.valueOf(quot;@nodequot;)) } this.applyTemplates({select:quot;node()|@*quot;}) }); });
  • 28. DAX-Cocoon How it works • Implemented as a Cocoon Transformer • Pull in quot;cocoonquot; object as Flowscript does • Usage Scenario: REST Application • validate using DAX (e.g. by checking database) • transform using DAX (e.g by triggering actions) • save using DAX (e.g. by changing model)
  • 29. DAX-Cocoon Open Questions • Caching • We do not know if a transformation has non-cacheable side-effects • Mixing DAX and XSLT • perhaps E4X is a way to conveniently embed XSLT • Not all XSLT concepts implemented (sorting)
  • 30. How to go on? • Read more • http://www.asciiarmor.com/2005/03/03/introducing- dax-declarative-api-for-xml/ • https://www.mindquarry.org/wiki/dax/ • http://www.codeconsult.ch/bertrand/archives/ 000802.html • Download • http://releases.mindquarry.org/dax/ • (Maven artifacts available)
  • 31. Thank you very much lars@trieloff.net For more information, see my weblog at http://weblogs.goshaky.com/weblog/lars