parse arg xmlFileName javaProxy =BsfCreateRexxProxy(.saxHandler~new, , "org.xml.sax.ContentHandler") /* create a Java SAX parser object */ parser=bsf.loadClass("org.xml.sax.helpers.XMLReaderFactory")~createXMLReader /* set the content handler to our proxy */ parser~setContentHandler(javaProxy) /* create a Rexx object for error handling */ eh=.errorHandler~new /* create a Java proxy using the Rexx object for error handling */ javaEH=BsfCreateRexxProxy(eh, , "org.xml.sax.ErrorHandler") /* set the parser's error handler (optional) */ parser~setErrorHandler(javaEH) /* parse the InputStream, the parser will call the content handler */ parser~parse(xmlFileName) ::requires BSF.CLS /* get the Java support */ ::class "saxHandler" /* a Rexx content handler, matching the interface "org.xml.sax.ContentHandler" */ ::method init /* constructor */ expose tab /* direct access to attributes */ tab="09"x /* tab char */ ::method startDocument /* new document*/ expose level /* direct access to attributes */ level=0 /* indicates current level */ ::method startElement expose level tab /* direct access to attributes */ use arg strNameSpaceURI, strLocalName, strQualifiedName, atts say tab~copies(level) || pp(strQualifiedName) level=level+1 /* increase level counter */ bool_of_p = 0 if strQualifiedName == "p" then bool_of_p = bool_of_p + 1 if bool_of_p == 1 then say "Hier endet der Paragraph! :) Super cool" ::method endElement expose level /* direct access to attribute */ level=level-1 /* decrease level counter */ ::method unknown /* intercept all other messages to do nothing */ ::class ErrorHandler /* will handle "org.xml.sax.ErrorHandler" events*/ ::method unknown /* handles "warning", "error" and "fatalError" events */ use arg methName, argArray /* fetch arguments */ exception=argArray[1] /* retrieve SAXException argument */ /* display error message */ .error~say(methName":" "line="exception~getLineNumber",col="exception~getColumnNumber":" pp(exception~getMessage))