You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Arto Pastinen <ar...@ofw.fi> on 2005/11/01 11:39:37 UTC
[digester]
Hi!
I need little help with commons digester, anyone?!?
I have bean:
public void Test {
private String html;
// getter&setter
}
and XML:
<test>
<html>
<p>
blaablaa
</p>
</html>
</test>
How can i set html to bean so, that Test.html contains also <p> tags?
Thanks, Artsi
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [digester]
Posted by Arto Pastinen <ar...@ofw.fi>.
Nice.. :)
Thanks Craig!
ke, 2005-11-02 kello 08:13 -0800, Craig McClanahan kirjoitti:
> On 11/2/05, Simon Kitching <sk...@apache.org> wrote:
> >
> > On Wed, 2005-11-02 at 10:37 +0200, Arto Pastinen wrote:
> > > Hi!
> > >
> > > Yes i know the problem, i think that it was bug in ATOM 0.3
> > > specification, i havent find DTD or Schema for it, and my test data is
> > > taken from specification text, and there is no CDATA for content, but i
> > > think there should be..
> > > I dont know about latest ATOM specification, but that doesnt matter
> > > because i must use 0.3..
> > >
> > > I think that i will use digester for other elements, and i will take
> > > this content out from XML with some cool REGEXP.
> >
> > Ok. Good luck.
> >
> > You might want to look at NekoHtml; it takes HTML input and turns it
> > into XHTML.
>
>
> For reading well-formed XML, Digester actually does have a rule that might
> help ... check out NodeCreateRule. When it hits a match, it pushes an
> org.w3c.dom.Element onto the stack, containing all the nested content of the
> matched element. Then, you can use the usual DOM APIs to parse your way
> around this content.
>
> Cheers,
> >
> > Simon
>
>
> Craig
>
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-user-help@jakarta.apache.org
> >
> >
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [digester]
Posted by Craig McClanahan <cr...@apache.org>.
On 11/2/05, Simon Kitching <sk...@apache.org> wrote:
>
> On Wed, 2005-11-02 at 10:37 +0200, Arto Pastinen wrote:
> > Hi!
> >
> > Yes i know the problem, i think that it was bug in ATOM 0.3
> > specification, i havent find DTD or Schema for it, and my test data is
> > taken from specification text, and there is no CDATA for content, but i
> > think there should be..
> > I dont know about latest ATOM specification, but that doesnt matter
> > because i must use 0.3..
> >
> > I think that i will use digester for other elements, and i will take
> > this content out from XML with some cool REGEXP.
>
> Ok. Good luck.
>
> You might want to look at NekoHtml; it takes HTML input and turns it
> into XHTML.
For reading well-formed XML, Digester actually does have a rule that might
help ... check out NodeCreateRule. When it hits a match, it pushes an
org.w3c.dom.Element onto the stack, containing all the nested content of the
matched element. Then, you can use the usual DOM APIs to parse your way
around this content.
Cheers,
>
> Simon
Craig
---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
RE: [digester]
Posted by Simon Kitching <sk...@apache.org>.
On Wed, 2005-11-02 at 10:37 +0200, Arto Pastinen wrote:
> Hi!
>
> Yes i know the problem, i think that it was bug in ATOM 0.3
> specification, i havent find DTD or Schema for it, and my test data is
> taken from specification text, and there is no CDATA for content, but i
> think there should be..
> I dont know about latest ATOM specification, but that doesnt matter
> because i must use 0.3..
>
> I think that i will use digester for other elements, and i will take
> this content out from XML with some cool REGEXP.
Ok. Good luck.
You might want to look at NekoHtml; it takes HTML input and turns it
into XHTML.
Cheers,
Simon
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
RE: [digester]
Posted by Arto Pastinen <ar...@ofw.fi>.
Hi!
Yes i know the problem, i think that it was bug in ATOM 0.3
specification, i havent find DTD or Schema for it, and my test data is
taken from specification text, and there is no CDATA for content, but i
think there should be..
I dont know about latest ATOM specification, but that doesnt matter
because i must use 0.3..
I think that i will use digester for other elements, and i will take
this content out from XML with some cool REGEXP.
Sorry about subject, i was bad boy..
- Artsi
ke, 2005-11-02 kello 21:10 +1300, Simon Kitching kirjoitti:
> On Tue, 2005-11-01 at 13:05 +0200, Arto Pastinen wrote:
> > I write that Test bean only for this mail for example.
> > Actually i am implementing ATOM 0.3, and there is this atom:content tag:
> > <atom:entry>
> > <atom:content>
> > xxxxxxxxxxxxx
> > </atom:content>
> > </atom:entry>
> > .. and it can contain all kind characters, and also some HTML.
>
> Well, first of all if the input isn't well-formed XML then digester
> simply will not handle it *at all*. Digester is just a thin layer on top
> of any old JAXP-compliant xml parser. And all xml parsers will stop as
> soon as they find that their input isn't well-formed xml.
>
> Perhaps you meant the atom:content contains XHTML?
>
> Or perhaps it contains CDATA like this?
> <atom:content><![CDATA[
> any old html
> ]]>
> </atom:content>
>
> If the input is XHTML, then you might want to look at the
> NodeCreateRule, which will simply build a DOM node representing the part
> of the tree you don't want parsed by digester. You can then pass this
> DOM node to any method you like on your Content object by using
> SetNextRule.
>
> If the input is in a CDATA section then it's just plain text and is
> handled exactly like
> <atom:content>hello, world</atom:content>
> and the "body content" can be passed to any method you like on your
> Content object by using CallMethodRule + CallParamRule.
>
> By the way, please try to use meaningful subject lines when posting to
> email lists. These help people determine which emails should get their
> attention (ones without meaningful subjects tend to get very low
> priority). It also helps people search/browse the email archives.
>
> Regards,
>
> Simon
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
RE: [digester]
Posted by Simon Kitching <sk...@apache.org>.
On Tue, 2005-11-01 at 13:05 +0200, Arto Pastinen wrote:
> I write that Test bean only for this mail for example.
> Actually i am implementing ATOM 0.3, and there is this atom:content tag:
> <atom:entry>
> <atom:content>
> xxxxxxxxxxxxx
> </atom:content>
> </atom:entry>
> .. and it can contain all kind characters, and also some HTML.
Well, first of all if the input isn't well-formed XML then digester
simply will not handle it *at all*. Digester is just a thin layer on top
of any old JAXP-compliant xml parser. And all xml parsers will stop as
soon as they find that their input isn't well-formed xml.
Perhaps you meant the atom:content contains XHTML?
Or perhaps it contains CDATA like this?
<atom:content><![CDATA[
any old html
]]>
</atom:content>
If the input is XHTML, then you might want to look at the
NodeCreateRule, which will simply build a DOM node representing the part
of the tree you don't want parsed by digester. You can then pass this
DOM node to any method you like on your Content object by using
SetNextRule.
If the input is in a CDATA section then it's just plain text and is
handled exactly like
<atom:content>hello, world</atom:content>
and the "body content" can be passed to any method you like on your
Content object by using CallMethodRule + CallParamRule.
By the way, please try to use meaningful subject lines when posting to
email lists. These help people determine which emails should get their
attention (ones without meaningful subjects tend to get very low
priority). It also helps people search/browse the email archives.
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]
Posted by Arto Pastinen <ar...@ofw.fi>.
I write that Test bean only for this mail for example.
Actually i am implementing ATOM 0.3, and there is this atom:content tag:
<atom:entry>
<atom:content>
xxxxxxxxxxxxx
</atom:content>
</atom:entry>
.. and it can contain all kind characters, and also some HTML.
The problem is that Digester seems to parse html also, but i dont want
to parse it, i want to attach it to my Content bean.
class Content {
private String text, type, lang, base;
// getter&setter
}
my current digester code:
digester.addObjectCreate("entry/content",Content.class);
digester.addSetProperties("entry/content","type","type");
digester.addSetProperties("entry/content","lang","lang");
digester.addSetProperties("entry/content","base","base");
digester.addBeanPropertySetter("entry/content","text"); // this line
doesnt work :(
- Artsi
ti, 2005-11-01 kello 10:54 +0000, Marco Mistroni kirjoitti:
> Hello,
> Sorry I read question too quickly..
>
> According to your XML, you should have a javabean for test, correct?
>
> As I said, one solution to get the <p> tag will be to create a javabean
> For the <html> tag, and on your HTMLBean create a property
>
> If I remember correctly, you can specify a property (let's say, propertyX)
> On your Bean that matches the <P> tag, since setP is little 'bad'
>
> Any reason of why you are using Digester with HTML?
>
> Regards
> marco
>
> -----Original Message-----
> From: Marco Mistroni [mailto:mmistroni@waersystems.com]
> Sent: 01 November 2005 10:50
> To: 'Jakarta Commons Users List'
> Subject: RE: [digester]
>
> Moi,
> You have to create a Bean for <HTML> like you did
> for test (that's one solution)
>
> kiitoksia
> marco
>
> -----Original Message-----
> From: Arto Pastinen [mailto:arto.pastinen@ofw.fi]
> Sent: 01 November 2005 10:40
> To: commons-user@jakarta.apache.org
> Subject: [digester]
>
> Hi!
>
> I need little help with commons digester, anyone?!?
>
> I have bean:
>
> public void Test {
> private String html;
> // getter&setter
> }
>
> and XML:
> <test>
> <html>
> <p>
> blaablaa
> </p>
> </html>
> </test>
>
> How can i set html to bean so, that Test.html contains also <p> tags?
>
> Thanks, Artsi
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
RE: [digester]
Posted by Marco Mistroni <mm...@waersystems.com>.
Hello,
Sorry I read question too quickly..
According to your XML, you should have a javabean for test, correct?
As I said, one solution to get the <p> tag will be to create a javabean
For the <html> tag, and on your HTMLBean create a property
If I remember correctly, you can specify a property (let's say, propertyX)
On your Bean that matches the <P> tag, since setP is little 'bad'
Any reason of why you are using Digester with HTML?
Regards
marco
-----Original Message-----
From: Marco Mistroni [mailto:mmistroni@waersystems.com]
Sent: 01 November 2005 10:50
To: 'Jakarta Commons Users List'
Subject: RE: [digester]
Moi,
You have to create a Bean for <HTML> like you did
for test (that's one solution)
kiitoksia
marco
-----Original Message-----
From: Arto Pastinen [mailto:arto.pastinen@ofw.fi]
Sent: 01 November 2005 10:40
To: commons-user@jakarta.apache.org
Subject: [digester]
Hi!
I need little help with commons digester, anyone?!?
I have bean:
public void Test {
private String html;
// getter&setter
}
and XML:
<test>
<html>
<p>
blaablaa
</p>
</html>
</test>
How can i set html to bean so, that Test.html contains also <p> tags?
Thanks, Artsi
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
RE: [digester]
Posted by Marco Mistroni <mm...@waersystems.com>.
Moi,
You have to create a Bean for <HTML> like you did
for test (that's one solution)
kiitoksia
marco
-----Original Message-----
From: Arto Pastinen [mailto:arto.pastinen@ofw.fi]
Sent: 01 November 2005 10:40
To: commons-user@jakarta.apache.org
Subject: [digester]
Hi!
I need little help with commons digester, anyone?!?
I have bean:
public void Test {
private String html;
// getter&setter
}
and XML:
<test>
<html>
<p>
blaablaa
</p>
</html>
</test>
How can i set html to bean so, that Test.html contains also <p> tags?
Thanks, Artsi
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org