[XML-SIG] [ pyxml-Patches-757799 ] XmlWriter.processingInstruction()

SourceForge.net noreply at sourceforge.net
Fri Jun 20 04:22:43 EDT 2003


Patches item #757799, was opened at 2003-06-20 10:22
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=306473&aid=757799&group_id=6473

Category: SAX
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Paul Ross (apaulross)
Assigned to: Nobody/Anonymous (nobody)
Summary: XmlWriter.processingInstruction()

Initial Comment:
There is a minor bug in this that gives the traceback:

  File "testxmlwriter.py", line 11, in ?
    myXml.processingInstruction('target', 'data=asd')
  File "D:\apps\python\Lib\site-
packages\_xmlplus\sax\writer.py", line 392, in 
processingInstruction
    self._offset = len(s) - (p + 1)
NameError: global name 'p' is not defined

Moving 'pos' up a couple of lines and renaming it 'p' 
seems to fix it (also one line of indenting at the 
first 'else' fixed):

    def processingInstruction(self, target, data):
        s = "%s%s %s%s" % (self.__syntax.pio, target, 
data, self.__syntax.pic)
        prefix = self._prefix[:-self.indentation] \
                 + (" " * self.indentEndTags)
        p = string.rfind(s, "\n")
        if "\n" in s:
           if self._flowing and not self._packing:
                self._write(prefix + s + "\n")
                self._offset = 0
           else:
                self._write(s)
                self._offset = len(s) - (p + 1)
        elif self._flowing and not self._packing:
            self._write(prefix + s + "\n")
            self._offset = 0
        else:
            self._write(s)
            self._offset = len(s) - (p + 1)



----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=306473&aid=757799&group_id=6473



More information about the XML-SIG mailing list