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

推荐订阅源

S
Security Affairs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Jina AI
Jina AI
P
Palo Alto Networks Blog
GbyAI
GbyAI
大猫的无限游戏
大猫的无限游戏
A
Arctic Wolf
Hugging Face - Blog
Hugging Face - Blog
小众软件
小众软件
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
Blog — PlanetScale
Blog — PlanetScale
S
Schneier on Security
V
Vulnerabilities – Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
雷峰网
雷峰网
T
Tenable Blog
人人都是产品经理
人人都是产品经理
T
Tor Project blog
C
Cyber Attacks, Cyber Crime and Cyber Security
AWS News Blog
AWS News Blog
Microsoft Security Blog
Microsoft Security Blog
J
Java Code Geeks
Scott Helme
Scott Helme
SecWiki News
SecWiki News
C
CERT Recently Published Vulnerability Notes
Recorded Future
Recorded Future
I
InfoQ
Security Archives - TechRepublic
Security Archives - TechRepublic
Help Net Security
Help Net Security
Cloudbric
Cloudbric
C
Check Point Blog
Engineering at Meta
Engineering at Meta
TaoSecurity Blog
TaoSecurity Blog
B
Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
N
News and Events Feed by Topic
云风的 BLOG
云风的 BLOG
MyScale Blog
MyScale Blog
腾讯CDC
量子位
Application and Cybersecurity Blog
Application and Cybersecurity Blog
K
Kaspersky official blog
Vercel News
Vercel News
F
Full Disclosure
T
Troy Hunt's Blog
Forbes - Security
Forbes - Security
S
Security @ Cisco Blogs

博客园 - 姜伟华

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的那种方法了。这个问题就不是我能决定的了,只有去问老板的意见了。