homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author patrick.vrijlandt
Recipients docs@python, patrick.vrijlandt
Date 2012年01月14日.12:02:13
SpamBayes Score 8.293186e-06
Marked as misclassified No
Message-id <1326542534.95.0.205057982858.issue13784@psf.upfronthosting.co.za>
In-reply-to
Content
Problem:
Locator methods return the location where the event starts, not where it ends.
Locator line numbers start at 1, Locator column numbers can be 0.
Proposal:
Adapt documentation.
From the docs:
Instances of Locator provide these methods:
Locator.getColumnNumber() 
Return the column number where the current event ends.
Locator.getLineNumber() 
Return the line number where the current event ends
My Test:
import xml.sax
data = b"""<main>
 <sub
 attr="1"
 id="name"
 >
 <subsub />
 </sub>
</main>"""
class MyHandler(xml.sax.handler.ContentHandler):
 def startElement(self, name, attrs):
 if name == "sub":
 print("open", name, self._locator.getLineNumber(), self._locator.getColumnNumber())
 
 def endElement(self, name):
 if name == "sub":
 print("close", name, self._locator.getLineNumber(), self._locator.getColumnNumber())
xml.sax.parseString(data, MyHandler())
Output:
open sub 2 4
close sub 7 4
History
Date User Action Args
2012年01月14日 12:02:15patrick.vrijlandtsetrecipients: + patrick.vrijlandt, docs@python
2012年01月14日 12:02:14patrick.vrijlandtsetmessageid: <1326542534.95.0.205057982858.issue13784@psf.upfronthosting.co.za>
2012年01月14日 12:02:14patrick.vrijlandtlinkissue13784 messages
2012年01月14日 12:02:13patrick.vrijlandtcreate

AltStyle によって変換されたページ (->オリジナル) /