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

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Dernier (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

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