Using XML with Legacy Business Applications

Book description

"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

Table of contents

  1. Copyright
    1. Dedication
  2. Advance Praise for Using XML with Legacy Business Applications
  3. Preface
    1. Acknowledgments
  4. Introduction
    1. The Problem
    2. What Do We Need in a Solution?
      1. Functional Requirements
      2. Nonfunctional Requirements: Good, Fast, and Cheap
    3. The Overview of a Solution
    4. Architecture
      1. Why Not Use XSLT for Everything?
      2. Two Implementations of the Architecture: Java and C++
      3. The Document Object Model
      4. Why Use the DOM?
    5. How to Use This Book
      1. Chapter Organization
      2. Notes for Primary Audiences
      3. Chapter Summaries
      4. Conventions
    6. What You Need to Use This Book
      1. What You Should Already Know
      2. Web Site and Contact Information
      3. General Software
      4. Java Software
      5. C++ Software
    7. For Developers
      1. General Coding Approach and Conventions
      2. Additional C++ Considerations
    8. How You Can Use the Utilities and Code
    9. References
    10. Resources
  5. Converting XML to CSV
    1. Requirements
    2. Running the Utility
    3. Sample Input and Output
    4. Design
      1. Naming Elements
      2. Module Logic
    5. Java Implementation
      1. main in XMLToCSVBasic.java
      2. write in CSVRowWriter.java
      3. Error Handling
    6. C++ Implementation
      1. main in XMLToCSVBasic.cpp
      2. write in CSVRowWriter.cpp
      3. Error Handling
    7. Comparing the Java and C++ Implementations
    8. Enhancements and Alternatives
      1. Validation of the Input Document
      2. Using a ColumnNumber Attribute
      3. A Recursive Algorithm
      4. Advanced Functionality
    9. Resources
  6. Converting CSV to XML
    1. Requirements
    2. Running the Utility
    3. Sample Input and Output
    4. Design
      1. Main Routine
      2. CSVRowReader Class
    5. Java Implementation
      1. main in CSVToXMLBasic.java
      2. parse in CSVRowReader.java
      3. write in CSVRowReader.java
    6. C++ Implementation
      1. main in CSVToXMLBasic.cpp
      2. parse in CSVRowReader.cpp
      3. write in CSVRowReader.cpp
    7. Comparing the Java and C++ Implementations
    8. Enhancements and Alternatives
      1. Validation of the Output Document
      2. Advanced Functionality
      3. Some Observations
    9. Resources
  7. Learning to Read XML Schemas
    1. Rope, Anyone?
    2. A Few Different Document Approaches
    3. DTD Refresher
    4. Foundation Concepts and Terminology
      1. Elements and Types
      2. Simple and Complex
    5. General Features
      1. Schema Declaration in Instance Documents
      2. Comments and Documentation
      3. Element Declarations
    6. Simple Content Elements
      1. Schema Built-in Data Types
      2. Extending and Restricting Simple Types
      3. Setting a Maximum Length
      4. Setting Minimum and Maximum Values
      5. Patterns for Identifiers
      6. Code Lists
      7. Attribute Declarations
    7. Complex Content Elements
      1. Types of Content
      2. Mandatory, Optional, Limits
      3. Creating New Complex Types by Extension
      4. Attribute Declarations
    8. Understanding Namespaces
      1. What Is a Namespace?
      2. URIs, URNs, and URLs
      3. Namespace Qualification in Instance Documents
      4. The W3C XML Schema-Related Namespaces
    9. Structuring Schemas
      1. Global Types and Local Elements versus Global Elements
      2. Named Types and Anonymous Types
      3. Modularity: The xs:include and xs:import Elements
      4. An Example of Importing Type Libraries
    10. Less Commonly Used W3C XML Schema Language Features
      1. Wildcards
      2. Default and Fixed Attributes
      3. Whitespace Suppression
      4. Derivation of Complex Types by Restriction
      5. Redefinition
      6. Named Attribute Groups
      7. Named Model Groups
      8. Abstract Types and Substitution Groups
      9. Keys and Uniqueness
      10. Nillable Elements
    11. Is There Data or Not?
    12. Reference
    13. Resources
  8. Validating against Schemas
    1. Requirements
    2. Running the Utilities
    3. Design
    4. Java Implementation
      1. Input Validation in XMLToCSVBasic.java
      2. Output Validation in CSVToXMLBasic.java
    5. C++ Implementation
      1. Input Validation in XMLToCSVBasic.cpp
      2. Output Validation in CSVToXMLBasic.cpp
    6. Examples of Input Validation Failures
    7. Resources
  9. Refining the Design
    1. Why Refine the Design?
    2. Making XML the Common Format
    3. Analyzing the Legacy Non-XML Grammars
    4. Describing the Legacy Non-XML Grammars
    5. Representing the Legacy Non-XML Grammars in XML
      1. Instance Document Design
      2. File Description Document Design
      3. Schemas for File Description Documents
      4. Schemas for Source and Target Documents
    6. Additional DOM Processing Considerations and Strategies
    7. Multilingual Issues
    8. Error Handling Strategy
    9. High-Level Design
      1. Source Converter Processing
      2. Target Converter Processing
      3. Summary of Classes
    10. Detail Design
      1. Main Routine Structures
      2. Converter Base Class
      3. SourceConverter Base Class (Extends Converter)
      4. TargetConverter Base Class (Extends Converter)
      5. RecordHandler Base Class
      6. RecordReader Base Class (Extends RecordHandler)
      7. RecordWriter Base Class (Extends RecordHandler)
      8. DataCell Base Class
    11. Java Implementation
    12. C++ Implementation
    13. References
    14. Resources
  10. Converting CSV Files to and from XML, Revisited
    1. CSV to XML: Functionality and Operation
      1. Requirements
      2. Running the Utility
      3. Sample Input and Output: Invoice
    2. XML to CSV: Functionality and Operation
      1. Requirements
      2. Running the Utility
      3. Sample Input and Output: Purchase Order
    3. Describing the File Formats
      1. CSV Physical Characteristics
      2. XML Output Characteristics
      3. CSV File Grammar
      4. Example File Description Documents
    4. Schema Examples
    5. High-Level Design Considerations
      1. Grammar Analysis and Description
      2. File Description Document Schemas
    6. CSV to XML: Detail Design
      1. Main Program
      2. CSVSourceConverter Class (Extends SourceConverter)
      3. CSVRecordReader Class (Extends RecordReader)
    7. XML to CSV: Detail Design
      1. Main Program
      2. CSVTargetConverter Class (Extends TargetConverter)
      3. CSVRecordWriter Class (Extends RecordWriter)
    8. New DataCell Methods and Derived Classes
      1. New DataCell Methods
      2. DataCellAN Class
      3. DataCellReal Class
      4. DataCellDateMMsDDsYYYY Class
    9. Java Implementation
    10. C++ Implementation
    11. Enhancements and Alternatives
      1. Additional Data Types
      2. Variety of Record Types
      3. Efficiency and Performance
    12. Resources
  11. Converting Flat Files to and from XML
    1. Flat File to XML: Functionality and Operation
      1. Requirements
      2. Running the Utility
      3. Sample Input and Output: Invoice
    2. XML to Flat File: Functionality and Operation
      1. Requirements
      2. Running the Utility
      3. Sample Input and Output: Purchase Order
    3. Describing the File Formats
      1. Flat File Physical Characteristics
      2. XML Output Characteristics
      3. Flat File Grammar
      4. Example File Description Documents
    4. Schema Examples
    5. High-Level Design Considerations
      1. Grammar Analysis and Description
      2. File Description Document Schemas
    6. Flat File to XML: Detail Design
      1. Main Program
      2. FlatSourceConverter Class (Extends SourceConverter)
      3. FlatRecordReader Class (Extends RecordReader)
    7. XML to Flat File: Detail Design
      1. Main Program
      2. FlatTargetConverter Class (Extends TargetConverter)
      3. FlatRecordWriter Class (Extends RecordWriter)
    8. New DataCell Methods and Derived Classes
      1. New DataCell Methods
      2. New Methods in DataCell Derived Classes
      3. DataCellN Class
      4. DataCellDateYYYYMMDD Class
    9. Java Implementation
    10. C++ Implementation
    11. Enhancements and Alternatives
      1. Additional Data Types
      2. CSV Record Formats
      3. Rounding versus Truncation
      4. Group Fields
      5. Redefined Fields
    12. Resources
  12. Converting EDI to and from XML
    1. Overview of the X12 EDI Syntax and Standards
    2. X12 to XML: Functionality and Operation
      1. Requirements
      2. Running the Utility
      3. Sample Input and Output: 850 Purchase Order
    3. XML to X12: Functionality and Operation
      1. Requirements
      2. Running the Utility
      3. Sample Input and Output: 810 Invoice
    4. Describing the File Formats
      1. X12 File Physical Characteristics
      2. XML Output Characteristics
      3. Transaction Set Grammar
      4. Example File Description Documents
    5. Schema Examples
    6. Supplemental Data Store for Control Numbers
    7. High-Level Design Considerations
      1. Grammar Analysis and Description
      2. File Description Document Schemas
    8. X12 to XML: Detail Design
      1. Main Program
      2. X12SourceConverter Class (Extends SourceConverter)Overview
      3. EDIRecordReader Class (Extends RecordReader)
      4. X12RecordReader Class (Extends EDIRecordReader)
    9. XML to X12: Detail Design
      1. Main Program
      2. X12TargetConverter Class (Extends TargetConverter)
      3. EDIRecordWriter Class (Extends RecordWriter)
      4. X12RecordWriter Class (Extends EDIRecordWriter)
    10. New DataCell Methods and Derived Classes
      1. DataCellX12N Class (Extends DataCellN)
      2. DataCellX12R Class (Extends DataCellReal)
      3. DataCellX12DT Class (Extends DataCellDateYYYYMMDD)
      4. DataCellX12TM Class
    11. Java Implementation
    12. C++ Implementation
    13. Enhancements and Alternatives
    14. Reference
    15. Resources
  13. Converting from One XML Format to Another with XSLT
    1. Why XSLT Is Important
    2. XSLT Overview
      1. A Simple Example: Hello World
      2. Another Simple Example: Changing Tag Names
    3. A General Approach to Using XSLT
    4. XPath Basics
    5. Structuring Stylesheets
    6. A Bit of Housekeeping
      1. The xsl:output Element
      2. Running Transformations from a Command Line
    7. Manipulating Content
      1. Adding and Removing Content
      2. Splitting Data Content
      3. Combining Data Content
      4. Changing an Attribute to an Element
      5. Changing an Element to an Attribute
    8. Solving Typical Navigation Problems
      1. Mapping a Flat Structure to a Hierarchy
      2. Mapping a Hierarchy to a Flat Structure
      3. Tips for Dealing with Other Navigation Problems
    9. Advanced Techniques for Processing Content
      1. Omitting Empty Elements and Attributes
      2. Converting Coded Values
      3. Handling Calculations
    10. Handling Namespaces
    11. Calling Non-XSLT Procedures
    12. References
    13. Resources
  14. Using the Conversion Techniques Together
    1. Pipe and Filter Revisited
    2. Sample Conversion Scenarios and Scripts
      1. Purchase Order: UBL to XML to CSV
      2. Invoice: Flat File to XML to EDI
      3. Campaign Contribution Reporting: CSV to XML to Flat File
    3. Building a System: Babel Blaster
      1. Version 1.0 Requirements
      2. Architectural Overview
      3. Trading Partner/Application Information
      4. Linking Pipes and Filters
      5. Version 1.1 Requirements
    4. Resources
  15. Building XML Support into a Business Application
    1. What Should Be “XMLized”?
    2. Devising an Architecture
      1. Add-on or Major Redesign?
      2. If, How, and Where to Validate
    3. Selecting the XML Format
      1. Use a Standard or Roll Your Own?
      2. General Document Design Decisions
      3. Providing Identifying Information
      4. Schema Design
    4. Changing Your Code
      1. Input and Import
      2. Printed Output and Export
      3. Adding XSLT
      4. Making XML the Native Output Format
      5. Making XML a Native Storage Format
    5. What about Databases?
    6. Other Approaches and APIs
      1. Simple API for XML
      2. Generated Class Bindings
      3. Options for Procedural Languages
    7. Non-XML Issues
      1. Looking Up and Converting Coded Values
      2. User-Defined Fields
      3. Business Process Support
    8. Resources
      1. Code-Level XSLT Integration
      2. Databases and XML
      3. Schema Design
  16. Security, Transport, Packaging, and Other Issues
    1. Some General Observations about Security
    2. Dealing with Security
      1. Security Requirements and Exposure
      2. Countermeasures and Remediation Strategies
      3. Prevention Countermeasures
    3. Transport
    4. Packaging
    5. Common Combinations for Security, Transport, and Packaging
    6. Emerging Technologies
    7. What This Means for You
    8. Reference
  17. GNU General Public License
    1. Preamble
    2. Terms and Conditions for Copying, Distribution and Modification
    3. How to Apply These Terms to Your New Programs
  18. Pseudocode Conventions
    1. Assignment Operator
    2. Mathematical Operators
    3. Equality and Relational Operators
    4. IF Selection Structures
    5. Repetition Structure
    6. Case Selection Structure
  19. COM Essentials for the Non-COM Programmer
    1. #import and Smart Pointers
    2. Initialization and Resource Management
    3. Exceptions and Errors
    4. COM Classes and Data Types for C++
  20. Bibliography
    1. References
    2. Resources
  21. Credits
    1. Chapter 1
    2. Chapter 4
    3. Chapter 5
    4. Chapter 6
    5. Chapter 8
    6. Chapter 9
    7. Chapter 12

Product information

  • Title: Using XML with Legacy Business Applications
  • Author(s): Michael C. Rawlins
  • Release date: August 2003
  • Publisher(s): Addison-Wesley Professional
  • ISBN: 0321154940