java, xml, and a new world of open components. java/xml/components why xml? ‘xml applications’...

44
Java, XML, and a New World of Open Components

Upload: reynold-lang

Post on 30-Dec-2015

241 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

Java, XML, and a New World of Open Components

Page 2: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

Java/XML/Components• Why XML?

• ‘XML Applications’

• Data Analysis and Application Development

• Client-Server and Distributed Applications

• Transforming XML

• Linking XML

• XML and the Web

• Java and XML Development

• Core XML-centric Standards: SAX and the DOM

• Building toward Beans: IBM’s BeanML

• Single-purpose: XWingML

• Building on XML: JXML’s MDSAX & Coins

• XML-oriented protocols: XML-RPC and XP

• Futures

Page 3: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

Why XML?

• Meaningful markup

• Single approach can accommodate both document and data structures, and can integrate both within documents.

• Good fit for object-oriented development - strict hierarchies ensure clean structures

• Relatively easy integration with legacy environments for creation, transport, presentation.

Page 4: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

Reusable Components for XML

• Standard XML document structure allows separation of file handling from application architecture.

• Separation of file handling permits creation of generic components for information processing.

• Modular approach simplifies integration on many levels.

Page 5: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

Clean Integration with OOP

• Hierarchical structures of XML map well to objects and properties.

• Componentization made simpler by XML parsing works well with OOP development environments.

• Program Composition made possible by XML mapping to object structures and late binding.

• Needed: Data typing. Currently roll-your-own

Page 6: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

Why NOT XML?

• Real programmers write their own highly optimized input/output routines

• Can’t lock customers in to a proprietary and inscrutable file format. (Have to produce better programs!)

• XML is verbose, especially with all those wasteful end tags. Binary formats are more efficient.

Page 7: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

• Application as Data Structure

• Application as Network Architecture

• Application as Software Package

What Is An XML Application?

• ‘Traditional’ SGML usage - “HTML is an application of SGML”

• Data structures may define family of software applications

Different Concepts of ‘Application’

• Web application or client-server application framework

• Not necessarily programming - typically integration-focused

• ‘Traditional’ software development view of applications

• May involve program or component integration

Page 8: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

XML for Document Processing

• ‘Traditional’ document-centric approach focuses on using Java as tool for managing, presenting, transforming XML documents.

• XML documents the focus; application built to support documents, not application-specific documents.

• Can be used for both generic (non-vocabulary-specific) approaches and custom apps built for particular vocabularies, document types.

Page 9: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

XML for Program Construction

• Beyond Resource Files

• XML application structure and content mapped into document structure

• Smoothes compile cycles by permitting run-time program construction based on document content

• Simplifies repetitive programming chores like GUI construction.

Page 10: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

Data Analysis and Application Development

• Data modeling as the first step in building an XML-centric application

• Data modeling as task of SGML consultants - is that always needed anymore?

• Key question: Am I building an application to support documents, or documents to support an application?

Page 11: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

Data Modeling and Application Development

• Need to involve application developers in data modeling process at early stage

• Programmer’s perspective: develop XML first, or object first? Either approach is possible, though each more appropriate to particular situations.

• Additional consideration may be needed for application-data model integration.

Page 12: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

Transforming XML• Extensible Style Language (XSL) provides

template-based transformation language• Architectural Forms (from SGML’s HyTime)

provides attribute-based transformations. David Megginson’s XAF implementation applies this to XML.

• SAXON and MDSAX provide filters for programmatically transforming XML.

• Transformations may be document to document, DOM tree to DOM tree, or events to events.

Page 13: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

Linking XML

• A critical piece of Web functionality that is seriously missing-in-action.

• Previous Working Draft: 3/3/98. Requirements Documents just issued.

• XLink’s approach is document-centric, but may be a good tool for modeling relations among objects as well as documents.

Page 14: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

XML and the Web:Integrating XML and Legacy Transport

• XML was designed for the Web, with HTTP transport in mind, though any file-oriented approach is acceptable.

• XML’s ‘natural fit’ with structures used for HTML simplifies implementation using traditional Web server/browser applications as well as CGI and, of course, Java.

Page 15: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

Java and XML Development

• Jon Bosak: ‘XML gives Java something to do.’

• Java provides among the best Unicode support (and useful tools for encoding conversions)

• Java is extremely network-friendly

• XML structures map easily to Java object structures.

• Extremely portable across platforms

Page 16: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

Java and XML, continued

• Many XML components are already available for Java, from parsers to XSL and XLink engines.

• Many of the core standards for processing XML are developed with Java in mind - SAX, DOM, etc.

• Frameworks for Java XML development, like MDSAX and SAXON, are readily available.

Page 17: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

Parsing XML

• The big leap from serialized documents to program structures, long the realm of experienced pros.

• XML was designed to avoid the many nightmares involved in parsing SGML.

• Parsing involves multiple stages of processing to return a complete picture of an XML document to an application.

• XML parsing tends to be assigned to a pre-built component, leaving the application to process data rather than parse text files.

Page 18: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

Parsing XML - An Inside Look

Core Document Parser

<?xml?><!ELEMENT...<!ATTLIST...

XML DTD

DTD declarations

Configurable Retrievalof ExternalResources

Attribute Defaulting

Structure Validation

Tree Builder

DTD ResolverEntity Resolution

Well-formedness Syntax Checker

XML Document

Application

Page 19: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

Parsing XML - The View from the Application

<?xml?>

Monolithic ParserLoads document

Parses declarationsBuilds DTD

Interprets document against DTDMay validate

May build DOM treeMay provide XSL or XLink Services

Application

XML Document

Page 20: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

Core XML Processing - Parser to Application Communication

• Two dominant standards:– Simple API for XML (SAX)

• Event-based model ‘reads’ document to application handlers.

• Supported by nearly all Java XML parsers.

• developed by XML-Dev mailing list (SAX2 in dev.)

– Document Object Model (DOM)• Tree-based model passes complete picture of document to

application at processing conclusion

• Java, JavaScript, IDL descriptions; Perl implementation in independent development.

• developed by W3C. Level 1 complete, Level 2 in progress.

Page 21: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

Tools for XML Software Development

• Development environment issues

• Platform issues

• Network issues

• Personal preference as the typically overriding issue

Page 22: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

Three Approaches toComposing Applications with XML

• Generic framework for use with any Bean-oriented Development (BeanML)

• Specific vocabulary aimed at particular area of Java development, with tools specific to that area (XWingML for Swing)

• Generic framework that can support multiple specific vocabularies (MDSAX and Coins)

Page 23: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

Bean-Centered XML: BeanML

• IBM’s AlphaWorks site offers Bean Markup Language tools, including a BeanML compiler and documentation.

• BeanML uses very Bean-specific vocabulary to configure JavaBeans.

• Small footprint (35K)

• Free download from IBM:

• http://www.alphaworks.ibm.com

Page 24: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

BeanML Code (Extract)

<?xml version="1.0"?>

<bean class="java.awt.Panel">

<property name="background" value="0xeeeeee"/>

<property name="layout">

<bean class="java.awt.BorderLayout"/>

</property>

<add>

<bean class="demos.juggler.Juggler" id="Juggler">

<property name="animationRate" value="50"/>

<call-method name="start"/>

</bean>

<string>Center</string>

</add>

…</bean>

Page 25: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

XWingML

• Similar to BeanML, but focused much more tightly on Swing GUI interfaces

• Currently available as toolkit; GUI editor supposed to available soon.

• Free download from Bluestone Software:http://www.bluestone.com

Page 26: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

Sample XWingML code<?xml version="1.0"?>

<!DOCTYPE XwingML SYSTEM "file:///c:/XwingML/xml/xwingml.dtd">

<XwingML>

<Classes>

<Instance name="OpenFile" className="XMLOpenFile"/>

<Instance name="SaveFile" className="XMLSaveFile"/>

<Instance name="ParseFile" className="XMLParseFile"/>

<Instance name="About" className="XMLAbout"/>

</Classes>

<JFrame name="MainFrame" title="Bluestone XMLEdit" image="icon.gif" x="10%" y="10%" width="80%" height="80%">

<JMenuBar>

<JMenu text="File" mnemonic="F">

<JMenuItem icon="open.gif" text="Open..." mnemonic="O" accelerator="VK_O,CTRL_MASK" actionListener="OpenFile"/>

<JMenuItem icon="save.gif" text="Save" mnemonic="S" accelerator="VK_S,CTRL_MASK" actionCommand="save" actionListener="SaveFile"/>

<JMenuItem icon="save.gif" text="Save As..." mnemonic="a" actionCommand="saveas" actionListener="SaveFile"/>

<Separator/>

<JMenuItem text="Exit" mnemonic="x" accelerator="VK_X,CTRL_MASK" actionListener="com.bluestone.xml.swing.XwingMLExit"/>

Page 27: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

Building on Document-Oriented Components

• The existence of standard interfaces to XML documents - SAX and the DOM - has given rise to a number of component possibilities.

• SAX Filters, which accept SAX events as input and generate SAX events as output, are one key component architecture for Java-based XML development.

Page 28: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

Layered Filter Structures - Origin

<?xml?>

DocumentEvent

Handler

DTD EventHandler

Error EventHandler

Entity EventHandler

SAXParser

Application

Events

XML Document

Copyright 1998 JXML, Inc.Permission is granted forredistribution and reusethat includes this label.

Page 29: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

Adding a Filter

<?xml?>

DocumentEvent

Handler

DTD EventHandler

Error EventHandler

Entity EventHandler

SAXParser

Application

Events

XML Document

DocumentEvent

Handler

List of Links

XLinkFilter

Copyright 1998 JXML, Inc.Permission is granted forredistribution and reusethat includes this label.

Filters can be inserted in thepath between the parser andthe application, providinggeneric functionality to manyapplications.

Page 30: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

Adding a Filter II

<?xml?>

DocumentEvent

Handler

DTD EventHandler

Error EventHandler

Entity EventHandler

SAXParser

Application

Events

XML Document

DocumentEvent

Handler

List of Links

XLinkFilter

DocumentEvent

Handler

LocationFilter

Stack of

Elements

Copyright 1998 JXML, Inc.Permission is granted forredistribution and reusethat includes this label.

Multiple filters may be layered and evenconnected to provide additional generic functionality.

Page 31: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

Adding a Filter III

And so on....

<?xml?>

DocumentEvent

Handler

DTD EventHandler

Error EventHandler

Entity EventHandler

SAXParser

Application

Events

XML Document

DocumentEvent

Handler

List of Links

XLinkFilter

DocumentEvent

Handler

LocationFilter

Stack of

Elements

Copyright 1998 JXML, Inc.Permission is granted forredistribution and reusethat includes this label.

NamespaceFilter

DocumentEvent

Handler

Stack of

Namespaces

Transformed Events

Page 32: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

Encapsulating Filters

<?xml?>

DocumentEvent

Handler

DTD EventHandler

Error EventHandler

Entity EventHandler

SAXParser

Application

Events

XML Document

DocumentEvent

Handler

List of Links

XLinkFilter

Copyright 1999 JXML, Inc.Permission is granted forredistribution and reusethat includes this label.

NamespaceFilter

DocumentEvent

Handler

Transformed Events

DocumentEvent

Handler

MDElementType (required by MDSAX)

XPointer Context

Stack of

Elements

Stack of

Namespaces

MDAppHandler

DocumentEvent

Handler

MDContext (Parsing Context)

ExtendedObject

Reference

JXML’s MDSAX provides an overall architecture for encapsulating SAX processors as well as a set of prebuilt filters that can be applied to particular situations.

(MDServlet provides support for using this in server-side document processing.)

Available for free download from http:/www.jxml.com

Page 33: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

From Context to Construction

• MDSAX goes beyond layered filter processing, using its own set of XML tools to build the pathways that events will follow.

• ContextML is an extensible markup language that developers can use to specify the paths events will follow. Effectively, MDSAX builds itself based on a set of XML documents.

• Coins lets you re-serialize your objects.

Page 34: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

From Processing to Program Construction

The bootstrap process for MDSAX

Page 35: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

Bootstrap Document for MDSAX<context>

<element/>

<documentRouter>

<elementRouter key="context">

<x key="displayOutput"

resultClass="com.jxml.mdsax.examples.output.DisplayOutput"/>

<x key="context"

resultClass="com.jxml.mdsax.MDContextFactoryImpl"/>

<x key="documentRouter"

resultClass="com.jxml.mdsax.MDDocumentRouterFactory"/>

<x key="stack"

resultClass="com.jxml.mdsax.MDFilterStackFactoryImpl"/>

<x key="element" resultClass="com.jxml.mdsax.MDElementFactoryImpl"/>

<x key="elementRouter" resultClass="com.jxml.mdsax.MDElementRouterFactory"/>

<x key="passAll"resultClass="com.jxml.mdsax.MDPassAllFactory"/>

<x key="trace" resultClass="com.jxml.mdsax.MDTraceFilterFactory"/>

<x key="display" resultClass="com.jxml.mdsax.MDDisplayFilterFactory"/>

Page 36: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

ContextML document for App<context>

<attList>

<att name="ID" type="id" status="#IMPLIED"/>

</attList>

<elementRouter>

<stack key="buttonGroup">

<element/>

<xs resultClass="javax.swing.ButtonGroup"/>

</stack>

<stack key="button">

<element/>

<xs resultClass="javax.swing.JButton"/>

</stack>

<stack key="radioButton">

<element/>

<xs resultClass="javax.swing.JRadioButton"/>

</stack>

<stack key="panel">

<element/>

<xs resultClass="javax.swing.JPanel"/>

</stack>

<stack key="sFrame">

<attList>

Page 37: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

Document describing GUI<sFrame

title="Simple"

ID="frame1"

metalButton="MetalButton"

motifButton="MotifButton"

windowsButton="WindowsButton">

<panel constraints="Center">

<button text="Hello, world">

<buttonProperties mnemonic="h"/>

</button>

<buttonGroup ID="bg1"/>

<radioButton

text="Metal"

ID="MetalButton"

actionCommand="javax.swing.plaf.metal.MetalLookAndFeel">

<buttonProperties buttonGroup="bg1" mnemonic="m"/>

<action eventDestination="frame1"/>

</radioButton>

<radioButton

text="Motif"

ID="MotifButton"

actionCommand="com.sun.java.swing.plaf.motif.MotifLookAndFeel">

<buttonProperties buttonGroup="bg1" mnemonic="o"/>

<action eventDestination="frame1"/>

</radioButton>

<radioButton

text="Windows"

ID="WindowsButton"

actionCommand="com.sun.java.swing.plaf.windows.WindowsLookAndFeel">

<buttonProperties buttonGroup="bg1" mnemonic="w"/>

<action eventDestination="frame1"/>

</radioButton>

</panel>

</sFrame>

Page 38: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

Program Construction in Use - Astronomical Instrument Markup

Language (AIML)• NASA and Century Computing are building

a markup language/Java combination supporting remote control of instruments in hostile environments.

• XML provides foundation for descriptions of instruments, input/output

• AIML is a subset of more general IML - could be used with any instruments

Page 39: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

Connecting Processes over Networks: XML-RPC and XP

• Combining the easy exchange and creation of XML documents with program composition and similar method-oriented strategies

• Using XML to relay data and command information among dissimilar systems

• Prospect of using COBOL output to build Java programs...

Page 40: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

XML-RPC• Remote Procedure Call Origins

• Uses HTTP as carrier– allows routing through firewalls without special

configuration– can rely on HTTP security, authentication,

session management

• Developed by Frontier, Microsoft

• Implementations in Java, Perl, Python, etc.

• www.xml-rpc.com

Page 41: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

XML-RPC SamplesPOST /rpchandler HTTP/1.0User-Agent: MyClient/1.0 (WinNT)Host: mycomputer.simonstl.comContent-Type: text/xmlContent-length:169

<?xml version="1.0"?><methodCall><methodName>test.returnId</

methodName><params>

<param><value><string>ASCII</

string></value></param>

<params></methodCall>

HTTP/1.1 200 OKServer: JavaWebServer/1.1Content-Length: Content-Type: text/xmlDate: Fri, 12 Feb 1999

19:01:32 GMT<?xml version="1.0?><methodResponse>

<params><param>

<value><string>Server 12345</string></value>

</param></params>

</methodResponse>

Page 42: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

XP - Extensible Protocol• IETF - http//www.ietf.org/internet-drafts/draft-

harding-extensible-protocol-00.txt

• Sets up two streams passing information as request/response

• Java implementation available

• “To extend XML from a class of data objects into a protocol is to extend the rules for constructing a single document into rules for constructing two interrelated streams of documents. Accordingly, we introduce mechanisms for handling both the sequential and interrelated aspects of the document streams.”

Page 43: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

XML Component Futures

• Shift from code-oriented development to document-oriented integration

• Small components can make a difference - moving from large projects to large collections of smaller projects

• Open source, open process, and the ability to compete in this market

• The end of CORBA and COM? Probably no, but...

Page 44: Java, XML, and a New World of Open Components. Java/XML/Components Why XML? ‘XML Applications’ Data Analysis and Application Development Client-Server

XML Architecture Futures

• Distributed processing on heterogeneous systems

• Debugging simplified!

• Client and server architectures can use identical components (and middleware too!)

• Less dependence on proprietary approaches