You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Martin Kersten <Ma...@Student.Uni-Magdeburg.DE> on 2004/02/29 01:11:10 UTC
[Digester 1.5] Pattern matching screwed me up
Hi maillist,
after I've tried for hours to get my simple XML shema working
(due to bad documentation if you ask me). I nearly give up.
My problem? Well I want to use selfcontainment. Given you
an example:
<a><a>
<b></b>
</a></a>
So whats the problem?
First of all this wont work:
digester.addObjectCreate("a",A.class);
digester.addObjectCreate("b",B.class);
digester.addSetNext("a/a","add");
digester.addSetNext("a/b","addB");
Why does this wont work? Well took me an hour
to figure it out (thanks for the hidden java doc documentation
-why not pointing it out in a seperate documentation file? Like
everyone does?)
Ok here you go, just add an */ to match everything...
digester.addObjectCreate("*/a",A.class);
digester.addObjectCreate("*/b",B.class);
digester.addSetNext("*/a/a","add");
digester.addSetNext("*/a/b","addB");
Looks right, doesn't it? Well not for digester, it seams! Since
*/a/a is a closer pattern match it seams, adding it is just more
important then creating the object first (who cares null pointer?!).
Ok therefore lets add a hack:
digester.addObjectCreate("*/a",A.class);
digester.addObjectCreate("*/b",B.class);
digester.addObjectCreate("*/a/a",A.class);
digester.addObjectCreate("*/b/a",B.class);
digester.addSetNext("*/a/a","add");
digester.addSetNext("*/a/b","addB");
Works! But halt, bad karma... . If you have something
like setProperties("*/a","id","id"); You can collapse right
now. Since */a is not as exact as */a/a it would not be called
right out of the box (setNext will be called first). So what to do?
Adding another setProperties("*/a/a","id","id")?
Would fix it!
Crazy. It seams I've missed an important information. Can someone
shade some light? I dont want to blaim digester but I am trying
for hours. I wanted to save time but who could know that
digester hates tags containing itself. (anyone like trees?).
I can not imagen that simple trees are beyond the caps of digester.
So I am thinking the fault is just on my side.
So please, tell me what am I doing wrong?!
Thanks
Martin (Kersten)
PS: Tried for more then four hours fooling around with test cases, looking
for the internet and debugging the digester api. I am just a little, well lets
call it disapointed... .
Re: [Digester 1.5] Pattern matching screwed me up
Posted by Martin Kersten <Ma...@Student.Uni-Magdeburg.DE>.
> > How about changing:
> >
> > [snip]
> > The Release Notes document the new features and bug fixes that have been
> > included in this release.
> >
> > The JavaDoc API documents are available online. In particular, you
should
> > read the package description for the org.apache.commons.digester package
> > for detailed information on using the package.
> > [snap]
> >
> > to:
> >
> > The Release Notes document the new features and bug fixes that have been
> > included in this release.
> >
> > The Documentation is part of the JavaDoc API documentation. In
particular,
> > you should read the package description for the
org.apache.commons.digester
> > package for detailed information on using the package.
> >
> > The JavaDoc API documents are also available online.
>
> I think this is a good suggestion, so I have made some minor changes to
> the "index.xml" xdoc file. I don't have Maven installed, so rather than
> commit the change without having tested it, here is a patch that I hope
> some maven user can test & apply.
>
>
> > I would suggest the following to prevent another one falling some traps
> > I went through and wasted 4 hours of my life. Well not wasted entirely
> > but it wasn't that productive also.
> >
> > a) refactor the The JavaDoc API documentation is available... and
> > split it up and mention the documentation being part of the api in
> > first place.
> Sorry, I don't understand this. Refactor what and how? Split what up?
Well refactoring means taking the old changing its structure without
changing its content. Thats why I applied it here. It does simply mean
what you 've done when creating the index.xml :)
>
> >
> > b) alter the package documentation to reflect whats happening when
> > it comes to self containment. (tag contains itself as child, the
information
> > was lagging).
>
> Can you provide a patch to the existing package.html file which includes
> the information you want? I will proof-read it for you.
Well ok. Simply I would like to add a part about self-containment of tags.
(The question I had and the solution to it).
Thanks,
Martin (Kersten)
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [Digester 1.5] Pattern matching screwed me up
Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
On 29 Feb 2004, at 22:24, Simon Kitching wrote:
<snip>
> I think this is a good suggestion, so I have made some minor changes
> to
> the "index.xml" xdoc file. I don't have Maven installed, so rather than
> commit the change without having tested it, here is a patch that I hope
> some maven user can test & apply.
committed.
BTW the format used in the xdocs is based on the one used by anakia (a
velocity driven xml transformation engine). there is some documentation
buried somewhere around
http://jakarta.apache.org/site/jakarta-site2.html.
- robert
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [Digester 1.5] Pattern matching screwed me up
Posted by Simon Kitching <si...@ecnetwork.co.nz>.
[Martin Kersten wrote:]
> How about changing:
>
> [snip]
> The Release Notes document the new features and bug fixes that have been
> included in this release.
>
> The JavaDoc API documents are available online. In particular, you should
> read the package description for the org.apache.commons.digester package
> for detailed information on using the package.
> [snap]
>
> to:
>
> The Release Notes document the new features and bug fixes that have been
> included in this release.
>
> The Documentation is part of the JavaDoc API documentation. In particular,
> you should read the package description for the org.apache.commons.digester
> package for detailed information on using the package.
>
> The JavaDoc API documents are also available online.
I think this is a good suggestion, so I have made some minor changes to
the "index.xml" xdoc file. I don't have Maven installed, so rather than
commit the change without having tested it, here is a patch that I hope
some maven user can test & apply.
> I would suggest the following to prevent another one falling some traps
> I went through and wasted 4 hours of my life. Well not wasted entirely
> but it wasn't that productive also.
>
> a) refactor the The JavaDoc API documentation is available... and
> split it up and mention the documentation being part of the api in
> first place.
Sorry, I don't understand this. Refactor what and how? Split what up?
>
> b) alter the package documentation to reflect whats happening when
> it comes to self containment. (tag contains itself as child, the information
> was lagging).
Can you provide a patch to the existing package.html file which includes
the information you want? I will proof-read it for you.
Thanks for your comments.
Regards,
Simon
Re: [Digester 1.5] Pattern matching screwed me up
Posted by Martin Kersten <Ma...@Student.Uni-Magdeburg.DE>.
> > After going through it again, the JavaDoc API documents are
> > available online statement, mention to read the package description.
Maybe
> > this should be said top level. The documentation is hidden within the
API
> > documentation. You know I just glaced over it and saw the api
> > documentation is online. The second line didn't seam to be important at
> > first...
> >
>
> In the home page for Digester:
>
> http://jakarta.apache.org/commons/digester/
>
> the second section of the overview is entitled "Documentation". And the
second
> paragraph there states:
>
> The JavaDoc API Documents are available online. In particular,
> you should read the package description for the
> org.apache.commons.digester package for detailed information
> on using the package.
>
> I'm not sure how we can say it any more "top level" than that, but would
> certainly be interested in any ideas there. (A similar comment is made on
the
> first page of the JavaDocs themselves.)
The problem is, that I wasn't that used to common libraries before I
got interessted in digester. I am also only using JavaDoc as part of the
source
and not as a part of the user guide. I was never used to see JavaDoc as a
user
guide but after I 've read all tutorials twice I remembered the JavaDocs and
looked for 'em since I was debugging digester and wanted to understand how
everything works. Thats when I found the 'documentation'.
How about changing:
[snip]
The Release Notes document the new features and bug fixes that have been
included in this release.
The JavaDoc API documents are available online. In particular, you should
read the package description for the org.apache.commons.digester package
for detailed information on using the package.
[snap]
to:
The Release Notes document the new features and bug fixes that have been
included in this release.
The Documentation is part of the JavaDoc API documentation. In particular,
you should read the package description for the org.apache.commons.digester
package for detailed information on using the package.
The JavaDoc API documents are also available online.
I think this would be more intuitve to the user. I am trained to read fast.
Therefore I apply to some fast reading technics. I'll show you what happens
when I read the documentation:
First paragraph:
... Release NOTES DOCUMENT ... blah blah. (found document but interessted)
... javadoc API DOCUMENT are available ONLINE. In particular, you should
read the PackagE description for the org.apache.commons.DigesteR PackagE
for detailed information on UsinG the PackagE.
Thats how I see this. I was looking for something that helps me. Therefore I
use
to read for document. The words starting and ending with a upper letter are
also
interessted. If a interessting word is recognized I start thinking what the
sentence
is meaning (everything is automated but thats how it works). And you see
the second part is quiently marked as not important because I did not
expected
some usefull informations.
But the refactored part above have everything what is needed to get me
attracted
to the required informations.
So I would like to see it changed. I am not the only one reading that way
:-).
> On the general topic of including user guide documentation in the
JavaDocs,
> you'll find this to be quite common in the various Commons packages. The
> reasoning is that these packages are, after all, class libraries to be
used by
> developers, and those developers are going to need the JavaDocs in order
to
> understand the valid method signatures and so on, no matter what.
I am using Eclipse. I am trained to see class documentations as tooltips so
I've
looked for the java doc of the methods and not of the entire package. I
didn't
found qlues about the pattern usage.
> I've seen cases where class libraries were documented separately, and the
user
> guide was never read because developers tended to think a "user guide" is
for
> the user of their own application, not for the library they are trying to
use,
> and wouldn't read it. This way, all the information that a developer
needs is
> accessible in one place.
That spare documentation and developing documentation seperately is an issus
I understand. To be honest we are doing it the same way here. JavaDoc is
used to support developers. After the iteration comes to an end, the JavaDoc
is reworked (cleaned up mostly through method splits and extractions) and
after being reworked, the public methods of public classes are described
in more detail.
But after every iteration a user guide is also updated.
>
> A separate benefit is that the user guide can contain direct links to the
> detailed JavaDocs for the classes it talks about, because the directory
> structure for where package.html files go is well defined.
> Trying to do this with separated user guides leads to much more fragile
> links, in my experience.
>
> Thanks for your offer to help!
No problem.
I would suggest the following to prevent another one falling some traps
I went through and wasted 4 hours of my life. Well not wasted entirely
but it wasn't that productive also.
a) refactor the The JavaDoc API documentation is available... and
split it up and mention the documentation being part of the api in
first place.
b) alter the package documentation to reflect whats happening when
it comes to self containment. (tag contains itself as child, the information
was lagging).
I think this would had suited me and doesn't break any of your
documentation requiries.
Thanks for providing digester! Saved me some hours of work and is a
great thing to have in your toolkit!
Thanks,
Martin (Kersten)
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [Digester 1.5] Pattern matching screwed me up
Posted by "Craig R. McClanahan" <cr...@apache.org>.
Quoting Martin Kersten <Ma...@Student.Uni-Magdeburg.DE>:
> After going through it again, the JavaDoc API documents are
> available online statement, mention to read the package description. Maybe
> this should be said top level. The documentation is hidden within the API
> documentation. You know I just glaced over it and saw the api
> documentation is online. The second line didn't seam to be important at
> first...
>
In the home page for Digester:
http://jakarta.apache.org/commons/digester/
the second section of the overview is entitled "Documentation". And the second
paragraph there states:
The JavaDoc API Documents are available online. In particular,
you should read the package description for the
org.apache.commons.digester package for detailed information
on using the package.
I'm not sure how we can say it any more "top level" than that, but would
certainly be interested in any ideas there. (A similar comment is made on the
first page of the JavaDocs themselves.)
On the general topic of including user guide documentation in the JavaDocs,
you'll find this to be quite common in the various Commons packages. The
reasoning is that these packages are, after all, class libraries to be used by
developers, and those developers are going to need the JavaDocs in order to
understand the valid method signatures and so on, no matter what. Too often,
I've seen cases where class libraries were documented separately, and the user
guide was never read because developers tended to think a "user guide" is for
the user of their own application, not for the library they are trying to use,
and wouldn't read it. This way, all the information that a developer needs is
accessible in one place.
A separate benefit is that the user guide can contain direct links to the
detailed JavaDocs for the classes it talks about, because the directory
structure for where package.html files go is well defined. Trying to do this
with separated user guides leads to much more fragile links, in my experience.
Thanks for your offer to help!
Craig McClanahan
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [Digester 1.5] Pattern matching screwed me up
Posted by Martin Kersten <Ma...@Student.Uni-Magdeburg.DE>.
Hi Simon,
[...]
> > Here is what I would like to do:
> >
> > 1. Write a getting-started.html put into the docs directory telling
people
> > where
> > to look for the 'orginal' documentation (link to the package
description).
> > 2. Write a tutorial teaching the pattern matching and xml-parts mapping.
[...]
> > I guess it would take me additional 4 hours. But I would likely to
> > contribute that
> > peaces. But again, I need a person who's playing the English teacher.
[...]
> > Thanks for the help, it seams to work now and I am going to alter my
test
> > cases
> > to avoid top-level attributes containing itself and adding an interface
for
> > adding
> > (cause this function is called within two tags).
>
> I'm glad your code is now working.
Me too. The documentation just needs some adds to avoid this.
>
> And I think it's great that you are really willing to help with
> documentation. I didn't mean to imply that Digester's documentation was
> perfect - we all know it's not. But there's a line between helpfully
> pointing out an issue and complaining/criticising. Of course those who
> are willing to actually *do* something get forgiven a lot :-)
Well I just said that the documentation is bad :) Which is a statement,
I would still sign. Maybe I shouldn't had said bad, just incomplete and
for a 'jakarta-doing-everything-within-packages.hml' newbie it was hard
to find it.
After going through it again, the JavaDoc API documents are
available online statement, mention to read the package description. Maybe
this should be said top level. The documentation is hidden within the API
documentation. You know I just glaced over it and saw the api
documentation is online. The second line didn't seam to be important at
first...
I would like to see a note about the composing of the documentation. Like
the documentation is part of the api documentation (link to it). That would
have saved me one hour :). I am really not used to this kind of
documentation
style.
>
> First thing to check is whether .html form is the correct format for new
> docs. I know that at least some docs at Apache are in something called
> "xdoc". I'm not sure exactly what xdoc is, though.
>
> Then there's the issues of deciding where to put the docs, and how to
> link to them from the project site. That probably involves some Maven
> configuration. If you can find a commons project which has documentation
> along the lines you are suggesting, and can investigate how they write &
> deploy it, that would be good too.
Oh gosh I would like to add content but not to learn Maven, xdoc and stuff.
That would really be a pain :(
Is someone else able to do contribute documentations?
>
> If you can do that, and produce some intros/tutorials, I would be
> willing to do some proof-reading if you wish.
Thanks!
> I'm currently (and concurrently) learning Websphere, Debian, Linux
> network security, nagios, LVM, LDAP and subversion, so my poor brain
> isn't up to learning xdoc or Maven at the moment.
Same here. I am doing Eclipse plugin programming for my final exams work
and would also avoid learning xdoc and maven. There should be some
people available being able to contribute a tutorial and correct the
documentation notation;)
>
> I think a few people are in this same situation, which is why writing a
> package.html file (which is standard html/javadoc) is so much easier
> than writing external documentation like you are proposing.
Why they don't change the way you must work to contribute
documentation?
>
> You'll find quite a lot of documentation written as package javadoc, so
> it's a good habit to check for it when learning a new library.
Yeah thats the lesson I've learned. But a (more prominent) note on the main
page would have saved me from learning it the hard way.
>
> Oh - and if you want to see a really badly documented library, I suggest
> looking at IBM WebsphereMQ Cluster Workload Exits. And they get *paid*
> to write that stuff :-(
Don't tell me about bad documentations! :-) I had to analyse lots of source
code for my final exam. There wasn't even much java doc available. And
the man who wrote the source seams to be hugged to the 'as long the
method as good it is' style. There where classes spanning over 1000 lines.
But the code is also three years old.
Thanks,
Martin (Kersten)
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [Digester 1.5] Pattern matching screwed me up
Posted by Simon Kitching <si...@ecnetwork.co.nz>.
On Sun, 2004-02-29 at 21:16, Martin Kersten wrote:
> > And when you're done, feel free to write a user manual and submit it for
> > inclusion into the project...
> My english isn't that good. But I can provide some concepts and if someone
> would like to play an English teacher and correct my bumpy english, I am
> sure
> we can improve the situation about the first contact on digester.
>
> Here is what I would like to do:
>
> 1. Write a getting-started.html put into the docs directory telling people
> where
> to look for the 'orginal' documentation (link to the package description).
> 2. Write a tutorial teaching the pattern matching and xml-parts mapping.
>
> I guess it would take me additional 4 hours. But I would likely to
> contribute that
> peaces. But again, I need a person who's playing the English teacher.
>
> Bye the way,
>
> Thanks for the help, it seams to work now and I am going to alter my test
> cases
> to avoid top-level attributes containing itself and adding an interface for
> adding
> (cause this function is called within two tags).
I'm glad your code is now working.
And I think it's great that you are really willing to help with
documentation. I didn't mean to imply that Digester's documentation was
perfect - we all know it's not. But there's a line between helpfully
pointing out an issue and complaining/criticising. Of course those who
are willing to actually *do* something get forgiven a lot :-)
First thing to check is whether .html form is the correct format for new
docs. I know that at least some docs at Apache are in something called
"xdoc". I'm not sure exactly what xdoc is, though.
Then there's the issues of deciding where to put the docs, and how to
link to them from the project site. That probably involves some Maven
configuration. If you can find a commons project which has documentation
along the lines you are suggesting, and can investigate how they write &
deploy it, that would be good too.
If you can do that, and produce some intros/tutorials, I would be
willing to do some proof-reading if you wish.
I'm currently (and concurrently) learning Websphere, Debian, Linux
network security, nagios, LVM, LDAP and subversion, so my poor brain
isn't up to learning xdoc or Maven at the moment.
I think a few people are in this same situation, which is why writing a
package.html file (which is standard html/javadoc) is so much easier
than writing external documentation like you are proposing.
You'll find quite a lot of documentation written as package javadoc, so
it's a good habit to check for it when learning a new library.
Oh - and if you want to see a really badly documented library, I suggest
looking at IBM WebsphereMQ Cluster Workload Exits. And they get *paid*
to write that stuff :-(
Regards,
Simon
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [Digester 1.5] Pattern matching screwed me up
Posted by Martin Kersten <Ma...@Student.Uni-Magdeburg.DE>.
Hi Simon,
> > after I've tried for hours to get my simple XML shema working
> > (due to bad documentation if you ask me). I nearly give up.
>
> Ummm .. you aren't likely to win many friends on this list with comments
> like that. You're asking for help, yet criticising the *volunteers* who
> wrote the software for not putting enough of their *unpaid* time into
> the project?
>
> I'm not sure why I'm answering this at all...
Well I fooled around with digester for about four hours ( also taking some
breaks to meditate to not get angry and reestablish selfcontrol).
Imagen looking around the internet and being not able to solve this problem.
The documentation is not that big problem. It was simple not accessible the
way I am used to. There wasn't even an getting started or basic tutorial
to go on. (ok ok some at ibm and stuff but it didn't covered the issus I am
tried to solve).
So bad means, it was not obvious where to look at, where to find a tutorial
which explains some details about the pattern. But after some wondering,
where the offical documentation is, I guessed there may be informations
hidden in the api documentation (easy but unusal guess, but there wasn't
any more then the api doc (no getting started guide nothing)). The
documentation is just not accessable at first glance. And it was of cause
lagging the informations I would have needed.
[...]
> > Crazy. It seams I've missed an important information. Can someone
> > shade some light? I dont want to blaim digester but I am trying
> > for hours. I wanted to save time but who could know that
> > digester hates tags containing itself. (anyone like trees?).
> > I can not imagen that simple trees are beyond the caps of digester.
> > So I am thinking the fault is just on my side.
> >
> > So please, tell me what am I doing wrong?!
>
> > PS: Tried for more then four hours fooling around with test cases,
looking
> > for the internet and debugging the digester api. I am just a little,
well lets
> > call it disapointed... .
>
>
> You want the following behaviour:
> * For an "a" element at the top level, create an object but don't try to
> add it to a parent object.
> * For "a" elements elsewhere, create an object and add it to a parent
> object.
> * For "b" elements elsewhere, create an object and add it to a parent
> object.
>
> So I think this should do:
> digester.addObjectCreate("a",A.class);
> digester.addObjectCreate("*/a",A.class);
> digester.addSetNext("*/a","add");
> digester.addObjectCreate("*/b",B.class);
> digester.addSetNext("*/b","addB");
>
> Note that because pattern "a" overrides pattern "*/a", digester doesn't
> (wrongly) try to call "add" for the top-level "a" element.
Yeah thats what I have needed. I didn't thought about using "addXX" on
A and B. (the orginal problem). Now I have to alter my test cases to avoid
setProperties for the pattern */a and a. I think I can handle that.
> And when you're done, feel free to write a user manual and submit it for
> inclusion into the project...
My english isn't that good. But I can provide some concepts and if someone
would like to play an English teacher and correct my bumpy english, I am
sure
we can improve the situation about the first contact on digester.
Here is what I would like to do:
1. Write a getting-started.html put into the docs directory telling people
where
to look for the 'orginal' documentation (link to the package description).
2. Write a tutorial teaching the pattern matching and xml-parts mapping.
I guess it would take me additional 4 hours. But I would likely to
contribute that
peaces. But again, I need a person who's playing the English teacher.
Bye the way,
Thanks for the help, it seams to work now and I am going to alter my test
cases
to avoid top-level attributes containing itself and adding an interface for
adding
(cause this function is called within two tags).
Thanks,
Martin (Kersten)
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [Digester 1.5] Pattern matching screwed me up
Posted by Martin Kersten <Ma...@Student.Uni-Magdeburg.DE>.
Hi Tim,
> >>Hi maillist,
> >>
> >> after I've tried for hours to get my simple XML shema working
> >>(due to bad documentation if you ask me). I nearly give up.
> >
> >
> > Ummm .. you aren't likely to win many friends on this list with comments
> > like that. You're asking for help, yet criticising the *volunteers* who
> > wrote the software for not putting enough of their *unpaid* time into
> > the project?
> >
> > I'm not sure why I'm answering this at all...
>
> Bah! Simon, we shouldn't be punishing people for pointing out obvious
> flaws. Documentation sucks all around Jakarta. Every single one of us
> could do a better job at that. Telling people we can't produce quality
> because we are unpaid "volunteers" is just ninny.
>
>
> Martin, you identification of porr document is on the mark, but if you
> really want a gold star - take a minute to submit a patch for that
> doumentation. Please? Don't you want to become one of us, an unpaid
> volunteer?
Sure, I posted an offer about, all I need are additional informations and a
person playing the English teacher (due my bad english hurts ;). I would
like
to contribute an extensed tutorial and a simple getting-started guide. But
again
I am needing a sidekick I can ask informations directly and also an English
teacher :).
I am trying to specialize in software documentation during my studies
(started
last semester here and I am writing my final exam). So I would like
to use the chance to contribute something in english. Damn I have to look
for a permanent ghost writer :)
So here is the deal:
I will contribute half of the hours I am saving using digester within the
first year
(I guess I will save 5hours in the current and additional 20 hours within a
second
one (likely to become my Ph.D work)). So at least 25h - 4h for fooling
around
makes 10.5h to contribute :). Well just joking but I will likely to
contribute 10h
for sure. So if someone gets me a hand I will start right out of the box.
By the way,
Thanks for digester. It feels better now I got the infos I 've needed :)
Martin (Kersten)
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [Digester 1.5] Pattern matching screwed me up
Posted by Tim O'Brien <to...@discursive.com>.
Simon Kitching wrote:
> On Sun, 2004-02-29 at 13:11, Martin Kersten wrote:
>
>>Hi maillist,
>>
>> after I've tried for hours to get my simple XML shema working
>>(due to bad documentation if you ask me). I nearly give up.
>
>
> Ummm .. you aren't likely to win many friends on this list with comments
> like that. You're asking for help, yet criticising the *volunteers* who
> wrote the software for not putting enough of their *unpaid* time into
> the project?
>
> I'm not sure why I'm answering this at all...
Bah! Simon, we shouldn't be punishing people for pointing out obvious
flaws. Documentation sucks all around Jakarta. Every single one of us
could do a better job at that. Telling people we can't produce quality
because we are unpaid "volunteers" is just ninny.
Martin, you identification of porr document is on the mark, but if you
really want a gold star - take a minute to submit a patch for that
doumentation. Please? Don't you want to become one of us, an unpaid
volunteer?
Tim
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [Digester 1.5] Pattern matching screwed me up
Posted by Simon Kitching <si...@ecnetwork.co.nz>.
On Sun, 2004-02-29 at 13:11, Martin Kersten wrote:
> Hi maillist,
>
> after I've tried for hours to get my simple XML shema working
> (due to bad documentation if you ask me). I nearly give up.
Ummm .. you aren't likely to win many friends on this list with comments
like that. You're asking for help, yet criticising the *volunteers* who
wrote the software for not putting enough of their *unpaid* time into
the project?
I'm not sure why I'm answering this at all...
>
> My problem? Well I want to use selfcontainment. Given you
> an example:
>
> <a><a>
> <b></b>
> </a></a>
>
> So whats the problem?
>
> First of all this wont work:
>
> digester.addObjectCreate("a",A.class);
> digester.addObjectCreate("b",B.class);
> digester.addSetNext("a/a","add");
> digester.addSetNext("a/b","addB");
>
> Why does this wont work? Well took me an hour
> to figure it out (thanks for the hidden java doc documentation
> -why not pointing it out in a seperate documentation file? Like
> everyone does?)
>
> Ok here you go, just add an */ to match everything...
>
> digester.addObjectCreate("*/a",A.class);
> digester.addObjectCreate("*/b",B.class);
> digester.addSetNext("*/a/a","add");
> digester.addSetNext("*/a/b","addB");
>
> Looks right, doesn't it? Well not for digester, it seams! Since
> */a/a is a closer pattern match it seams, adding it is just more
> important then creating the object first (who cares null pointer?!).
>
> Ok therefore lets add a hack:
>
> digester.addObjectCreate("*/a",A.class);
> digester.addObjectCreate("*/b",B.class);
>
> digester.addObjectCreate("*/a/a",A.class);
> digester.addObjectCreate("*/b/a",B.class);
> digester.addSetNext("*/a/a","add");
> digester.addSetNext("*/a/b","addB");
>
> Works! But halt, bad karma... . If you have something
> like setProperties("*/a","id","id"); You can collapse right
> now. Since */a is not as exact as */a/a it would not be called
> right out of the box (setNext will be called first). So what to do?
> Adding another setProperties("*/a/a","id","id")?
>
> Would fix it!
>
> Crazy. It seams I've missed an important information. Can someone
> shade some light? I dont want to blaim digester but I am trying
> for hours. I wanted to save time but who could know that
> digester hates tags containing itself. (anyone like trees?).
> I can not imagen that simple trees are beyond the caps of digester.
> So I am thinking the fault is just on my side.
>
> So please, tell me what am I doing wrong?!
> PS: Tried for more then four hours fooling around with test cases, looking
> for the internet and debugging the digester api. I am just a little, well lets
> call it disapointed... .
You want the following behaviour:
* For an "a" element at the top level, create an object but don't try to
add it to a parent object.
* For "a" elements elsewhere, create an object and add it to a parent
object.
* For "b" elements elsewhere, create an object and add it to a parent
object.
So I think this should do:
digester.addObjectCreate("a",A.class);
digester.addObjectCreate("*/a",A.class);
digester.addSetNext("*/a","add");
digester.addObjectCreate("*/b",B.class);
digester.addSetNext("*/b","addB");
Note that because pattern "a" overrides pattern "*/a", digester doesn't
(wrongly) try to call "add" for the top-level "a" element.
And when you're done, feel free to write a user manual and submit it for
inclusion into the project...
[of course the code above is not tested....]
Regards,
Simon
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org