Once upon a time there was a org.apache.cocoon.components.parser.Parser,
but now it's deprecated. OK, so I think I should use the Excalibur
parser component, which has recently been split into a SAX parser and a
DOM parser.
Looking in excalibur-xmlutil-20030122.jar, I found this class:
org.apache.excalibur.xml.sax.Parser. Maybe I can use that. This is my
first try:
org.apache.excalibur.xml.sax.Parser saxParser = null;
try {
saxParser = (org.apache.excalibur.xml.sax.Parser)
manager.lookup(org.apache.excalibur.xml.sax.Parser.ROLE);
}
finally {
if (saxParser != null) manager.release(saxParser);
}
Unfortunately, it doesn't compile, because Parser does not implement
Component, so I resolve the problem with a cast:
if (saxParser != null) manager.release((Component) saxParser);
I'm starting to feel a little bit confused, because I was not aware that
in Java you could get away with that at compile time. Maybe I should
have a look at the JLS, but since I'm lazy and my code runs, I figure
I'd better ask cocoon-dev ;-).
Is this the kosher way of obtaining an XML parser in Cocoon 2.1?
To further complicate things, Eclipse does not like my little class
which implements org.apache.avalon.framework.component.Component, since
it insists that the type Component is deprecated, along with
ComponentManager. In order to play by the rules, I've removed
"Component" from the interfaces my class implements, but Cocoon (or is
it Excalibur?) barfs with a "ClassCastException" when I try to put it in
cocoon.xconf. Well, I just put back the "implements Component"
declaration and live with Eclipse's warnings, but I cannot help feeling
a little disoriented about all this ;-).
Ugo
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]
- Re: What is a Parser? Ugo Cei
- Re: What is a Parser? Jeff Turner
- Re: What is a Parser? Ugo Cei
- Re: What is a Parser? Vadim Gritsenko
- Re: What is a Parser? Stefano Mazzocchi
- Re: What is a Parser? Vadim Gritsenko
- Re: What is a Parser? Sylvain Wallez
- Re: What is a Parser? Berin Loritsch
- Re: What is a Parser? Vadim Gritsenko
- Re: What is a Parser? Stephen McConnell
- Re: What is a Parser? Vadim Gritsenko