-
Front cover The XML Files: Development of XML/XSL Applications Using WebSphere Studio Version 5 Introduces WebSphere Studio Application Developer Version 5 XML tooling A comprehensive guide to XML support of WebSphere Family Start-to-finish application case studies Osamu Takagiwa Deena Hassan Oliver Quixchan Jagjit Singh ibm.
-
-
International Technical Support Organization The XML Files: Development of XML/XSL Applications Using WebSphere Studio Version 5 December 2002 SG24-6586-00
-
Note: Before using this information and the product it supports, read the information in “Notices” on page ix. First Edition (December 2002) This edition applies to Version 5 of IBM WebSphere Studio Application Developer. © Copyright International Business Machines Corporation 2002. All rights reserved. Note to U.S. Government Users Restricted Rights -- Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
-
Contents Notices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix Trademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . x Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi The team that wrote this redbook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi Become a published author . . . . .
-
Chapter 3. Processing XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 3.1 XML applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 3.2 Xalan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 3.3 SAX2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 3.4 DOM level2 . . . . . . . . . . . . . . . . . . . . . . .
-
.2.1 Create an XML file from a DTD file . . . . . . . . . . . . . . . . . . . . . . . . . 147 7.2.2 Create an XML file from an XSD file . . . . . . . . . . . . . . . . . . . . . . . . 148 7.2.3 Create DTD/XSD files from XML. . . . . . . . . . . . . . . . . . . . . . . . . . . 149 7.3 Generate a HTML from an XSD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 7.4 JavaBeans from DTD/XSD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 7.
-
Chapter 10. Development of XML-based Enterprise applications . . . . . 215 10.1 XML based Enterprise application architecture . . . . . . . . . . . . . . . . . . . 216 10.2 Solution outline for customer registration sample . . . . . . . . . . . . . . . . . 217 10.3 Developing the customer registration sample . . . . . . . . . . . . . . . . . . . . 219 10.3.1 Creating the Web tier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 10.3.2 Building the entity EJB and the database schema .
-
Appendix B. Installing IBM WebSphere Application Server 4.0 AEs . . . 305 Things to do before installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306 Hardware and software prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306 Create groups and users. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306 Check that IP ports are unused. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307 Stop the Web server processes .
-
viii The XML Files: Development of XML/XSL Applications Using WebSphere Studio
-
Notices This information was developed for products and services offered in the U.S.A. IBM may not offer the products, services, or features discussed in this document in other countries. Consult your local IBM representative for information on the products and services currently available in your area. Any reference to an IBM product, program, or service is not intended to state or imply that only that IBM product, program, or service may be used.
-
Trademarks The following terms are trademarks of the International Business Machines Corporation in the United States, other countries, or both: Redbooks(logo)™ AIX® alphaWorks® CICS® DB2® IBM® IMS™ Informix® MQSeries® Perform™ SAA® SOM® SP™ VisualAge® WebSphere® The following terms are trademarks of International Business Machines Corporation and Lotus Development Corporation in the United States, other countries, or both: Lotus® The following terms are trademarks of other companies: ActionMedia, LANDes
-
Preface In today’s technology, XML is becoming a key piece of software infrastructure. The main idea is extremely simple. It is a language like HTML and is text based, but is rigidly enforced, and therefore, can be built upon easily. XML documents may use a Document Type Definition (DTD) or an XML Schema. XML was designed to describe data and to focus on the data, unlike HTML, which was designed to display data. It was created to structure and store data.
-
Oliver Quixchan is an e-business consultant from Guatemala. He holds a BS in Computer Science from Universidad Francisco Marroquin, Guatemala. He has experiece in application development, Web-oriented solutions using J2EE and WebSphere software platform, banking software development, and middleware design. His areas of expertise include WebSphere Application Server, WebSphere Host Pblisher, XML, J2EE. Jagjit Singh is an IT architect with IBM Global Services, Australia.
-
Become a published author Join us for a two- to six-week residency program! Help write an IBM Redbook dealing with specific products or solutions, while getting hands-on experience with leading-edge technologies. You'll team with IBM technical professionals, Business Partners and/or customers. Your efforts will help increase product acceptance and customer satisfaction. As a bonus, you'll develop a network of contacts in IBM development labs, and increase your productivity and marketability.
-
xiv The XML Files: Development of XML/XSL Applications Using WebSphere Studio
-
Part 1 Part 1 Introduction to XML technology Part one introduces the eXtensible Markup Language (XML) and how it can be used in today’s technology. This highlights the XML Processor and parser shipped with Websphere Application Developer. © Copyright IBM Corp. 2002. All rights reserved.
-
2 The XML Files: Development of XML/XSL Applications Using WebSphere Studio
-
1 Chapter 1. XML overview “I think we should shoot for a goal within the developed countries of having Internet access as complete as telephone access within a fixed number of years. It will do as much as anything else to reduce income inequality.” Bill Clinton, President of the United States of America, November 21, 1999 This chapter introduces the eXtensible Markup Language (XML) and how it can be used in today’s technology.
-
1.1 XML concepts In today’s technology, XML is starting to becoming a key piece of software infrastructure. The main idea is extremely simple. It is a language like HTML and is text based, but is rigidly enforced, and therefore, can be built upon easily. XML documents may use a Document Type Definition (DTD) or an XML Schema. XML was designed to describe data and to focus on the data, unlike HTML which was designed to display data. It was created to structure and store data. 1.
-
1.3 XML business benefits The benefits of a common base upon which the technical world can build layers upon layers of technical innovation are enormous. This will only be possible if this standard has been agreed to by all. XML has three main applications: Sharing of information: The main problem integrating data between any two business organizations is the interface between them.
-
XML formats and standardization. Examples of these are inter-bank payment between banks, insurance companies and trading agencies, supply-chains between manufacturers, distributors and retailers, battlefield information between soldiers, satellites and defence analysts.
-
1.3.3 XML in new innovations There have such a large number of innovations based on XML, they are too numerous to list. New ideas are now based in XML. Entrepreneurial companies now cannot avoid XML and its standards. Voice XML In October, 2001, the World Wide Consortium (w3C) announced the first release of a working draft for the Voice Extensible Markup Language (VoiceXML). VoiceXML has these purposes among others: It will hide designers and developers from low-level platform specific details.
-
Acceptability of use for data transfer XML is not a programming language. It is a standard way of putting information in a format that can be processed and exchanged across hardware devices, operating systems, software applications, and the Web. It has become such a common medium of data that it enables the transmission and retrieval, and storage of information over the Internet across company boundaries, making it a natural choice for data management for e-business transactions.
-
required, the development cost would rise. However, if the data could be re-used or built upon, there would be a re-development savings. Imagine a navigation system used by consumers to move from one place to another. This system would have street maps, yellow pages information, local attractions and other information.
-
GML also drew on work by William Tunnicliffe and Stanley Rice on building a generic coding system, which was done under the auspices of the Graphic Communication Association. GML formed the basis of many IBM documentation systems including Script and Bookmaster. Later developments led to SGML, which became an ISO standard in 1986. SGML has had a great deal of success, but unfortunately, it has mainly been limited to large corporations and government departments.
-
relied on the standard for character specifications. Characters that are not present in Version 2.0 would probably have be used in XML documents and character data. Developers would have developed workarounds for characters that were not supported in Unicode Version 2.0. These characters are not allowed in XML names such as element type, names, and attribute names, just to name a few. Also, some characters that should have been permitted in XML 1.
-
Presently, Web services theoretically need to support a multitude a browsers. The data sent to the browsers would be common to all, but the presentation of the data could be dependent on the browser. In effect, the presentation of the data could be PDA or even a mobile phone. An XSLT stylesheet is a XML document. A XSLT processor transforms one or more XSLT stylesheets. Typically, in a Java and XSLT based Web application, Java is used to access the data from the database.
-
XSLT has become a critical part of Web applications, because it allows versatility in the presentation logic. W3C has published a working draft for XSLT Version 2.0 and XML Path Language (XPath) Version 2.0 in April 2002. The later had a major IBM involvement. 1.8 Web services and XML Web services have gained prominence in the last three years. They are the new middleware that will glue all kinds of disparate applications from different vendors.
-
format to define an endpoint. Related concrete endpoints are combined into abstract endpoints (services). WSDL is extensible to allow description of endpoints and their messages regardless of what message formats or network protocols are used to communicate, however, the only bindings described in this document describe how to use WSDL in conjunction with SOAP 1.1, HTTP GET/POST, and MIME.
-
The W3C regularly publishes technical reports and publications. IBM has made major contributions to the W3C. A list of publications where IBM researchers have been involved in follows. The list is not exhaustive. Recommendations “A recommendation is work that represents consensus within W3C and has the director's stamp of approval. W3C considers that the ideas or technology specified by a recommendation are appropriate for widespread deployment and promotes W3C's mission.
-
16 The XML Files: Development of XML/XSL Applications Using WebSphere Studio
-
2 Chapter 2. Technologies in XML This chapter discusses some of the latest technologies being introduced in the XML arena. Some of these have been around for the last three years or so, and are undergoing enhancements and the others are fairly new. The material is intended for introduction only, where detailed investigation of each of these technologies is a subject by itself.
-
2.1 XML Processor (parser) An XML Processor can either be a validating or non-validating parser. Both kinds of parsers report violations on an XML document. According to the XML 1.0 specification: http://www.w3.org/ TR/REC-xml#proc-types “Validating processors must, at user option, report violations of the constraints expressed by the declarations in the DTD, and failures to fulfill the validity constraints given in this specification.
-
only after it has parsed the whole document. However, once the document has been created in memory, it can be navigated and changed. A DOM parser would be a tree-based parser. Event-based parsing These parsers process the document as it encounters the tags of the document. It is a data-centric view of the XML. Whenever an element or tag is encountered, it (or its contents) can be processed. However, it cannot backtrack once the tag has been passed.
-
XML Schema Part 0: This is a primer, it is intended to provide an easily readable description of the XML Schema facilities, and is oriented towards quickly understanding how to create schemas using the XML Schema language. XML Schema Part 1: Structures specify the XML Schema definition language, which offers facilities for describing the structure and constraining the contents of XML 1.0 documents, including those which exploit the XML Namespace facility.
-
2.3 Schema and style using CSS, XSLT, and XSL The eXtensible Style Language (XSL) is a language defined by the W3C for expressing stylesheets. It has three parts: XSL Transformations (XSLT), which is used for transforming XML documents. the XML Path Language (XPath), which is a language used to access or refer to parts of an XML document. XSL-FO, which is a vocabulary for specifying formatting semantics.
-
To make the XML data available to all kinds of browsers, we could transform the XML document on the server and send it as a more generic form of HTML to the browser. XSL transformations on the server will experience major growth as the specialized browser market expands. The would include browsers for Braille, aural browsers, Web printers, handheld devices and other kinds. The W3C has published a working draft for a new set of requirements for XPath on February 2001. It has set of number of goals.
-
used with XML if the display engine supports it. So far, the only shipping browser that supports this feature is Microsoft Internet Explorer 5.0. CSS can be used within a document, or referenced in a separate stylesheet, which is the more common approach. For more information on CSS, see: http://www.w3.org/TR/CSS1 The Cascading Style Sheet, Level 1 (CSS1) was made a full recommendation in 1996, while Cascading Style Sheet, Level 2 (CSS2) was made a full recommendatory in 1998.
-
XML Sample 210 1-868640-34-2 John Smith Mr In the example above, the
tag is used twice, but in a different context, once within the element and once within the element. Note the use of the xmlns keyword in the namespace declaration.
-
XML namespaces are used extensively in the XML arena, but, during the last two years, there has not been much technological advancement in this area. 2.5 Link and jump using XLink, XPointer, and XML Base Anyone surfing the Internet knows the joys of moving from one document to another seemlessly. Links are easily embedded within one document to a pre-defined location another. As demands for linking functionality, more demands are required on the technology for more capabilities.
-
Locator: Pointer to a external source. A locator can have a title as its child element type. Arc: A rule between resources. An arc element can have a title as its child element type. The simple and extended attributes are considered as linking elements. The other attributes describe the link. A resource is any available information or service that can be located by one means or another. The links, therefore, can link any two resources: files, documents, images, query results, and programs.
-
example shown) on the simple link will open the resource pointed to in an existing window. An example of an XML document showing extended links is in Example 2-4. Example 2-4 An extended link PAGE 44
For more details, visit W3C XML Linking language (XLink) V1.0 at: http://www.w3.org/TR/xlink/#N854. XML Base XML Base allows developers to specify a document’s base URI. Other links within the same document can then specify links relative to this base. These links could then point to applets, style sheets, images and other files. The syntax for XML Base consists of a single XML attribute named xml:base. A simple example follows for xml:base in a document with Xlink follows.
-
“Choice 1: Beef Vindalooo" resolves to the URI "http://airlines.org/mealchoices/choice1.xml" “Choice 2: Chicken Laksa" resolves to the URI "http://airlines.org/mealchoices/choice2.xml" "Choice 3: United Airlines Burger" resolves to the URI "http://airlines.org/mealchoices/choice2.xml" As in XML, only Unicode characters are allowed in xml:base. But for the URI, non-ASCII characters, except for the hash, percentage and square brackets, are disallowed.
-
The XML Pointer Language (XPointer), the language defined to express fragment identifiers for any URI reference that locates a resource whose Internet media type is one of text/xml, application/xml, text/xml-external-parsed-entity, or application/xml-external-parsed-entity. Some examples of Xpointers follow. Each of these selects a particular element in a document. The example finds the element with the ID United: http://www.airlines.com/airline.
-
The node test is ROW The predicate is [position()=34] This example located the 34th ROW element along from the content node. The user can also specify the absolute location steps that do not depend on the context node. The location path of the XPointer is: /child::BOEING747/child::ROW[position()=3]. This path is built from two location steps: /child::BOEING747 and child::ROW[position()>34] The first step is an absolute step that selects all child elements of the root node whose name is BOEING747.
-
end-point(location-set) - acts the same as start-point() but returns the points just after each location in its input. XPointer string functions There are some basic string matching capabilities through this function: string-range() - It takes a location set to search and a substring to search for. The result is a location set having a single range. The index and length arguments specify the number of characters where the match should start from and the number of characters it should search for.
-
The optional fourth argument specifies the number of characters to select. The example below, selects the ‘737’ from the first occurrence of the entire string Boeing737: xpointer(string-range(/,"Boeing737",7,3)[position()=1]) If the first string argument in the node test is empty, then relevant positions in the context node's text contents are selected. In the example below, the first six characters are picked up: xpointer(string-range(/,""1,6)[position()=1]) See Related Publications. 2.
-
great novel 10 good story 10 The path /child::book/child::copies selects all copies element children of book, which are defined under the document’s root. The above path can also be written as /book/copies. The XPath location step makes the selection of document part based on the basis and the predicate. The basis performs a selection based on axis name and node test.
-
document of the same document. Also, we would like only different classes of users to have access to different parts of the document. A airline agent may need to know a passenger’s customer name and address, but does not need to know the details of their credit card. A passenger boarding officer does not need to have access to the passenger’s personal details, while the airline would want to know more information about the passenger for marketing purposes.
-
Examples of XML encryption The main elements in the XML encryption syntax are the EncryptedData element and the EncryptedKey element, which derive from the EncryptedType abstract type. The data to be encrypted can be of an type, being an XML document, element or element content. The result of encrypting data is an XML encryption element that contains or references the cipher data.
-
In other cases, other information might be encrypted. Here are some of the credit card details that have been left un-encrypted. This could happen if the credit limit and the currency of the user’s details must be left visible to other parties. Example 2-9 Encrypting only the credit card number John Smith
-
$j Generate an element with a computed name, containing nested elements named and : <$tagname> $d , $p $tagname> In this example, the tagname, with its end-tag itself is a variable. FLWR(“FOR, LET, WHERE and RETURN clauses”) expression A FLWR expression binds values to and more variables, and then uses these variables to construct a result.
-
other holdings, include the author: FOR $h IN //holding RETURN $h/title, IF $h/@type = "Journal" THEN $h/editor ELSE $h/author SORTBY (title) Quantifiers Sometimes we have to test if elements exist that must satisfy a condition. Find titles of books in which both sailing and windsurfing are mentioned in the same paragraph: FOR $b IN //book WHERE SOME $p IN $b//para SATISFIES contains($p, "sailing") AND contains($p, "windsurfing") RETURN $b/title Eg 12.
-
Prepare a table of contents for the document "cookbook.xml", containing nested sections and their titles: LET $b := document("cookbook.xml") RETURN filter($b, $b//section | $b//section/title | $b//section/title/text() ) Querying relational data The best way to demonstrate XQuery is showing how it can be used to query a relational database. In Table 2-1 we have a very simple database.
-
RETURN $p/pno SORTBY(.) Grouping in XQuery Find the part number and average price for parts that have at least three suppliers. SQL version: SELECT pno, avg(price) AS avgprice FROM sp GROUP BY pno HAVING count(*) >= 3 ORDER BY pno; XQuery version: FOR $pn IN distinct(document("sp.xml")//pno) LET $sp := document("sp.
-
For more detail, visit XQuery 1.0: An XML Query Language ( April 2002 ) at: http://www.w3.org/TR/xquery/ XQuery: A Query Language for XML (Feb 2002) at: http://www.w3.org/TR/2001/WD-xquery-20010215/#section-Introduction 2.9 XSLT compilers (XSLTC) As the use of XML documents climbs, so will the use of XSL transformations increase. For any project, this increase will not only be in terms of the number of transformations required, but also in the size of each transformation.
-
< xs l:te m pla te m a tch = "C u s to m e r"> < h 1> In pu t X M L Fo rm < fo rm a c tio n = "/Tra ve l/C u sto m e rX S L S e rvle t" m e th o d= "po s t"> < ta b le b ord e r= "0 " c e llp a d d in g ="2 " c ells p a cin g = "0 "> < xs l:a p p ly-te m p late s s e lec t="firs tn am e "/> < /ta b le> < /form > < /xsl:te m p la te > X S LT s ty le s h e e t C o m p ile r JV M b yteco d e tra n s A .
-
2.10 Java Architecture for XML Binding (JAXB) The Java Architecture for XML Binding provides an API and tools that automate the mapping between XML documents and Java objects. These are available as an early access release. The public version of the JAXB specifications and a pre-release version of the reference implementation will be available by the third quarter 2002. The final draft is scheduled to be published in the forth quarter of the same year. The JAXB API compiles an XML Schema into Java classes.
-
The latest version is Cocoon 2 and is available for download from: http://www. xml.apache.org/cocoon/ It is a Web based application and must be run upon a Java Servlet 2.2 compliant engine, and also Jakarta Tomcat 4.0.1 In Cocoon, everything can be perceived as part of a pipeline. A pipeline consists of an input, some processing steps and then an output. Cocoon 2 makes use of the SAX events between each processing step. Parts of the pipeline include a generator and a serializer.
-
Matchers and selectors: conditional processing Conditional statements are part of any programming language. Output can be dependent on many factors, such as the users’ browser, request parameters, or operating system. Matchers are the equivalent of If statements. If a condition is true, then a section of a pipeline is processed, or otherwise is passed by. A selector is used when there are few options available, and it is similar to an If-then-else statement.
-
The sitemap is a XML file and is responsible for declaring individual components. It is used to define how those components are used to construct pipelines. Declaring components within the sitemap provides Cocoon with a great deal of extensibility, allowing the plug-and-play addition of new implementations. The sitemap XML file has the structure shown below: Example 2-15 Components of a sitemap XML file PAGE 69
Part 2 Part 2 XML technology in IBM WebSphere This part introduces IBM WebSphere Studio family and introduces the XML development capabilities of Websphere Studio Application Developer using XML perspective and wizards. © Copyright IBM Corp. 2002. All rights reserved.
-
54 The XML Files: Development of XML/XSL Applications Using WebSphere Studio
-
3 Chapter 3. Processing XML Chapter three provides the reader with an opportunity to learn about the processing of XML documents. The chapter highlights the XML Processor and parser shipped with WebSphere Application Developer. In this chapter, the following topics are described: Xalan XSLT Processor SAX2 DOM Level2 Java API for XML Processing (JAXP) © Copyright IBM Corp. 2002. All rights reserved.
-
3.1 XML applications Today’s organizations’ rapid movement towards e-business brings new demands on defining flexible systems architectures. Systems need to be powerful, scalable, robust, and most of all, capable of meeting new business requirements. With that in mind, applications often need to be able to support multiple client types, all with different capabilities. The dominant client type for Web applications is currently the desktop browser, but that will not last forever.
-
3.2 Xalan Xalan is an XSLT processor for transforming XML documents into HTML, text, or other XML document types. It implements the W3C Recommendations for XSL Transformations (XSLT) and the XML Path Language (XPath). It provides a standard API for performing XML Transformations. It builds on SAX2, DOM Level2, and the XML parser API in Java API for XML Parsing 1.0 (JAXP). It may be configured to work with any XML parser, such as Xerces, that implements JAXP.
-
TransformerFactory creates Templates (stylesheet) invokes input Transformation output Result Source source specification SAX Source Stream Source result specification SAX Result DOM Source DOM Result Stream Result Figure 3-2 javax.xml.transforms interfaces operation 3.3 SAX2 SAX is the Simple API for XML, originally a Java-only API. SAX was the first wisely adopted API for XML in Java.
-
XML A p p lic a t io n SAX API X M L P a rse r XM L D ocum ent Figure 3-3 SAX application components To understand how an event-based API can work, consider the sample document in Example 3-1. Example 3-1 Sample XML document Mary Smith 10001 An event-based interface will break the structure of this document down into a series of linear events, such as those shown in Example 3-2.
-
An application handles these events just as it would handle events from a graphical user interface; there is no need to cache the entire document in memory or secondary storage. Currently, there are two versions of SAX: 1.0 and 2.0. Many changes were made in version 2.0. The focus of this chapter is on SAX version 2.0. Most SAX parsers should support the older 1.0 classes and interfaces, however, you will receive deprecation warnings from the Java complier if you use these older features.
-
implements the ContentHandler interface. To use DefaultHandler, create a subclass and override the methods that interest you. The other methods can safely be ignored, since they are just empty methods. The ParserAdapter class makes a SAX1 Parser behave as a SAX2 XMLReader. The XMLReaderAdapter class makes a SAX2 XML reader behave as a SAX1 parser.
-
With the default SAX2 namespace processing, the XML reader would report a start and end element event with the namespace URI http://www.ibm.com and the local name hr. Most XMLReader implementations also report the original qName html:hr, but that parameter might simply be an empty string (except for elements that are not in the namespace).
-
Attr Element Text Comment CDATASection DocumentType Notation Entity EntityReference ProcessingInstruction These specialized interfaces all inherit the basic attributes and methods provided by the Node interface. They also provide specialized access to unique information associated with each specific XML document item. The resulting specialized nodes are stored in a list of lists structure that has parent_child and sibling-to-sibling links.
-
D o cu m e n t E le m e n t E le m e n t E le m e n t Te x t Te x t E le m e n t E le m e n t E le m e n t Te x t Te x t Figure 3-4 Sample generated DOM tree Document represents the whole documents, and the interface define methods for creating elements, attributes, comments, and so on. Attributes of a Node are manipulated using the methods of the Element interface.
-
URI in DOM Level2 methods. Applications must use the value null as the namespace URI parameter for methods if they wish to have no namespace. 3.5 JAXP The Java API for XML Processing (JAXP) supports processing of XML documents using DOM, SAX, and XSLT. JAXP enables applications to parse and transform XML documents independent of a particular XML processing implementation. Depending on the needs of the application, developers have the flexibility to swap between XML Processors (such as high performance vs.
-
Application Code JAXP DocumentBuilder SAXParser Transformer DOM API Implementation SAX Parser Implementation XSLT Processor Implementation Figure 3-5 JAXP architecture As shown, application code does not deal directly with specific parser or processor implementations. Instead, you write code against abstract classes that JAXP provides. This level of indirection allows you to pick and choose among different implementations without even recompiling your application.
-
Studying Example 3-6, notice that JAXP can read directly from a File object, so three files objects are created for the source XML, the XSLT stylesheet, and the target HTML file. The Source interface is used to read both the XML file and the XSLT file. The Source interface can have many implementations. In this example, we are using StreamSource, which has the ability to read a File object, an InputStream, a Reader, or a system ID.
-
Stylesheet compilation Before a stylesheet can be processed, it must be converted into some internal machine readable format. Usually the stylesheet is read into memory using an XML parser, translated into machine format and then preserved in memory for repeated use. This is called stylesheet compilation. Different XSLT processors implement stylesheet compilation differently, so JAXP includes the javax.xml.transform.Templates interface to provide consistency.
-
4 Chapter 4. Introduction to IBM WebSphere Application Developer This chapter contains an introduction to the concepts behind Application Developer, and an overview of the features of the various members of the WebSphere Studio family of tools. © Copyright IBM Corp. 2002. All rights reserved.
-
4.1 WebSphere Studio product family The WebSphere Studio family of products is built on the top of the Eclipse Workbench as a set of plug-ins conforming to the Workbench’s open standard APIs. These products are then follow-on technology for WebSphere Studio Advanced Edition V3 and VisualAge for Java Enterprise Edition V4.
-
The WebSphere Studio family of products provide integrated development tools for all e-business development roles including Web developers, Java developers, business analysts, architects, and Enterprise programmers. The customizable, targeted and role-based approach of the Workbench will be a common characteristic of future products in the WebSphere Studio family. WebSphere Studio Site Developer Advanced Site Developer Advanced is an IDE intended for Web developers who develop and manage complex Web sites.
-
WebSphere Studio Application Developer Integration Edition Integration Edition includes all of the functionality in Application Developer, plus: Powerful graphical tools to help you quickly and easily build custom application adapters to integrate your J2EE application with your back-end systems, helping you save time and money by reusing existing resources.
-
4.2 Tools The WebSphere Studio family of products includes the following basic tools: Web development tools Relational database tools XML tools Java development tools Web services development tools Team collaboration tools Integrated debugger Server tools for testing and deployment Enterprise JavaBean development tools (not in Site Developer Advanced) Performance profiling tools (not in WSSD) Plug-in development tools 4.2.
-
Over 2,000 images and sounds in the built-in library Integrated, easy-to-use visual layout tool for JSP and HTML file creation and editing Web project creation, using the J2EE-defined hierarchy Creation and visual editing of the Web application deployment descriptor (web.
-
Create XML documents from a DTD, from an XML Schema, or from scratch. Generate JavaBeans from a DTD or XML Schema. Define mappings between XML documents and generate XSLT scripts that transform documents. Create an HTML or XML document by applying an XSL style sheet to an XML document. Map XML files to create an XSL transformation script and to visually step through the XSL file.
-
products that include the Web services feature, help you to build and deploy Web services-enabled applications across the broadest range of software and hardware platforms used by today's businesses. These tools are based on open, cross-platform standards such as Universal Description Discovery and Integration (UDDI), Simple Object Access Protocol (SOAP), and Web Services Description Language (WSDL). 4.2.
-
The debugger includes a debug view that shows threads and stack frames, a process view that shows all currently running and recently terminated processes, and a console view that allows developers to interact with running processes. There are also views that display breakpoints and allow you to inspect variables. 4.2.9 Performance profiling tools The WebSphere Studio family except Site Developer Advanced provide tools that enable you to test the performance of your application.
-
Apache Tomcat, which can be installed only locally and supports testing of Web applications. 4.2.11 Plug-in development tools The WebSphere Studio family (except for Site Developer Advanced) include the PDE (Plug-in Development Environment) which is designed to help you develop platform plug-ins while working inside the platform workbench, and it provides a set of platform extension contributions (views, editors, perspectives, etc.
-
5 Chapter 5. Application Developer XML Tools Chapter four introduces the XML development capabilities of Websphere Application Developer. In particular, the chapter covers the following topics: XML perspective XML editors XML support features in Websphere Studio Application Developer © Copyright IBM Corp. 2002. All rights reserved.
-
5.1 XML perspective Perspectives are a way to look through different views to a a project. Depending on the role of the developer (whether a Web developer, or a Java developer, or an EJB developer, etc.). And also depending on the tasks that the developer must perform, the developer uses a different perspective. The XML perspective is the perspective for XML development in the Application Developer.
-
The view on the bottom left shows the Navigator view, which displays the folders, and files of the project The view on the bottom right shows the Tasks view, which shows the problems and errors to be fixed 5.2 XML perspective editors In this section, we demonstrate the editing capabilities of the XML components editors available in the Application Developer. 5.2.1 XML editor This is a tool for creating and viewing XML files.
-
Figure 5-2 XML editor Editing an XML file The XML Editor has two main views: Source view, Design view, in addition to utilizing the Outline view, and Task view. The Source view is a text editor that lets you directly edit the source of the XML document.
-
the tree nodes give alternatives that are valid for that location. The right column is also used to display content model information associated with elements. The Outline view provides an overview of the XML document that can be useful when navigating large documents. And finally the Task view displays error messages that may be associated with the XML document. Note the editor's page tabs at the bottom of the top right pane.
-
Figure 5-3 DTD Editor In order to handle the contents of a DTD file, you can use the Outline view to add or remove components of your DTD. When you select an object in the Outline view, the Design view will display the properties that are associated with that DTD component object. You can use the Design view to enter values for the selected object. You can switch to the Source view to edit the DTD source directly. The DTD editor also uses the Task view from the workbench for errors reporting.
-
Figure 5-4 Pop-up on DTD file in the Outline view Validating DTD Another useful feature of the DTD editor is the incremental validation feature. At any point during your development of a DTD, you can invoke the Validate process to validate the DTD. Just right-click on the file name in the Navigator view, and select Validate DTD option.
-
Figure 5-5 XML Schema Editor In order to handle the contents of a schema file, you can use the Outline view to add, remove, or rearrange components of your schema. When you select an object in the Outline view, the Design view will display the properties that are associated with that schema component object. you can use the Design view to enter values for the selected object. You can switch to the Source view to edit the schema source directly.
-
Figure 5-6 Pop-up on schema file in the Outline view Making changes and referential integrity As a schema becomes bigger and more complex, there will be more type definitions, and references to those types.
-
One thing to note is that the built-in referential integrity mechanism will only be enforced if the change is made from the Design view. If you make the changes directly by typing in the Source view, then it is your responsibility to ensure that you make all the changes correctly. Any change you made in the Source view will automatically be reflected in the Design and Outline view. Namespace Namespace provides a way to identify where an element or attribute comes from.
-
Source view (as indicated by switching focus to a different view). Any validation errors will be reported in the Task view with a little red marker for the corresponding line in the Source view, and the corresponding object in the Outline view. Also, when making changes in the Design view, pay attention to the status bar. It will contain hints for potential errors in the schema that you are developing. 5.2.4 XSL editor This is a tool for creating and viewing XSL files.
-
Editing an XSL file The XSL editor provides a text editor to handle the source code of the XSL file. It has several text editing features, such as content assist and syntax highlighting. The content assist feature helps you in writing you XSL code, as it is aware of the proper XSL grammar rules. When editing the XSL document, content assist can be invoked to prompt the you with a list of possible XSL constructs to use.
-
If you review the generated XML file, you will notice that the root element is qualified to belong to the target namespace specified in the schema file. It is also important to note that the local elements that belong to the root element are unqualified. That is, they do not have a prefix. This is because the schema file by default specifies that local elements should not be qualified.
-
5.4 XPath support XPath is an XSL sub-language that is designed to be used with XSLT. It is used for identifying or addressing parts of a source XML document. Every node within an XML document can be uniquely identified and located using the syntax defined for XPath. WebSphere Application Developer provides support for XPath. To launch the XPath Builder Move to the XML perspective. Choose an XML file in your project. Right-click, and select Generate —>XPath.
-
by the location path. Location paths can recursively contain expressions that are used to filter sets of nodes. A location path has three steps: 1. An axis, which specifies the tree relationship between the nodes selected by the location step and the context node. 2. A node test, which specifies the node type and expanded-name of the nodes selected by the location step. 3. Zero or more predicates, which use arbitrary expressions to further refine the set of nodes selected by the location step.
-
Figure 5-11 XPath Operators The last tab shows a list of functions to use in your XPath definition, as shown in Figure 5-12. There is a list of node set functions, boolean functions, string functions, number functions, XSLT functions. After you finish defining your XPath, you can click the Execute button to test your XPath. The wizard displays your XPath results, as shown in Figure 5-13.
-
Figure 5-12 XPath functions Chapter 5.
-
Figure 5-13 XPath Query Result screen 5.5 XSL debugger This tool enables you to visually step through an XSL transformation script, highlighting the transformation rules as they are fired. It is used to test the generated XSL style sheet. Simply use the editor to apply the XSL style sheet to a source XML file, and create a new HTML or XML file. You can then trace through the new XML or HTML file to verify if the results are correct. The XSL trace editor only works on a one-to-one basis.
-
Moreover, the XSL debugger allows to add breakpoints to your XSL file, which facilitate the debugging process. To add a breakpoint, just double click on the line number where you want to place the breakpoint, and green ball will appear indicating that there is a breakpoint in this line. To be able to remove a breakpoint, choose the breakpoints tab in the window in the upper right hand corner shown in Figure 5-14.
-
5.6 Web services support XML and its associated family of standards play a central role in Web services by providing a data interchange format that is independent of both programming languages and operating systems. This section gives an overview of the support provided by the Application Developer for XML-based Web services. For detailed information about the development of XML Web services using Websphere Studio Application Developer, please refer to Chapter 9.
-
The generated sample contains the code to instantiate the generated Web service proxy class and to invoke the desired methods on it. You can specify to immediately launch the sample application after the wizard. A default Websphere test environment is started, and the test client starts in a browser, and you can test the Web service. Chapter 5.
-
100 The XML Files: Development of XML/XSL Applications Using WebSphere Studio
-
6 Chapter 6. RDB and XML integration Chapter six discusses XML and SQL capabilities within Application Studio. In any application, simple or complex, a database usually acts as the data store. For any application development tool, whether developing the graphical user interface or the business logic components, an easy to use tool graphical tool that works well with a database is a must. Application Studio’s tool and wizards for interacting with the database provide a multitude of capabilities.
-
6.1 The SQL to XML wizards The SQL to XML wizards are found in the data perpective. To demonstrate the wizards and the files produced, a schema and SELECT statement has to be created. The schema is shown below in Figure 6-1. It consists of three tables: PASSENGER, SCHEDULE, and AIRCRAFT. The PASSENGER and SCHEDULE tables are joined by the flight and flightNo attributes. The aircraft attribute on the SCHEDULE table is connected to the aircraft_key attribute on the AIRCRAFT table through a foreign key.
-
To generate the XML relate files based on the Passenger List Select statement, right-clink on the selectPassengerList statement, and select the Generate new XML from the pop-up menu. The SQL to XML wizard opens as shown below: Figure 6-2 The SQL to XML wizard panel The wizard provides three options (Figure 6-2). The last Output folder is automatically filled in if there is only one project and if that project has been pre-selected. Other projects can be selected by clicking the Browse button.
-
Show table column as option This option produces three files for each select statement. Accordingly, they are named after the select statement, and in our example their names are: The selectPassengerList.html The selectPassengerList.xml The selectPassengerList.xsl The most important files here are the XML and XSL files, because the HTML file can also be generated from these two files.
-