Home > Store

Using XML with Legacy Business Applications

Register your product to gain access to bonus material or receive a coupon.

Using XML with Legacy Business Applications

Book

  • Sorry, this book is no longer in print.
Not for Sale

Description

  • Copyright 2004
  • Edition: 1st
  • Book
  • ISBN-10: 0-321-15494-0
  • ISBN-13: 978-0-321-15494-1

"This volume offers relentlessly pragmatic solutions to help your business applications get the most out of XML, with a breezy style that makes the going easy. Mike has lived this stuff; he has a strong command of the solutions and the philosophy that underlies them."
--Eve Maler, XML Standards Architect, Sun Microsystems

Businesses running legacy applications that do not support XML can face a tough choice: Either keep their legacy applications or switch to newer, XML-enhanced applications. XML presents both challenges and opportunities for organizations as they struggle with their data.

Does this dilemma sound familiar? What if you could enable a legacy application to support XML? You can. In Using XML with Legacy Business Applications, e-commerce expert Michael C. Rawlins outlines usable techniques for solving day-to-day XML-related data exchange problems. Using an easy-to-understand cookbook approach, Rawlins shows you how to build XML support into legacy business applications using Java and C++. The techniques are illustrated by building converters for legacy formats. Converting CSV files, flat files, and X12 EDI to and from XML will never be easier!

Inside you'll find:

  • A concise tutorial for learning to read W3C XML schemas
  • An introduction to using XSLT to transform between different XML formats
  • Simple, pragmatic advice on transporting XML documents securely over the Internet

For developers working with either MSXML with Visual C++ or Java and Xerces:

  • See Chapter 3 for a step-by-step guide to enabling existing business applications to export XML documents
  • See Chapter 2 for a step-by-step guide to enabling existing business applications to import XML documents
  • See Chapter 5 for code examples and tips for validating XML documents against schemas
  • See Chapter 12 for general tips on building commerce support into an application

For end users who need a simple and robust conversion utility:

  • See Chapter 7 for converting CSV files to and from XML
  • See Chapter 8 for converting flat files to and from XML
  • See Chapter 9 for converting X12 EDI to and from XML
  • See Chapter 11 for tips on how to use these techniques together for complex format conversions

The resource-filled companion Web site (www.rawlinsecconsulting.com/booksupplement) includes executable versions of the utilities described in the book, full source code in C++ and Java, XSLT stylesheets, bug fixes, sample input and output files, and more.



0321154940B07142003

Downloads

Source Code

Untitled Document Click below for source code related to this title:

Schemas and Samples--schemasamp.zip--Contains all run time schemas, sample data files, sample schemas, sample XSLT stylesheets, and sample data files

C++ Binaries--cppbin.zip--Contains the Windows C++ executable programs

Java Binaries--javabin.zip--Contains the Java jar file for the compiled java classes

C++ Source - cppsource.zip - Contains the C++ source code

Java Source - javasource.zip - Contains the Java source code

Supplemental Material:
http://www.rawlinsecconsulting.com/booksupplement--Additional examples, latest bug fixes, links, other resources.

Sample Content

Online Sample Chapter

Opening the Door to Open Source

Downloadable Sample Chapter

Download the Sample Chapter related to this title.

Table of Contents



Preface.


1. Introduction.

The Problem.

What Do We Need in a Solution?

Functional Requirements.

Nonfunctional Requirements: Good, Fast, and Cheap.

The Overview of a Solution.

Architecture.

Why Not Use XSLT for Everything?

Two Implementations of the Architecture: Java and C++.

The Document Object Model.

Why Use the DOM?

How to Use This Book.

Chapter Organization.

Notes for Primary Audiences.

Chapter Summaries.

Conventions.

What You Need to Use This Book.

What You Should Already Know.

Web Site and Contact Information.

General Software.

Java Software.

C++ Software.

For Developers.

General Coding Approach and Conventions.

Additional C++ Considerations.

How You Can Use the Utilities and Code.

References.

Resources.



2. Converting XML to CSV.

Requirements.

Running the Utility.

Sample Input and Output.

Design.

Naming Elements.

Module Logic.

Java Implementation.

main in XMLToCSVBasic.java.

write in CSVRowWriter.java.

Error Handling.

C++ Implementation.

main in XMLToCSVBasic.cpp.

write in CSVRowWriter.cpp.

Error Handling.

Comparing the Java and C++ Implementations.

Enhancements and Alternatives.

Validation of the Input Document.

Using a ColumnNumber Attribute.

A Recursive Algorithm.

Advanced Functionality.

Resources.



3. Converting CSV to XML.

Requirements.

Running the Utility.

Sample Input and Output.

Design.

Main Routine.

CSVRowReader Class.

Java Implementation.

main in CSVToXMLBasic.java.

parse in CSVRowReader.java.

write in CSVRowReader.java.

C++ Implementation.

main in CSVToXMLBasic.cpp.

parse in CSVRowReader.cpp.

write in CSVRowReader.cpp.

Comparing the Java and C++ Implementations.

Enhancements and Alternatives.

Validation of the Output Document.

Advanced Functionality.

Some Observations.

Resources.



4. Learning to Read XML Schemas.

Rope, Anyone?

A Few Different Document Approaches.

DTD Refresher.

Foundation Concepts and Terminology.

Elements and Types.

Simple and Complex.

General Features.

Schema Declaration in Instance Documents.

Comments and Documentation.

Element Declarations.

Simple Content Elements.

Schema Built-in Data Types.

Extending and Restricting Simple Types.

Setting a Maximum Length.

Setting Minimum and Maximum Values.

Patterns for Identifiers.

Code Lists.

Attribute Declarations.

Complex Content Elements.

Types of Content.

Mandatory, Optional, Limits.

Creating New Complex Types by Extension.

Attribute Declarations.

Understanding Namespaces.

What Is a Namespace?

URIs, URNs, and URLs.

Namespace Qualification in Instance Documents.

The W3C XML Schema-Related Namespaces.

Structuring Schemas.

Global Types and Local Elements versus Global Elements.

Named Types and Anonymous Types.

Modularity: The xs:include and xs:import Elements.

An Example of Importing Type Libraries.

Less Commonly Used W3C XML Schema Language Features.

Is There Data or Not?

Reference.

Resources.



5. Validating against Schemas.

Requirements.

Running the Utilities.

Design.

Java Implementation.

Input Validation in XMLToCSVBasic.java.

Output Validation in CSVToXMLBasic.java.

C++ Implementation.

Input Validation in XMLToCSVBasic.cpp.

Output Validation in CSVToXMLBasic.cpp.

Examples of Input Validation Failures.

Resources.



6. Refining the Design.

Why Refine the Design?

Making XML the Common Format.

Analyzing the Legacy Non-XML Grammars.

Describing the Legacy Non-XML Grammars.

Representing the Legacy Non-XML Grammars in XML.

Instance Document Design.

File Description Document Design.

Schemas for File Description Documents.

Schemas for Source and Target Documents.

Additional DOM Processing Considerations and Strategies.

Multilingual Issues.

Error Handling Strategy.

High-Level Design.

Source Converter Processing.

Target Converter Processing.

Summary of Classes.

Detail Design.

Main Routine Structures.

Converter Base Class.

SourceConverter Base Class (Extends Converter).

TargetConverter Base Class (Extends Converter).

RecordHandler Base Class.

RecordReader Base Class (Extends RecordHandler).

RecordWriter Base Class (Extends RecordHandler).

DataCell Base Class.

Java Implementation.

C++ Implementation.

References.

Resources.



7. Converting CSV Files to and from XML, Revisited.

CSV to XML: Functionality and Operation.

Requirements.

Running the Utility 211 Sample Input and Output: Invoice.

XML to CSV: Functionality and Operation.

Requirements.

Running the Utility.

Sample Input and Output: Purchase Order.

Describing the File Formats.

CSV Physical Characteristics.

XML Output Characteristics.

CSV File Grammar.

Example File Description Documents.

Schema Examples.

High-Level Design Considerations.

Grammar Analysis and Description.

File Description Document Schemas.

CSV to XML: Detail Design.

Main Program.

CSVSourceConverter Class (Extends SourceConverter).

CSVRecordReader Class (Extends RecordReader).

XML to CSV: Detail Design.

Main Program.

CSVTargetConverter Class (Extends TargetConverter).

CSVRecordWriter Class (Extends RecordWriter).

New DataCell Methods and Derived Classes.

New DataCell Methods.

DataCellAN Class.

DataCellReal Class.

DataCellDateMMsDDsYYYY Class.

Java Implementation.

C++ Implementation.

Enhancements and Alternatives.

Additional Data Types.

Variety of Record Types.

Efficiency and Performance.

Resources.



8. Converting Flat Files to and from XML.

Flat File to XML: Functionality and Operation.

Requirements.

Running the Utility.

Sample Input and Output: Invoice.

XML to Flat File: Functionality and Operation.

Requirements.

Running the Utility.

Sample Input and Output: Purchase Order.

Describing the File Formats.

Flat File Physical Characteristics.

XML Output Characteristics.

Flat File Grammar.

Example File Description Documents.

Schema Examples.

High-Level Design Considerations.

Grammar Analysis and Description.

File Description Document Schemas.

Flat File to XML: Detail Design.

Main Program.

FlatSourceConverter Class (Extends SourceConverter).

FlatRecordReader Class (Extends RecordReader).

XML to Flat File: Detail Design.

Main Program.

FlatTargetConverter Class (Extends TargetConverter).

FlatRecordWriter Class (Extends RecordWriter).

New DataCell Methods and Derived Classes.

New DataCell Methods.

New Methods in DataCell Derived Classes.

DataCellN Class.

DataCellDateYYYYMMDD Class.

Java Implementation.

C++ Implementation.

Enhancements and Alternatives.

Additional Data Types.

CSV Record Formats.

Rounding versus Truncation.

Group Fields.

Redefined Fields.

Resources.



9. Converting EDI to and from XML.

Overview of the X12 EDI Syntax and Standards.

X12 to XML: Functionality and Operation.

Requirements.

Running the Utility.

Sample Input and Output: 850 Purchase Order.

XML to X12: Functionality and Operation.

Requirements.

Running the Utility.

Sample Input and Output: 810 Invoice.

Describing the File Formats.

X12 File Physical Characteristics.

XML Output Characteristics.

Transaction Set Grammar.

Example File Description Documents.

Schema Examples.

Supplemental Data Store for Control Numbers.

High-Level Design Considerations.

Grammar Analysis and Description.

File Description Document Schemas.

X12 to XML: Detail Design.

Main Program.

X12SourceConverter Class (Extends SourceConverter).

EDIRecordReader Class (Extends RecordReader).

X12RecordReader Class (Extends EDIRecordReader).

XML to X12: Detail Design.

Main Program.

X12TargetConverter Class (Extends TargetConverter).

EDIRecordWriter Class (Extends RecordWriter).

X12RecordWriter Class (Extends EDIRecordWriter).

New DataCell Methods and Derived Classes.

DataCellX12N Class (Extends DataCellN).

DataCellX12R Class (Extends DataCellReal).

DataCellX12DT Class (Extends DataCellDateYYYYMMDD).

DataCellX12TM Class.

Java Implementation.

C++ Implementation.

Enhancements and Alternatives.

Reference.

Resources.



10. Converting from One XML Format to Another with XSLT.

Why XSLT Is Important.

XSLT Overview.

A Simple Example: Hello World.

Another Simple Example: Changing Tag Names.

A General Approach to Using XSLT.

XPath Basics.

Structuring Stylesheets.

A Bit of Housekeeping.

The xsl:output Element.

Running Transformations from a Command Line.

Manipulating Content.

Adding and Removing Content.

Splitting Data Content.

Combining Data Content.

Changing an Attribute to an Element.

Changing an Element to an Attribute.

Solving Typical Navigation Problems.

Mapping a Flat Structure to a Hierarchy.

Mapping a Hierarchy to a Flat Structure.

Tips for Dealing with Other Navigation Problems.

Advanced Techniques for Processing Content.

Omitting Empty Elements and Attributes.

Converting Coded Values.

Handling Calculations.

Handling Namespaces.

Calling Non-XSLT Procedures.

References.

Resources.



11. Using the Conversion Techniques Together.

Pipe and Filter Revisited.

Sample Conversion Scenarios and Scripts.

Purchase Order: UBL to XML to CSV.

Invoice: Flat File to XML to EDI.

Campaign Contribution Reporting: CSV to XML to Flat File.

Building a System: Babel Blaster.

Version 1.0 Requirements.

Architectural Overview.

Trading Partner/Application Information.

Linking Pipes and Filters.

Version 1.1 Requirements.

Resources.



12. Building XML Support into a Business Application.

What Should Be XMLized?

Devising an Architecture.

Selecting the XML Format.

Changing Your Code.

What about Databases?

Other Approaches and APIs.

Non-XML Issues.

Resources.



13. Security, Transport, Packaging, and Other Issues.

Some General Observations about Security.

Dealing with Security.

Security Requirements and Exposure.

Countermeasures and Remediation Strategies.

Prevention Countermeasures.

Transport.

Packaging.

Common Combinations for Security, Transport, and Packaging.

Emerging Technologies.

What This Means for You.

Reference.



Appendix A. GNU General Public License.


Appendix B. Pseudocode Conventions.


Appendix C. COM Essentials for the Non-COM Programmer.


Bibliography.


Credits.


Index.

Preface

Some day most business applications will be able to read and write XML files. Until that happens, you are probably going to need techniques and utilities like those presented in this book. This book is for people who use business applications that don't currently support XML, and for people who develop those applications and want to build XML support into them. It is designed to provide a tool kit of techniques and utilities that can help you to perform common EAI, B2B, and EDI data conversion operations using XML.

Nothing in this book is rocket science. Any good programmer with experience in the relevant technologies could develop any of these techniques and utilities. The point of this book is that I've done it so that you don't have to. As is often said, good programmers develop good programs. Better programmers steal what they can and modify it. Steal this code.

If you are a user of a business application and already have or can afford to procure a capable EAI or EDI software package, you probably don't need this book. However, if you only have some simple needs that don't justify the purchase of such a package, or if for some other reason you don't want to or can't afford to spend thousands of dollars to purchase one, then this book is for you. In addition, if you are interested in an open, nonproprietary, standards based, and portable approach to data conversion, then this book is for you, too.



0321154940P04212003

Index

Download the Index file related to this title.

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020