XML at the ASF ApacheCon 2005 -...

51
ApacheCon 2005 December 2005 XML at the ASF Ted Leung [email protected]

Transcript of XML at the ASF ApacheCon 2005 -...

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 1

XML at the ASF

Ted Leung

[email protected]

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 2

Copyright © Sauria Associates, LLC ApacheCon 2005 2

Overview xml.apache.org

Xerces Xalan FOP Batik Xindice Forrest XML-Security XML-Commons XMLBeans

cocoon.apache.org Cocoon Lenya

There are three major XML focused projects at the ASF.

Originally there was one project, xml.apache.org. Earlier this year, the Cocoon andweb services projects were formed.

Xml.apache.org contains a number of projects that are general purpose XML tools.Most of these tools are based on specifications from the World Wide WebConsortium. This includes XML itself, XSLT, XSL Formatting object, ScalableVector Graphics, and XML Signature and XML Encryption

The web services project, ws.apache.org contains projects that cluster aroundstandards for dealing with Web Services, including SOAP and XML-RPC

The Cocoon project is oriented around the Cocoon Web publishing frameworkwhich is basd on XML, XSLT, and a number of other XML related technologies.

I’m not going to be able to give you any deep technical details regarding all of theseprojects. Instead, I’m going to try to describe what these projects are, whatstandards they implement, and talk about situations where you might use them.

Unless I say otherwise, I’m going to be covering the Java projects. There are a fewprojects which have C/C++ versions and I’ll mention that where applicable.

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 3

Copyright © Sauria Associates, LLC ApacheCon 2005 3

ws.apache.org XML-RPC Axis(2) Woden (incubation) WSIF JaxMe jUDDI

Muse Pubscribe Sandesha Scout Addressing EWS Kandula Mirae Muse TSIK (incubation) WSS4J WSRF

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 4

4

XML

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 5

Copyright © Sauria Associates, LLC ApacheCon 2005 5

Xerces-J

<?xml version="1.0" encoding="UTF-8"?><books xmlns="http://sauria.com/schemas/apache-xml-book/books" xmlns:tns="http://sauria.com/schemas/apache-xml-book/books" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation= "http://sauria.com/schemas/apache-xml-book/books http://www.sauria.com/schemas/apache-xml-book/books.xsd" version="1.0"> <book> <title>Effective Java</title> <author>Joshua Bloch</author> <isbn>yyy-yyyyyyyyyy</isbn> <month>August</month> <year>2001</year> <publisher>Addison-Wesley</publisher> <address>New York, New York</address> </book></books>

Xerces-J is an XML parser written in Java. There is also a C++ version Xerces-C,and a Perl wrapper for the C Version called Xerces-P

The job of an XML parser is to break an XML document up into its constituentparts:ElementsAttributesCharacter data

The parser also verifies that the document obeys the rules of XML:Well-formednessValidity (optional)Namespace rules

The parts are exposed to an application via an API of some sort.

XML Parsing is the fundamental building block for just about every XML basedapplication and technology

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 6

Copyright © Sauria Associates, LLC ApacheCon 2005 6

Xerces-J Provide API’s to the parts

SAX DOM XNI XNI-based pull

Validation DTDs XML Schema Support Relax NG support via Andy Clark’s Neko Tools for XNI

When would I use it? Everywhere

Xerces provides 4 APIs for accessing the parts of an XML document

SAX – defacto standard - event callback based – produces “event streams”DOM – W3C standard – tree oriented object model – produces a DOM treeXNI – Xerces Native Interface – event callback basedXNI-based pull – CyberNeko – allows inversion of control

There are three major standards for validating XML documents. Xerces has built insupport for 2 and added support for the third.

Xerces has built in support for XML DTD’s and the W3C XML SchemaVia Andy Clark’s CyberNeko Tools for XNI, Xerces has support for OASIS’s RelaxNG

XML parsing provides the foundation layer for most XML applications. If you areusing XML the question isn’t so much when would Iuse an XML parser, the question is, will I know that I am using an XML parser.Some of the projects that I’ll discuss in this talk use anXML parser as part of their implementation

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 7

Copyright © Sauria Associates, LLC ApacheCon 2005 7

Xalan-J What does it do?

XSLT Processor

Converts one kind of XML into another Uses a stylesheet (XML document) Stylesheet describes tree transformation Declarative programming model

Based on pattern matching

Xalan-J is an XSLT processor. As with Xerces, there is also a C++ version.

XSLT is the XSL Transformations language. It is a declarative language fordescribing how to transform a source XML document into another XML document.The transformations are specified via an XML document called an XSLT stylesheet

XSLT views every XML document as a tree of nodes, similar to the DOM model.Transformations on documents correspond to transformations of the input tree

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 8

Copyright © Sauria Associates, LLC ApacheCon 2005 8

Xalan-J<html><head><META http-equiv="Content-Type"content="text/html; charset=UTF-8"><title>Book Inventory</title></head><body><em>Effective Java</em><br><b>Joshua Bloch</b><br> yyy-yyyyyyyyyy<br> August,

2001<br> Addison-Wesley<br> New York, New York<br><p></p></body></html>

<?xml version="1.0"?><books> <book> <title>Effective Java</title> <author>Joshua Bloch</author> <isbn>yyy-yyyyyyyyyy</isbn> <month>August</month> <year>2001</year> <publisher>Addison-Wesley</publisher> <address>New York, NewYork</address> </book></books>

Here’s a simple example of the way that XSLT can be used to transform XML intoanother XML dialect.

Conveniently, HTML can also be viewed as an XML vocabulary, so we can useXSLT to convert XML data into HTML

In this diagram, the arrows show how various parts of the XML document gettransformed into the HTML document.

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 9

Copyright © Sauria Associates, LLC ApacheCon 2005 9

Xalan-J<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:books="http://sauria.com/schemas/apache-xml-book/books" exclude-result-prefixes="books"> <xsl:output method="html" version="4.0" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/> <xsl:template match="books:books"> <html> <head><title>Book Inventory</title></head> <body> <xsl:apply-templates/> </body> </html> </xsl:template> <xsl:template match="books:book"> <xsl:apply-templates/> <p /> </xsl:template> <xsl:template match="books:title"> <em><xsl:value-of select="."/></em><br /> </xsl:template> …

This is a portion of the XSLT stylesheet that produced the HTML document in theprevious slide

The important thing to look at here is the <xsl:template> elements, which show howthe pattern matching model of XSLT functions.The template matches, some nodes are inserted into the result tree. More templatescan be tried if <xsl:apply-templates/> appears in the template body

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 10

Copyright © Sauria Associates, LLC ApacheCon 2005 10

Xalan-J TrAX API is part of JAXP XSLTC Compiler Extensions

EXSLT Xalan specific

When would I use it? Convert XML to HTML Convert XML to XML

WML Vocabulary translation

For More: TU08: Intro to XSLT Tues 10:30

JAXP provides an API for dealing with an XSLT processorThis API is called TrAX, which stands for Transformation API for XML.In JDK 1.4 and above, the reference implementation for TrAX is provided by Xalan

Xalan provides two XSLT processing engines.The default engine interprets XSLT stylesheets as it transforms a document.The XSLTC engine compiles XSLT stylesheets into Java programs called translets. The translets arethen executed to transform the documentThis approach has large performance benefits in scenarios where the documents being transformeduse a fixed grammar or set of grammars.

Xalan allows two forms of extensions:It supports the EXSLT XSLT extension library found at http://www.exslt.orgXalan also includes is own mechanism for defining XSLT extensions.This allows you to define extension elements (in XSLT stylesheets) and extension functions (whichcan be used in XPath expressions).

I’ve already show an example of using XSLT to convert XML to HTML. You can build entire websites this way, and use XSLT to generate the right kind of output format – HTML, XHTML, WMLand so on.If you are doing publishing, this kind of single input multiple output should be very appealing.There are also lots of applications where you need to take XML data that uses a grammar and convertit into another grammar. XSLT can be very useful in these situations as well.

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 11

Copyright © Sauria Associates, LLC ApacheCon 2005 11

FOP What does it do?

XSL Processor Convert XML with XSL elements into non

XML formats

FOP is an XSL Formatting Object processor

XSL Formatting Objects is a W3C Recommendation that uses XML markup todescribe how to render a document.The usual rendering is a non-XML format. The XSL specification contains lots ofconstructs for specifying precise layout and page control.

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 12

Copyright © Sauria Associates, LLC ApacheCon 2005 12

FOP – XSL Input<?xml version="1.0" encoding="UTF-8"?><fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> <fo:layout-master-set> <fo:simple-page-master margin-right="0.5in" margin-left="0.5in" margin-bottom="0.5in" margin-top="0.5in" page-width="8.5in" page-height="11in" master-name="book-page"> <fo:region-body margin="1in"/> </fo:simple-page-master> </fo:layout-master-set> <fo:page-sequence master-reference="book-page"> <fo:flow flow-name="xsl-region-body"> <fo:block> <fo:list-block provisional-label-separation="3pt" provisional-distance-between-starts="18pt"> <fo:list-item> <fo:list-item-label> <fo:block space-after.optimum="15pt"> <fo:inline font-size="14pt">• Effective Java</fo:inline> </fo:block> </fo:list-item-label>

Here’s an example of an XSL FO document

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 13

Copyright © Sauria Associates, LLC ApacheCon 2005 13

FOP – PDF output <fo:list-item-body> <fo:block space-after.optimum="15pt"> <fo:inline font-weight="bold">Joshua Bloch</fo:inline> <fo:inline>yyy-yyyyyyyyyy</fo:inline> <fo:inline>August, </fo:inline> <fo:inline>2001</fo:inline> <fo:inline>Addison-Wesley</fo:inline> <fo:inline>New York, New York</fo:inline> </fo:block> </fo:list-item-body> </fo:list-item> </fo:list-block> </fo:block> </fo:flow> </fo:page-sequence></fo:root>

Here is the rest of the document, and the top of the PDF file that FOP generates

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 14

Copyright © Sauria Associates, LLC ApacheCon 2005 14

FOP Supported formats include

PDF PostScript RTF

Font Handling Hyphenation When would I use it?

Any where you need a format that FOP canproduce

FOP can generate a variety of formats includingPDFPostScriptRTFText

FOP provides utilities that can read font metrics files for TrueType and Adobe Type1 fonts.

FOP can use TeX hyphenation dictionaries

The choice of whether you need FOP is driven by the needs of your application. Ifyou have XML data, and you need PDF, or PostScript or one of the other formatsthat FOP supports, then you’ll need to use FOP. Once you’ve determined that youneed to use FOP, you’ll need to find a way to obtain an XSL Formatting Objectsdocument that describes how to layout your XML data. This is actually where mostof the work will be. Calling FOP from your application is relativelystraightforward.

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 15

Copyright © Sauria Associates, LLC ApacheCon 2005 15

Batik What does it do?

Scalable Vector Graphics (SVG) Vector drawing commands as XML Declarative animation Imperative animation (scripting)

Batik is a toolkit for working with Scalable Vector Graphics (SVG)

SVG is a Recommendation of the W3C and provides an XML vocabulary fordescribing vector graphics drawing commands.

SVG is able to render complex vector diagrams.

SVG can also perform animation. There are two modes, declarative andimperative.In declarative animation, SVG uses animation elements from the SynchronizedMultimedia Integration Language (SMIL) to animate SVG objects.In imperative animation, an SVG document includes scripting elements whichoperate on an SVG specific version of the DOM. The scripts in these elements areable to update elements in the SVG document. When these elements are updated,the SVG browser updates the SVG image, thus achieving an animation style effect.

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 16

Copyright © Sauria Associates, LLC ApacheCon 2005 16

Batik<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"><svg width="5in" height="3in" viewBox="0 0 800 600" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <g id="plainPath"> <path style="stroke:black; fill:none" d="M 0 200 C 100 100 200 0 300 100 C 400 200 500 300 600 200 C 700 100 800 100 800 100"/> </g>

<g id="labelledPath" transform="translate(0,200)"> <path id="followMe" style="stroke:blue; fill:none" d="M 0 200 C 100 100 200 0 300 100 C 400 200 500 300 600 200 C 700 100 800 100 800 100"/> <text font-family="Verdana" font-size="42.5" fill="blue" > <textPath xlink:href="#followMe" startOffset="40"> Just following my way along the path here </textPath> </text> </g></svg>

Here is a sample SVG document that shows how to draw a path, and then showshow to wrap a piece of text along a path.

The resulting image is shown just to the right of the SVG document.

Let me stop here and give you a short animation demonstration.

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 17

Copyright © Sauria Associates, LLC ApacheCon 2005 17

Batik Toolbox

SVGGraphics2D JSVGCanvas Browser Image Transcoding Rasterizer Scripting

When would I use it? Graphical Output – Static or Dynamic Flash-like user interfaces

Batik provides a toolbox for working with SVG. Here are some of the components included in that toolbox.

SVGGraphics2D – This class is derived from the java.awt.Graphics2D class. It allows you to use standardGraphics2D drawing methods to construct an image that will be represented as SVG. All you do is createan SVGGraphics2D, call the desired drawing methods, and call some methods to write the SVG file.

JSVGCanvas – This class is a Swing component that knows how to render an SVG file as a graphical image.

Browser – Batik includes a stand alone SVG Browser that is built using the JSVGCanva component

Image Transcoding - Batik includes classes that allow you to convert SVG documents into JPEG, GIF, PNG, orTIFF files.

Rasterizer – The Batik Rasterizer is a standalone program that lets you use the Batik Image Transcoding classesto generate JPEG, GIF, PNG, or TIFF files.

Scripting – JSVGCanvas provides access to the SVG DOM so that you can do imperative animation. Thedefault scripting language is the Java-based Rhino engine, which implements Java/EcmaScript. JPython andJacl can also be used as scripting languages

There are two broad classes of use for Batik and SVG.1. You need to display some graphics from data that is encoded as XML.2. You want to create an interactive user interface ala Flash

The drawback of using SVG on the client is that it requires an SVG browser or the Adobe SVG PluginFor static images you can get around this by using the Batik image transcoding functionality to generate image

files.

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 18

Copyright © Sauria Associates, LLC ApacheCon 2005 18

Xindice What does it do?

Native XML Database

XML:DB API Collections of XML Documents Searchable by XPath XUpdate

When would I use it? You want to store XML directly You need XPath query capability

Xindice is a “native XML database” as defined by XML:DB initiaiveThe idea behind native XML databases is that they

Define a logical model for an XML document, which must include elements,attributes, character data and document order

Have an XML document as the fundamental unit of storageAre not bound to a storage model (relational, object-oriented, hierarchical)

This means that the database “understands” XML and allows you to refer to documents and pieces ofXML documents.

Xindice implements the XML:DB API.The API is organized around Collections of Resources which are usually XML documents inXindice.Resources can be created or retrieved as SAX event streams or DOM trees.Collections can be indexed. Indexes can be build on element names, attribute names andcombinations of element and attribute names.Xindice implements querying via XPath. Queries return sets of resources that match the XPathexpressionXindice uses the XUpdates specification to perform updates. XUpdate uses XML documents todescribe updates to a native XML database

Xindice is a good choice if the native XML database philosophy is attractive to you, and if yourapplication can benefit by using XPath as a query language over collections of XML documents

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 19

Copyright © Sauria Associates, LLC ApacheCon 2005 19

XML Commons What does it do?

Reusable components SAX and DOM Which Resolver

OASIS XML Catalogs OASIS TR9401 Catalogs XCatalog

When would I use it?

The XML Commons project is part of xml.apache.org. It is intended to serve as arepository for code that would be useful tomultiple projects

It contains two groups of projects at the moment.

The first group is code that is maintained outside the ASF but which is used by ASFprojects.This includes the SAX and DOM API’s.

The second group is a set of utiltilies:

Which is a simple utility for determining the state of the Java environment,including the versions of Xerces and Xalan.

Resolver is a set of classes which can be used as SAX entity resolvers.These resolvers provide support for

OASIS XML CatalogsOASIS TR9401 CatalogsXCatalog

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 20

Copyright © Sauria Associates, LLC ApacheCon 2005 20

XML-Security What does it do?

XML Digital Signature XML Encryption

The XML-Security project is working to provide implementations for the W3C’sXML Digital Signature and XML Encryption recommendations.

The goal of both of these specifications is to describe how digital signatures andencryption work in the context of XML documents.

There are two issues that need to be addressed:1. How to sign/encrypt at a granularity smaller than an entire document – element

wise2. How to provide the information that the recipient needs to verify/decrypt the

document – public keys, encryption algorithms, etc.

Both Java and C++ versions are in development

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 21

Copyright © Sauria Associates, LLC ApacheCon 2005 21

XML-Security<?xml version="1.0" encoding="UTF-8"?><book version="1.0" xmlns="http://sauria.com/schemas/apache-xml-book/book" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://sauria.com/schemas/apache-xml-book/book http://www.sauria.com/schemas/apache-xml-book/book.xsd"> <title>Apache XML Tools</title> <xenc:EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"> <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"/> <xenc:CipherData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"> <xenc:CipherValue xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">Pyn0AqcaMaCg5Cv1wy5sDe0I1aox/JzvupzyXcS0AGilXaF4SCbBaiBVS33KxGS8P </xenc:CipherValue> </xenc:CipherData> </xenc:EncryptedData> <isbn>xxx-xxxxxxxxxx</isbn> <month>October</month> <year>2003</year> <publisher>John Wiley and Sons</publisher> <address>New York, New York</address></book>

Here is an example of an encrypted XML document.

You’ll see that this is the book document that I’ve been using as an examplethroughout the talk.

In this case, I’ve used XML-Security to encrypt the <author> element.So you can see that the <author> element has been replaced by elements from thexenc namespace.

The author element has been encrypted with 256 AES, and the encrypted value ispresent as the value of the<xenc:CipherValue> element.

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 22

Copyright © Sauria Associates, LLC ApacheCon 2005 22

XML-Security When would I use it?

When you need digital signatures When you need encryption XML based workflows

The scenarios where you would use XML-Security are the same ones where youwould use digital signatures or encryption.

XML-Security gives you the freedom to restrict signatures or encryption to just theportion of that data that needs to be signed or encrypted.

This can be especially useful during workflows, so that different parts of the samedocument can be signed or encrypted differently according to the needs of thevarious recipients along the workflow.

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 23

Copyright © Sauria Associates, LLC ApacheCon 2005 23

XMLBeans What does it do?

XML instance <-> Java instances Based on XML Schema mapping Populate JavaBeans from XML Generate XML from JavaBeans

Cursor based navigation of XML Select XML based using XPath

When would I use it? You need to map between XML and Java

XMLBeans is a project under incubation. Its ultimate destination is xml.apache.org

It is a system that uses XML Schema definitions to create Java interfaces that can beused to access data in an XML documentThese interfaces can also be used to generate XML data from Java instances

XMLBeans supports all the features of XML Schema, whereas JAXB does not.

XMLBeans represents the data internally as XML to reduce the overhead ofconverting back and forth from XML.

In addition to mapping XML instances to Java instances, XMLBeans provides anavigation API based on cursors. You canAsk an XMLBean to give you a cursor, and then ask the cursor to advance throughthe XML. You can modify the document as you traverse it.The cursor API also allows you to use XPath expressions to select portions of theXML.

XMLBeans provides a relatively simple API for mapping XML instance data intoJava objects. If you need this capability, you should definitely look into usingXMLBeans in your application.

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 24

24

Cocoon

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 25

Copyright © Sauria Associates, LLC ApacheCon 2005 25

Cocoon What does it do?

Web publishing framework Based on XML Not an implementation of a standard Relies on a pipeline architecture

Cocoon is an XML based web publishing framework that was designed entirelywithin the ASF.

Unlike most of the other projects that I’ve been talking about, Cocoon is not animplementation of a standard defined by another organization.

It relies on a pipelined architecture to do its work.

It provides rich facilities including database access, input form handling,internationalization, browser detection, and more.

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 26

Copyright © Sauria Associates, LLC ApacheCon 2005 26

Sitemap

Pipeline

CocoonHTTP

Request

Matcher

Matcher

Matcher

Generator Transformer Serializer

Cocoon works by processing HTTP requests. Each request is routed to a sitemap, which is an XML document that describes aseries of pipelines.

The pipelines in a sitemap are protected by Matchers which are used to match against various attributes of the HTTP request,most commonly the URI but possibly the parameters and headers.

When a matcher matches the request, the associated pipeline is executed.

Conceptually, a pipeline is composed of a generator, one or more transformers and a serializer.

A generator is a Cocoon component that generates an XML document (as a stream of SAX events). This stream of events isthe input to a transformer.

A transformer is a Cocoon component that transforms a stream of SAX events into a different stream. An obvious examplewould be an XSLT processing engine.

A serializer is a Cocoon component that takes a stream of SAX events and converts it into a Java character or binary stream foroutput to the client.

Although conceptually simple, pipelines can actually be a bit more complicated than this diagram shows.

Cocoon provides eXtensible Server Pages (XSP) as a way of implementing generators in a style that will be familiar to usersof JSP. XSP’s are always XML documents, and Cocoon provides the equivalent of JSP taglibs via a clever use of XSLTcalled logicsheets.

A pipeline may also contain Actions, which are components that can just insert data into the sitemap for later use. Cocoonincludes actions that can be used for database access, sending email, or accessing session data.

Within a single pipeline, you can use Selectors to allow if/then/else style flow of control, causing subsections of a pipeline tobe executed depending on the data available to the sitemap.

If you are building an application that has complicated page flows, you should look into Cocoon’s continuation based flowcontrol layer. The flow layer provides you with a way to implement the controller portion of a Model-View-Controllerapplication in a simple and elegant manner.

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 27

Copyright © Sauria Associates, LLC ApacheCon 2005 27

Cocoon When would I use it? For More:

TU13 Cocoon - OneHour Portal Tues 15:00 TU17 Cocool Blocks Tues 15:30 TU21 Slicing and dicing REST with Apache

Cocoon Tues 17:30

Cocoon is suitable for general purpose web applications.

If you are building a large web application and you can benefit from using XML atall levels (say you need to provide multiple output flavors, or you need to provideXML data feeds as well), then you should really take a look at Cocoon

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 28

Copyright © Sauria Associates, LLC ApacheCon 2005 28

Forrest What does it do?

Documentation platform based on Cocoon

Content Templates FAQs, Changelogs, HOWTOs, etc.

Skins Forrestbot When would I use it?

Used in many xml.apache.org projects

Forrest is a documentation system based on Cocoon.

It provides a series of content templates where your place your content.Examples of templates are FAQs, ChangeLogs, HOWTOs, and todo lists. The plans are to supportDocbook and Wiki formats as well

Forrest then uses a skin to render your content into a project websiteIt can do this statically or dynamicallyNot only can you change the skin used to render, you can also choose whether to render to HTML orPDF

Forrest provides the forrestbot system for keeping a forrest based web site up to date.You run the forrestbot on machine A, get the content from machine B, and publish the formatted siteto machine C.Forrestbot has support for

local directoriesCVSFTPSCP

If you need a documentation system for a program you are developing, you should look at Forrest.

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 29

Copyright © Sauria Associates, LLC ApacheCon 2005 29

Lenya What does it do?

Content Management System for Cocoon Revision Control Scheduling Search Engine Staging areas Workflow Browser based WSIWYG Editors

When would I use it? When you are developing a large site in Cocoon

For More: TU05: Lenya and Jackrabbit make a fine couple

Tues 10:30

Lenya is a project under incubation. Its ultimate destination is cocoon.apache.org

Lenya provides the functions of a Content Management System for Cocoon.

This includesRevision ControlSchedulingSearch EngineStaging areasWorkflow managementBrowser-based WSIWYG Editors

If you are developing a large Cocoon site and coordinating lots of contentpublication, then you should look into Lenya.

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 30

30

Web Services

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 31

Copyright © Sauria Associates, LLC ApacheCon 2005 31

XML-RPC What does it do?

Use XML to markup RPC’s Deliver the XML via HTTP Supports a fixed set of datatypes

During the end of the 90’s, people were trying to use web technologies to integrate applications.

In 1998, a number of parties got together to create a specification that allowed applications to callprocedures in other applications.This specification relied on marshalling the procedure arguments into an XML document.The XML document was then delivered to the remote application via HTTP.The application performed its functionality and returned a result.The result was marshalled into an XML documentThe result document was placed in the HTTP response and returned.

This specification was called XML-RPC and the primary authors wereDave Winer – Userland SoftwareDon Box – DevelopmentorBob Atkinson and Mohsen Al-Ghosein – Microsoft

XML-RPC is very simple to implement, which makes it attractive.Part of the reason that it is simple is that it supports a small set of scalar datatypes

At Apache, the XML-RPC project is part of the webservices.apache.org project

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 32

Copyright © Sauria Associates, LLC ApacheCon 2005 32

XML-RPC<?xml version="1.0" encoding="UTF-8"?><methodCall> <methodName>createBook</methodName> <params> <param><value><string>Effective Java</string></value></param> <param><value><string>Joshua Bloch</string></value></param> <param><value><string>yyy-yyyyyyyyyy</string></value></param> <param><value><string>August</string></value></param> <param><value><i4>2001</i4></value></param> <param><value><string>Addison-Wesley</string></value></param> <param><value><string>New York, New York</string></value></param> </params></methodCall>

Here is a sample XML-RPC message.

This message is used to ask a remote application to call the createBook method andpass the attached list of parameters.

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 33

Copyright © Sauria Associates, LLC ApacheCon 2005 33

XML-RPC When would I use it?

You need to talk to another XML-RPCapplication

For More: http://www.xmlrpc.com

You should use the XML-RPC project if you need to talk to another XML-RPCenabled application.

There are XML-RPC implementations for many languages, partially because itseasy to implement.If you need to talk to code written in one of those languages, XML-RPC may be agood alternative.

If you like the idea of XML-RPC, then maybe what you should really be using isSOAP. Which brings us to our next project, Axis.

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 34

Copyright © Sauria Associates, LLC ApacheCon 2005 34

Axis What does it do?

SOAP The standardized extensible XML-RPC

WSDL A way to describe SOAP services

You’ve probably already heard about web services and SOAP.

Axis is the ASF’s second generation web services stack that implements the SOAPand WSDL specifications.

SOAP is designed to fulfill many of the same goals as XML-RPC, but it has theadvantage of being standardized through the W3C.

WSDL is an XML vocabulary for describing SOAP based (and other) web services.In fact, if you have a WSDL description of a web service,Your toolset can generate the code needed to implement both service providers andservice requestors.WSDL uses XML Schema to describe the data types that can be processed by a webservice.A WSDL document tells how to bind an abstract definition of a web service (calleda portType) to a particular protocol, such as SOAP over HTTP.

There is also a C version of Axis under development.

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 35

Copyright © Sauria Associates, LLC ApacheCon 2005 35

Axis<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <book xmlns="http://sauria.com/schemas/apache-xml-book/book"> <author>Joshua Bloch</author> <title>Effective Java</title> <isbn>yyy-yyyyyyyyyy</isbn> <month>August</month> <year>2001</year> <publisher>Addison-Wesley</publisher> <address>New York, New York</address> </book> </soapenv:Body></soapenv:Envelope>

Here’s a SOAP message:

The message consists of an Envelope element. Inside the Envelope are an optionalHeader element and a required Body element

The Envelope defines some frequently used namespaces.

The Body of this message is using what is called a document/literal style.The rpc/encoded style is more common – but common wisdom is that the futuredirection of web services is to use document/literal style.rpc/encoded style explicitly encodes the arguments of the RPC using an encodingscheme defined by the SOAP specification.document/literal style assumes that the body of the element is an XML documentdescribed by an XML schema. It’s the job of the service provider and servicerequestor to know how to interpret that schema.

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 36

Copyright © Sauria Associates, LLC ApacheCon 2005 36

Axis JAX-RPC programming model (JSR-101) WSDL tools

WSDL2Java Java2WSDL

TCPMon

The programming model that Axis presents to a Java developer is the JAX-RPC programming modeldescribed in JSR-101.This model attempts to make working with web services appear like working with RMI.

Axis includes a pair of tools for working with WSDL documents.WSDL2Java takes a WSDL description of a web service and generates skeleton code for a servicerequestor and/or service provider.The recommended way to do web service development is to start with a WSDL file and useWSDL2Java to generate the classes that you need. You can then modify the generated classes toinclude your application specific logic.

If you already have Java classes that you want to expose as web services, you have two choices:1) If you must work with a WSDL description, then use WSDL2Java to generate the classes and thenuse the adapter or façade patterns to interface with your code2) You can use Java2WSDL to generate a WSDL file from your Java classes. Then you have aWSDL file that you can give to people who want to use your service, and you can use WSDL2Java togenerate classes that can use adapter or façade to talk to your code.

Axis provides a cool tool called TCPMon that can help you when you are developing web services.

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 37

Copyright © Sauria Associates, LLC ApacheCon 2005 37

Axis

This is a screenshot of TCPMon, which acts a tunnel for the HTTP connections thatyour SOAP messages are using.

When you use TCPMon it displays the contents of HTTP requests and responses inthe panes.

This tool has uses beyond web services development as well.

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 38

Copyright © Sauria Associates, LLC ApacheCon 2005 38

Axis When would I use it?

You need a SOAP based web service You need to integrate systems

You need to do it over the Internet

You need to talk to .NET Java and C++

For More: TU20: Flashifying an Apache Axis

Application T16:00

Web Services are technology for integrating applications in a dynamic and looselycoupled fashion.

If you need to perform this kind of integration, you should be looking at WebServices and SOAP,Which means that you should be looking at Axis. SOAP based web services canleverage the infrastructure of the world-wide-web, allowing you to performapplicatoin integration tasks over the Internet, and using well understood Internettechnologies.

The Microsoft .Net platform has committed itself to SOAP based web services as akey part of the distributed computing model for the platform. If you need to accessservices provided by .NET then you will probably be able to do it using a SOAPbased web service implementation.

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 39

Copyright © Sauria Associates, LLC ApacheCon 2005 39

Axis2 Actually this is the third time New Features

XMLBeans based databinding support WS-Addressing support REST Web Service Support MTOM//SWA attachment support SAAJ

For More: WE11 Introducing Axis2 Wed 14:00

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 40

Copyright © Sauria Associates, LLC ApacheCon 2005 40

jUDDI What does it do?

UDDI implementation

When would I use it? To prototype an application that uses UDDI To run a local/private UDDI registry

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 41

Copyright © Sauria Associates, LLC ApacheCon 2005 41

WSIF What does it do?

Web Services Invocation Framework Allows you to invoke services via a WSDL

document Supports

Java classes EJB JMS JCA

When would I use it? If you need a uniform interface to services

implemented using different technologies You need isolation from the services API’s

WSIF is the Web Services Invocation Framework, which is part of ws.apache.org

WSIF provides an insulation layer for applications that call services. The idea is toprovide a single mechanism for callling services, regardless of how those servicesare implemented.

WSIF accomplishes this by using WSDL descriptions of services, and providing amechanism for invoking a service via a WSDL document.

Currently it provides support forLocal Java classesEJBJMSJCA

WSIF defines binding extension elements for each of these technologies.

If you are developing an application which uses one or more of these technologies,you may find it convenient to have a layer such as WSIF.

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 42

Copyright © Sauria Associates, LLC ApacheCon 2005 42

JaxMe What does it do?

JAXB implementation Convert XML instances <-> Java Bean

instances

Store JavaBeans into a database Query that database

When would I use it? You need to use JAXB

JaxMe is a project under incubation. Its ultimate destination is ws.apache.org

JaxMe is an implementation of the Java Architecture for XML Binding (JAXB) specified in JSR-031

JSR-031 specifies how to map XML instances and Java instances to each other.

JaxMe can store JavaBeans in a database – the focus is on XML databases like:TaminoXML:DB

JaxMe will have the capability to generate EJB’s (session or entity) that access the database

JaxMe / JAXB and XMLBeans overlap in functionality. The tradeoffs on when to use them are:JAXB is a JCP standard and XMLBeans is not.JAXB only supports a subset of XML Schema, while XMLBeans supports all of XML Schema.XMLBeans API is simpler.XMLBeans does not have database access functionality.

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 43

43

Now entering Spec Land…

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 44

Copyright © Sauria Associates, LLC ApacheCon 2005 44

Java/JSRSpecProject

WSDL 2.0(library)

Woden(incubation)

JSR-172WS on J2ME

Mirae

EWSEWS

JAXR (JSR-93)Scout

Scout uses jUDDI

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 45

Copyright © Sauria Associates, LLC ApacheCon 2005 45

OASIS

WS SecurityWSS4J

WS-Security +TSIK(incubation)

WSNPubscribe

WSRFWSRF

MUWSMuse

SpecProject

Muse uses WSRF

TSIK - For More: TU12 Pragmatic XML Security TU 14:00

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 46

Copyright © Sauria Associates, LLC ApacheCon 2005 46

WS-Consortium

WS-CoordinationWS-Atomic TransactionWS-Business Activity

Kandula

WS-AddressingAddressing

WS-Reliable MessagingSandesha

SpecProject

Kandula is mostly Atomic Transaction Coordination

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 47

47

Jakarta

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 48

Copyright © Sauria Associates, LLC ApacheCon 2005 48

jakarta.apache.org Betwixt

XML introspection mechanism for mappingbeans to XML

Digester Rule based approach to “digesting” XML

configuration files

JXPath Use XPath to traverse graphs of Java

objects

The Jakarta project also contains some projects that are related to XML.The projects that I’m going to talk about are part of the Jakarta-Commons project.

Betwixt is in the same niche as XMLBeans and JaxMe.The biggest difference is that Betwixt doesn’t need an XML Schema to do its job, it can just look atthe Java classes and generate the XMLThis is similar to the JDK 1.4 long term bean serialization mechanism, but Betwixt can generate nicerlooking XML.

Digester uses a rule-based approach for reading data out of XML configuration files.The digester rules look a little bit like XPath expressions but they are not, but they serve the samepurpose.They say, when you see an element, take the content and pass it to this method.

JXPath allows you to use the XPath syntax to traverse graphs of Java objects. These objects can beJavaBeansarrays and CollectionsMapsDOM and JDOM nodesServlet contexts

This allows you to use a single API for manipulation different kinds of objects. You can traverseobject graphs the contain different types of objects, say a Bean that contains a Map of DOM nodes.

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 49

Copyright © Sauria Associates, LLC ApacheCon 2005 49

Book Professional XML

Development withApache Tools Wrox December 2003

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 50

Copyright © Sauria Associates, LLC ApacheCon 2005 50

Thanks Open Source Applications Foundation

ApacheCon 2005 December 2005

Copyright © Sauria Associates, LLC 2005 51

Copyright © Sauria Associates, LLC ApacheCon 2005 51

Questions: http://xml.apache.org http://cocoon.apache.org http://ws.apache.org http://jakarta.apache.org

[email protected] http://www.sauria.com/blog