Small cwm patch: fixing embedded RDF

If you have RDF embedded in some larger XML document, cwm's rdf parser
raises an "Unknown RDF parser state 'Not RDF' in end tag" exception.  
For example, this little file won't be processed.

<?xml version="1.0"?>
<metadata  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:s="http://mems-exchange.org/schema/file/1.0/"
         xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>  This is non-RDF content </title>
  <rdf:RDF>
    <rdf:Description rdf:about="%s">
      <dc:Creator>%s</dc:Creator>
      <s:Run>45</s:Run>
    </rdf:Description>
  </rdf:RDF>
  <element />
</metadata>

The patch is simple, just ignoring the NOT_RDF state in the end
tag handler; see below.

--amk

Index: sax2rdf.py
===================================================================
RCS file: /sources/public/2000/10/swap/sax2rdf.py,v
retrieving revision 1.22
diff -u -r1.22 sax2rdf.py
--- sax2rdf.py	2002/08/06 01:36:09	1.22
+++ sax2rdf.py	2002/09/11 18:03:06
@@ -415,7 +415,8 @@
         elif self._state == STATE_DESCRIPTION:
             self._items.pop()
         elif self._state == STATE_NOVALUE or \
-             self._state == STATE_NO_SUBJECT:
+             self._state == STATE_NO_SUBJECT or \
+             self._state == STATE_NOT_RDF:
             pass
         else:
             raise RuntimeError, ("Unknown RDF parser state '%s' in end tag" % self._state, self._stack)

Received on Wednesday, 11 September 2002 20:24:25 UTC