This page is a part of Tools for parsing XML with Python.

xmlproc: A Python XML parser

Version: 0.52
Author: Lars Marius Garshol
Email: larsga@ifi.uio.no
Released: 12.Sep.98

What is xmlproc?

xmlproc is an XML parser written in Python. It is a fairly complete validating parser, but does not do everything required of a validating parser, or even a well-formedness parser. The average user should not run into any omissions, though. Later releases will be more complete.

xmlproc now supports both SGML Open Catalogs and XCatalog 0.1.

Deviations from the XML specification

xmlproc does not follow the XML specification in these respects:

All other deviations from the specification are unintentional bugs and should be reported to me via email. Hopefully, xmlproc will be 100% compliant in version 1.00.

Using xmlproc

xmlproc can be used both as a command-line parser and as a parser API you can use to write XML applications.

The command-line parser

The command-line parser is in xpcmd.py for well-formedness parsing and xvcmd.py for validating parsing. Currently xpcmd.py only accepts one argument: the URL to the file to parse. (You can use just the file name instead of a full URL if you like.)

xvcmd.py has more options:

Usage:

  xvcmd.py [-c catalog] [-l language] {-o format] [urltodoc]

  ---Options:  
  catalog:  path to catalog file to use to resolve public identifiers
  language: ISO 3166 language code for language to use in error messages
  format:   Format to output parsed XML. 'e': ESIS, 'x': canonical XML
            No data will be outputted if this option is not specified
  urltodoc: URL to the document to parse. (You can use plain file names
            as well.) Can be omitted if a catalog is specified and contains
            a DOCUMENT entry.  
            
  Catalog files with URLs that end in '.xml' are assumed to be XCatalogs,
  all others are assumed to be SGML Open Catalogs.

  If the -c option is not specified the environment variables XMLXCATALOG
  and XMLSOCATALOG will be used (in that order).

Basic usage

If you want to make a program that gets data from the parser you should subclass the Application class in xmlapp.py. This is a sample xmlproc client:


from xml.parsers.xmlproc import xmlproc

class MyApplication(xmlproc.Application):
    pass # Add some useful stuff here

p=xmlproc.XMLProcessor()  # Make this xmlval.XMLValidator if you want to validate
p.set_application(MyApplication())
p.parse_resource("foo.xml")

More detailed information

The xmlproc APIs are now documented. Note however, that if possible, you should use the SAX API instead of xmlprocs native API. This is because the SAX API will allow you to switch parsers without changing your application code.

Licence?

xmlproc is free and you can do as you like with it. If you change it, please let me know.

Getting xmlproc

You can download xmlproc here.

Changes since last release

These are the changes since version 0.51:

Feedback

Any and all feedback is welcome, from suggestions for improvements or new features to bug reports. And I really mean it! If you have some opinions on this program, please let me hear them.

Email notification of new versions

To be notified by email when a new version is released, fill out this form. I guarantee that these email addresses won't be used for any other purpose, and that you'll receive notification if the service dies. (If you follow the Python XML-SIG mailing list you won't need to register here since new releases will also be announced there.)

Your full name:
Your email address:

14.Sep.98 23:19, Lars Marius Garshol, larsga@ifi.uio.no. A part of Tools for parsing XML with Python.