#!/usr/bin/env rexx -- chose an element from w3schools that should be simple rexxObject=.saxHandler~new javaProxy=BSFCreateRexxProxy(rexxObject,,"org.xml.sax.ContentHandler") parser=bsf.loadClass("org.xml.sax.helpers.XMLReaderFactory")~createXMLReader parser~setContentHandler(javaProxy) eh=.errorHandler~new javaEH=BsfCreateRexxProxy(eh, , "org.xml.sax.ErrorHandler") parser~setErrorHandler(javaEH) parser~parse("https://www.w3schools.com/xml/cd_catalog.xml") -- parse the InputStream, will call back ::requires BSF.CLS -- get the Java support for ooRexx ::class "SaxHandler" -- a Rexx content handler ("org.xml.sax.ContentHandler") ::method startElement -- callback method for characters use arg , localName say pp(localName) ::method unknown -- intercept all other messages (avoiding runtime error) ::class ErrorHandler -- a Rexx error handler ("org.xml.sax.ErrorHandler") ::method unknown -- handles "warning", "error" and "fatalError" events use arg methName, argArray -- arguments from the Java SAX parser exception=argArray[1] -- retrieve SAXException argument .error~say(methName":"- "line="exception~getLineNumber",col="exception~getColumnNumber":"- pp(exception~getMessage))