RexxExpat An Introduction



Similar documents
DTD Tutorial. About the tutorial. Tutorial

PHP and XML. Brian J. Stafford, Mark McIntyre and Fraser Gallop

Last Week. XML (extensible Markup Language) HTML Deficiencies. XML Advantages. Syntax of XML DHTML. Applets. Modifying DOM Event bubbling

Exchanger XML Editor - Canonicalization and XML Digital Signatures

Extensible Markup Language (XML): Essentials for Climatologists

Multimedia Applications. Mono-media Document Example: Hypertext. Multimedia Documents

Introduction to XML Applications

TCP/IP Networking, Part 2: Web-Based Control

An Introduction to Procedural and Object-oriented Programming (Object Rexx) 8 "Automating Windows and Windows Applications"

XML: extensible Markup Language. Anabel Fraga

Illustration 1: Diagram of program function and data flow

PL/JSON Reference Guide (version 1.0.4)

Microsoft' Excel & Access Integration

Standard Recommended Practice extensible Markup Language (XML) for the Interchange of Document Images and Related Metadata

CIS 467/602-01: Data Visualization

Web Development using PHP (WD_PHP) Duration 1.5 months

Intel EP80579 Software for Security Applications on Intel QuickAssist Technology Cryptographic API Reference

TATJA: A Test Automation Tool for Java Applets

Managing XML Documents Versions and Upgrades with XSLT

KITES TECHNOLOGY COURSE MODULE (C, C++, DS)

IBM Tivoli Service Request Manager 7.1

Embedded PHP. Web services vs. embedded PHP. CSE 190 M (Web Programming), Spring 2008 University of Washington

2016 TRAINING CALENDAR

Structured vs. unstructured data. Semistructured data, XML, DTDs. Motivation for self-describing data

DocuSign Information Guide. DocuSign Resource File. Overview. Table of Contents

ADL User Guide for Open AT V4.10

XML and Data Management

T XML in 2 lessons! %! " #$& $ "#& ) ' */,: -.,0+(. ". "'- (. 1

LogProcess v1.0 User Guide

10CS73:Web Programming

Structured vs. unstructured data. Motivation for self describing data. Enter semistructured data. Databases are highly structured

Comparison of SGML and XML

SQLITE C/C++ TUTORIAL

Compiler Construction

Concrete uses of XML in software development and data analysis.

By Nabil ADOUI, member of the 4D Technical Support team

Learning Web Design. Third Edition. A Beginner's Guide to (X)HTML, Style Sheets, and Web Graphics. Jennifer Niederst Robbins

Software API Conventions Implementation Agreement

Pre-authentication XXE vulnerability in the Services Drupal module

Web Design Certification

An Introduction to Procedural and Object-oriented Programming (Object Rexx) 3 "Automating Windows and Windows Applications"

TECHNOLOGY Computer Programming II Grade: 9-12 Standard 2: Technology and Society Interaction

An XML Based Data Exchange Model for Power System Studies

C Compiler Targeting the Java Virtual Machine

Service Availability TM Forum Application Interface Specification

Molecular Dynamics Simulations with Applications in Soft Matter Handout 7 Memory Diagram of a Struct

Software design (Cont.)

XML Processing and Web Services. Chapter 17

Chapter 3: XML Namespaces

We automatically generate the HTML for this as seen below. Provide the above components for the teaser.txt file.

Programming languages C

Working with JSON in RPG. (YAJL Open Source JSON Tool)

RomPager Intro Web Server for ThreadX Programming Reference

3.5. cmsg Developer s Guide. Data Acquisition Group JEFFERSON LAB. Version

Web Design for Programmers. Brian Hogan NAPCS Slides and content 2008 Brian P. Hogan Do not reproduce in any form without permission

Course Name: ADVANCE COURSE IN SOFTWARE DEVELOPMENT (Specialization:.Net Technologies)

Advanced PostgreSQL SQL Injection and Filter Bypass Techniques

Website Standards Association. Business Website Search Engine Optimization

by LindaMay Patterson PartnerWorld for Developers, AS/400 January 2000

ARC: appmosphere RDF Classes for PHP Developers

FileMaker Server 9. Custom Web Publishing with PHP

Mobile Web Design with HTML5, CSS3, JavaScript and JQuery Mobile Training BSP-2256 Length: 5 days Price: $ 2,895.00

Short notes on webpage programming languages

How To Run A Test File Extension On A Rexx (Unix) On A Microsoft Linux (Amd64) (Orchestra) (For Windows) (

StreamServe Persuasion SP4 Service Broker

Data Tool Platform SQL Development Tools

HTML Fails: What No One Tells You About HTML

Avaya Aura Call Center Elite Multichannel Readme Release Patch 2 November 2015

FileMaker Server 14. Custom Web Publishing Guide

FileMaker Server 13. Custom Web Publishing with XML

Advanced Web Development SCOPE OF WEB DEVELOPMENT INDUSTRY

<Namespaces> Core XML Technologies. Why Namespaces? Namespaces - based on unique prefixes. Namespaces. </Person>

Learning Outcomes. Networking. Sockets. TCP/IP Networks. Hostnames and DNS TCP/IP


FileMaker Server 12. Custom Web Publishing with XML

CSE 308. Coding Conventions. Reference

Implementing Rexx Handlers in NetRexx/Java/Rexx

Blackbox Reversing of XSS Filters

XML. CIS-3152, Spring 2013 Peter C. Chapin

Numerical Algorithms Group

RightNow CRM 7.5. Integration Manual. July 2005

SYCL for OpenCL. Andrew Richards, CEO Codeplay & Chair SYCL Working group GDC, March Copyright Khronos Group Page 1

Mobility Information Series

<?xml version= 1.0?> <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN

Cyber Security Challenge Australia 2014

DOCUMENTS ON WEB OBJECTIVE QUESTIONS

Programming Against Hybrid Databases with Java Handling SQL and NoSQL. Brian Hughes IBM

HTML5 & CSS3. ( What about SharePoint? ) presented

TCG. Trusted Platform Module Library Part 2: Structures. TCG Published. Family 2.0. Level 00 Revision October 30, 2014.

What is COM/DCOM. Distributed Object Systems 4 COM/DCOM. COM vs Corba 1. COM vs. Corba 2. Multiple inheritance vs multiple interfaces

How To Use Dreamweaver With Your Computer Or Your Computer (Or Your Computer) Or Your Phone Or Tablet (Or A Computer)

N CYCLES software solutions. XML White Paper. Where XML Fits in Enterprise Applications. May 2001

XML & Databases. Tutorial. 2. Parsing XML. Universität Konstanz. Database & Information Systems Group Prof. Marc H. Scholl

IBM WebSphere Message Broker Message Monitoring, Auditing, Record and Replay. Tim Kimber WebSphere Message Broker Development IBM Hursley Park, UK

Transcription:

Wrapping the XML-parser 'expat' in Rexx/ObjectRexx. Slide 1/19 Wrapping the XML-parser 'expat' in Rexx/ObjectRexx. RexxExpat - An Introduction -

Table of Contents Slide 2/19 Table of Contents Overview of XML and expat Example using XML and expat RexxExpat wrapping expat ing expat or RexxExpat Handlers setting and invocation RexxExpat Special Issues Outlook and References Examples

Overview Slide 3/19 Overview XML (extended Markup Language) expat standardized meta language to define individual document types allows automated processing and easy exchange of data conforming, non-validating XML-parser in C implemented supports individual encodings, namespace processing and external entity parsing

Using XML Slide 4/19 Using XML Data Management Document Management Process Validate Interpretate Templates XML Describe Display Publish Exchange Store

expat in Action Slide 5/19 <?xml version="1.0" standalone='no' encoding='nativeaustrian'?> expat in Action <!DOCTYPE HTML PUBLIC SYSTEM "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/tr/rec-html40/loose.dtd"> <HTML> <BODY> <H1>This is a document to demonstrate expat's work!</h1> <IMG SRC='logo' ALIGN=RIGHT /> Well, an example for an external entity might be the German Umlaut 'ü' and the German ess-zett 'ß' in their escaped form: ü and ß. They are declared in the HTML-DTD (aren't they?). expat <?php echo("to serve XML documents, do like this\n");?> <![CDATA[ >>> This text could be copied from some file ;-). Declaring it as CDATA frees you from converting key characters like the left sharp bracket '<' and the ampersand '&' to its escaped form ("<" and "&")! <<< ]]> element handler routines entity handler routines CDATA handler routines other handler routines... Author &author; </BODY> </HTML>

Example: expat parsing XML Slide 6/19 Example: expat parsing XML <?xml version="1.0" standalone='no' encoding='nativeaustrian'?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" SYSTEM "http://www.w3.org/tr/rec-html40/loose.dtd"> <!-- XML declarations --> <!NOTATION php SYSTEM "http://www.php.net/onlineservices/php.exe"> <!NOTATION gif SYSTEM "http://www.dot.com/viewers/gifviewer.exe"> <!ENTITY logo SYSTEM "/bilder/rexxexpat.gif" NDATA gif> <!ENTITY copyright SYSTEM "copyright.html"> <!ENTITY author "">

Example: expat parsing XML Slide 7/19 <HTML> <BODY> <H1>This is a little document to demonstrate RexxExpat's work!</h1> <IMG SRC='logo' ALIGN=RIGHT /> Well, an example for an external entity might be the German Umlaut 'ü' and the German ess-zett 'ß' in their escaped form: ü and ß. They are declared in the HTML-DTD (aren't they?). <?php echo("to serve XML documents, do like this\n");?> <![CDATA[ >>> This text could be copied from some file ;-). Declaring it as CDATA frees you from converting key characters like the left sharp bracket '<' and the ampersand '&' to its escaped form ("<" and "&")! <<< ]]> Author &author; </BODY> </HTML>

RexxExpat wrapping expat Slide 8/19 RexxExpat wrapping expat RexxExpat expat C handler routines REXX handler routines

ing expat = ing RexxExpat Slide 9/19 ing expat = ing RexxExpat 1. create parser Parser = ExpatParserCreate(); 2. initialize callback routines ExpatSetElementHandler(Parser, "Say 'StartElement <'ARG(2)'>'", "", 1, "EndElementExternFunc.cmd", EnvName, 0); 3. parse and process document (via callback routines) ExpatParse(Parser, Puffer, isfinal) 4. free parser ExpatParserFree(Parser);

Handler setting Slide 10/19 Handler setting Each handler is defined by three parameters ProcName, EnvName, Instore according to the following pseudo code: if (ISNULLSTR(Instore) ISZEROLENSTR(Instore) Instore == 0) { ProcName is a file name of a Rexx procedure } else if (Instore = macro Instore = MACRO ) { ProcName is a macro loaded into the macrospace } else { ProcName contains pure Rexx code }

Handler invocation Slide 11/19 Handler invocation all wrapper functions match the corresponding expat functions handler functions pass through all arguments from C to Rexx callback routines do not return codes (few exceptions) RexxStart ( ArgCount, ArgList, userdata->handler[handlertype]->procname, userdata->handler[handlertype]->instore, userdata->handler[handlertype]->envname, RXSUBROUTINE, NULL, /* no system exits for dll s available */ &result_int, &result_str);

RexxExpat: Special Issues Slide 12/19 RexxExpat: Special Issues UnknownEncodingHandler s return code defines individual encodings: /*set XML_Encoding structure*/ currindex = result_str.strptr; for (i=0; currindex && i<encodingmapsize && currindex<=(result_str.strptr+result_str.strlength); i++, currindex++) { if (isdigit((unsigned char)*currindex)) /*byte defined*/ info->map[i] = strtol(currindex, &currindex, 0); else /*byte left out*/ info->map[i] = i; } /*fill up bytes*/ for (; i<encodingmapsize; i++) info->map[i] = i;

RexxExpat: Special Issues Slide 13/19 RexxExpat: Special Issues Problem: Separate environments in main program and callback routines main program (Rexx) RexxExpat (C) handler routines (Rexx) REXX main program RexxExpat REXX handler routines

RexxExpat: Special Issues Slide 14/19 RexxExpat: Special Issues Variable pool functions to exchange data between main program and callback routines: numeric ExpatSetVariablePool( numeric parser, alphanumeric varnames,...); numeric ExpatGetVariablePool( numeric parser); numeric ExpatFreeVariablePool(numeric parser); Possible obstacle: insufficient memory due to duplication of variable pool

Outlook Slide 15/19 Outlook implementation of an object expat in ObjectRexx Rexx procedure which creates an object model from a given XML-file all current expat functions are wrapped future extensions to expat can be easily appended

References Slide 16/19 References W3C, Extensible Markup Language (XML) 1.0 (Second Edition), Oct. 6, 2000 (http://www.w3.org/tr/rec-xml) Kuno Dünhölter, Extensible Markup Language (XML), version 2.0, Sept. 1, 1998 (http://members.aol.com/xmldoku) xmlparse.h, version 1.2, Thai Open Source Software Center Clark Cooper, Using Expat, Sept. 1, 1999, XML.com, O'Reilly & Associates (http://www.xml.com/pub/1999/09/expat/reference.html) rexxsaa.h, version 1.5, Anders Christensen (/Mark Hessling), The Regina Rexx Interpreter Anders Christensen (/Mark Hessling), The Regina Rexx Interpreter, Aug. 14, 2000, (ftp://ftp.lightlink.com/pub/hessling/regina/reginapdf22.zip) IBM, Object REXX for Windows NT and Windows95 Programming Guide (Version 1.03), third edition, May 1999 (ftp://service.boulder.ibm.com/ps/products/ad/obj-xx/rexxpg.zip)

RexxExpat Example (1) Slide 17/19 RexxExpat Example (1) RexxExpatExample.rexx RxFuncAdd 'ExpatLoadFuncs', 'RexxExpat.dll', 'ExpatLoadFuncs'; Parser ExpatLoadFuncs(); = ExpatParserCreate(); ExpatSetElementHandler(Parser, "StartElement.rexx", "", 0, "EndElement.rexx", "", 0); pad = 5; i = 0; myfile = "Interface.xml"; mypos = 0; Do while lines(myfile)<>0 End nextline = linein(myfile) mypos = STREAM(myfile, 'Command', 'Query Position Read'); ExpatFreeVariablePool(Parser); ExpatSetVariablePool(Parser, "i", "pad"); retstr = ExpatParse(Parser, nextline, lines(myfile)) ExpatGetVariablePool(Parser); If retstr == 0 then say "### ERROR ###" STREAM(myfile, 'Command', 'Position ='mypos Read); ExpatParserFree(Parser); ExpatDropFuncs();

RexxExpat Example (2) Slide 18/19 RexxExpat Example (2) StartElement.rexx Parse Arg Parser, Name Say RxFuncAdd 'ExpatSetVariablePool', 'RexxExpat.dll', 'ExpatSetVariablePool'; RxFuncAdd 'ExpatGetVariablePool', 'RexxExpat.dll', 'ExpatGetVariablePool'; ExpatGetVariablePool(Parser); Insert(Name, "End", i*padding+6); i = i + 1; Exit ExpatSetVariablePool(Parser, "i"); RxFuncDrop 'ExpatSetVariablePool' RxFuncDrop 'ExpatGetVariablePool' EndElement.rexx Parse Arg Parser, Name RxFuncAdd 'ExpatSetVariablePool', 'RexxExpat.dll', 'ExpatSetVariablePool'; RxFuncAdd 'ExpatGetVariablePool', 'RexxExpat.dll', 'ExpatGetVariablePool'; ExpatGetVariablePool(Parser); i = i - 1; Say Exit Insert("/"Name, "End", i*padding+6); ExpatSetVariablePool(Parser, "i"); RxFuncDrop 'ExpatSetVariablePool' RxFuncDrop 'ExpatGetVariablePool'

RexxExpat Data structures Slide 19/19 RexxExpat Data structures /* ExpatHandlers - how many are there? */ enum EXPATHANDLERTYPES { OnStartElement, OnEndElement, OnCharacterData, [...] NumberOfHandlers}; /* ExpatHandler - data storage */ typedef struct TypeDefExpatHandler { PSZ ProcName; PSZ EnvName; PRXSTRING Instore; /* pointer to array[2] */ } *EXPATHANDLER; /* RexxExpatData - to make it thread-safe */ typedef struct TypeDefRexxExpatData { /* Expat-Data */ XML_Parser Parser; /* parser */ XML_Encoding Encoding; /* encoding */ EXPATHANDLER Handler[NumberOfHandlers]; /* handler */ /* Rexx-Data */ PSHVBLOCK shvfirst; /* rexx variable pool */ } *RexxExpatData;