惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

W
WeLiveSecurity
T
Tenable Blog
Project Zero
Project Zero
C
Cybersecurity and Infrastructure Security Agency CISA
T
The Exploit Database - CXSecurity.com
P
Palo Alto Networks Blog
S
Schneier on Security
Scott Helme
Scott Helme
S
Securelist
Know Your Adversary
Know Your Adversary
Vercel News
Vercel News
IT之家
IT之家
V
V2EX
F
Fortinet All Blogs
Simon Willison's Weblog
Simon Willison's Weblog
K
Kaspersky official blog
博客园_首页
T
Tailwind CSS Blog
The GitHub Blog
The GitHub Blog
Spread Privacy
Spread Privacy
Microsoft Security Blog
Microsoft Security Blog
Cisco Talos Blog
Cisco Talos Blog
The Register - Security
The Register - Security
有赞技术团队
有赞技术团队
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
The Hacker News
The Hacker News
L
LINUX DO - 热门话题
Hugging Face - Blog
Hugging Face - Blog
博客园 - 三生石上(FineUI控件)
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
CXSECURITY Database RSS Feed - CXSecurity.com
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Threat Research - Cisco Blogs
P
Proofpoint News Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Privacy & Cybersecurity Law Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
CERT Recently Published Vulnerability Notes
S
SegmentFault 最新的问题
AWS News Blog
AWS News Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
P
Proofpoint News Feed
The Cloudflare Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Vulnerabilities – Threatpost

博客园 - 姜伟华

HBase的内存使用 我常用的软件列表 How can I handle a destructor that fails 让windows explorer总是打开文件夹视图的方法 转一个windows "无法停止‘通用卷’设备"的解决方法 终于看到外界宣传我们的产品 Intel XML Software Suite了。 将PDF文件放大缩小 一篇非常不错的探讨pure virtual function call错误的文章。 D-LINK DI-524无线路由器变身DI-624,解决BT断线问题 Emacs在FreeNX下不工作 gdb中如何使用shell环境变量 我的GVIM配置 终于毕业了 放弃office,拥抱latex 终于选定了编辑器了 郁闷的夏天 Jikes RVM中 Java 循环的识别 在PearPC上安装Mandrake 9.1 for PPC的经历 今天复旦软院的第一届学生就要毕业了
开始写XML Code了
姜伟华 · 2005-08-19 · via 博客园 - 姜伟华

非常奇怪的一件事情:我已经在XML这个领域工作了快一年了。而且对于XML的各种规范,例如XML、Schema、Namespace、XSLT、XPath、XQuery,已经它们的最新进展都很熟悉了,各种规范中的犄角嘎拉的咚咚都比较了解了。但我却从来没有用流行的XML包(例如Xerces、JDOM、DOM4J等等)写过任何XML程序。
现在终于要写XML程序了,结果发现自己对于Xerces中的复杂类系统感到无所适从。我想实现这样一个功能:对于DOM中的每个Element,都能够记录它在源文件中的行号。但是这个要求好像有点高。看了Xerces的Mailing List,好像只有一个人提到了这个问题,它的解决方法是:
>
> >Is there a way to get the current number from the sax2 parser?  Either
> >from the implementation of the DefaultHandler's beginElement or
> >endElement callbacks or from the object that has access the the
> >SAX2XMLReaderImpl object?
> >
> >Chris
> >
> >
> >
> I don't know if you've solved this already or not, but you can just
> implement setDocumentLocator from ContentHandler, and set the Locator a
> global variable.
> Then in startElement or endElement you just query the Locator. Easy as that.

我看了一下,XMLScanner类中的成员ReaderMgr实现了Locator接口。但我如何把这个成员像上面所说的那样,变成一个全局变量呢?难道修改Xerces的源代码?
另外,如何用SAXParser去实现一个DOM Tree呢?

另外,找到的方法就是JDOM,在JDOM-contrib中实现了一个LineNumberSAXBuilder和LineNumberElement,好像用它们可以很轻松的实现带行号信息的DOM Tree。

现在的问题就是用什么语言去实现了?如果用Java的话,JDOM显然很不错;而如果用C++的话,JDOM就不能用了。这样,就要去试Xerces的那种方法了。这个问题就不是我能决定的了,只有去问老板的意见了。