Java, XML, and a New World of

skatechildrenΛογισμικό & κατασκευή λογ/κού

3 Νοε 2013 (πριν από 4 χρόνια και 4 μέρες)

71 εμφανίσεις

Java, XML, and a New World of
Open Components

Simon St.Laurent


New York Object Developers Group


April 19, 1999



Copyright 1999 Simon St.Laurent



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


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.

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.

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

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.


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

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.

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.

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?

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.

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.

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.

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
.

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

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.

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.

Parsing XML
-

An Inside Look

Core Document Parser
<?xml?>
<!ELEMENT...
<!ATTLIST...
XML DTD
DTD declarations
Conf igurable Retrieval
of External
Resources
Attribute Def aulting
Structure Validation
Tree Builder
DTD Resolv er
Entity Resolution
Well-f ormedness Sy ntax Checker
XML Document

Application

Parsing XML
-

The View from
the Application

<?xml?>
Monolithic Parser
Loads document
Parses declarations
Builds DTD
Interprets document against DTD
May validate
May build DOM tree
May provide XSL or XLink Services
Application
XML Document
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.

Tools for XML

Software Development


Development environment issues


Platform issues


Network issues


Personal preference as the typically
overriding issue

Three Approaches to

Composing 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)

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

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>

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


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"/>


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.

Layered Filter Structures
-

Origin

<?xml?>
Document
Ev ent
Handler
DTD Event
Handler
Error Event
Handler
Entity Event
Handler
SAX
Parser
Application
Ev ents
XML Document
Copyright 1998 JXML, Inc.
Permission is granted for
redistribution and reuse
that includes this label.
Adding a Filter

<?xml?>
Document
Ev ent
Handler
DTD Event
Handler
Error Event
Handler
Entity Event
Handler
SAX
Parser
Application
Ev ents
XML Document
Document
Ev ent
Handler
List of Links
XLinkFilter
Copyright 1998 JXML, Inc.
Permission is granted for
redistribution and reuse
that includes this label.
Filters can be inserted in the

path between the parser and

the application, providing

generic functionality to many

applications.

Adding a Filter II

<?xml?>
Document
Ev ent
Handler
DTD Event
Handler
Error Event
Handler
Entity Event
Handler
SAX
Parser
Application
Ev ents
XML Document
Document
Ev ent
Handler
List of Links
XLinkFilter
Document
Ev ent
Handler
LocationFilter
Stack of
Elements
Copyright 1998 JXML, Inc.
Permission is granted for
redistribution and reuse
that includes this label.
Multiple filters may be layered and even

connected to provide additional generic

functionality.

Adding a Filter III

And so on....

<?xml?>
Document
Ev ent
Handler
DTD Event
Handler
Error Event
Handler
Entity Event
Handler
SAX
Parser
Application
Ev ents
XML Document
Document
Ev ent
Handler
List of Links
XLinkFilter
Document
Ev ent
Handler
LocationFilter
Stack of
Elements
Copyright 1998 JXML, Inc.
Permission is granted for
redistribution and reuse
that includes this label.
NamespaceFilter
Document
Ev ent
Handler
Stack of
Namespaces
Transf ormed Events
Encapsulating Filters

<?xml?>
Document
Ev ent
Handler
DTD Event
Handler
Error Event
Handler
Entity Event
Handler
SAX
Parser
Application
Ev ents
XML Document
Document
Ev ent
Handler
List of Links
XLinkFilter
Copyright 1999 JXML, Inc.
Permission is granted for
redistribution and reuse
that includes this label.
NamespaceFilter
Document
Ev ent
Handler
Transf ormed Events
Document
Ev ent
Handler
MDElementTy pe (required by MDSAX)
XPointer Context
Stack of
Elements
Stack of
Namespaces
MDAppHandler
Document
Ev ent
Handler
MDContext (Parsing Context)
Extended
Object
Ref erence
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

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.

From Processing to

Program Construction

The bootstrap process for MDSAX

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"/>


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>

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.WindowsLookAndF
eel">





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




<action eventDestination="frame1"/>



</radioButton>


</panel>

</sFrame>


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

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...

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

XML
-
RPC Samples

POST /rpchandler HTTP/1.0

User
-
Agent: MyClient/1.0 (WinNT)

Host: mycomputer.simonstl.com

Content
-
Type: text/xml

Content
-
length:169


<?xml version="1.0"?>

<methodCall>

<methodName>test.returnId</met
hodName>


<params>



<param>

<value><string>ASCII</string></v
alue>



</param>


<params>

</methodCall>


HTTP/1.1 200 OK

Server: JavaWebServer/1.1

Content
-
Length:

Content
-
Type: text/xml

Date: Fri, 12 Feb 1999
19:01:32 GMT

<?xml version="1.0?>

<methodResponse>


<params>



<param>




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



</param>


</params>

</methodResponse>


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.”

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...

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

Resources

simonstl.com
-

essays, XLinkFilter project, and more:


http://www.simonstl.com

XMLsoftware.com
-

a directory of software and components for
processing XML:


http://www.xmlsoftware.com

Robin Cover’s XML pages
-

a guide to everything XML:


http://www.oasis
-
open.org/cover/xml.html

Café Con Leche
-

An almost daily guide to XML:


http://metalab.unc.edu/xml/

General

Resources

IBM’s AlphaWorks: (All kinds of XML projects, mostly Java)


http://www.alphaworks.ibm.com

JXML: (MDSAX and Coins)


http://www.jxml.com

SAXON (a framework for processing SAX events)


http://home.iclweb.com/icl2/mhkay/saxon.html

Docuverse DOM (free DOM implementation)


http://www.docuverse.com/domsdk/index.html

Development Frameworks and Tools

Resources

John Cowan’s XML index (ParserFilter, NamespaceFilter, much more)


http://www.ccil.org/~cowan/XML/

Free XML Software (maintained by Lars Marius Garshol)


http://www.stud.ifi.uio.no/~larsga/linker/XMLtools.html

James Clark’s XML Resources (XML tools in Java, C, and C++)


http://www.jclark.com/xml/

More Components