You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Matthias Wessendorf <ma...@matthias-wessendorf.de> on 2005/01/12 14:03:16 UTC

[Digester] using (X)HTML in XML

Hi,

I run into a problem with digester,
when include (X)HTML in a XML file
that I want to read with Digester.

I've an XML and ne of those values contain
(X)HTML:
<root>
...
<texte>
 <text>Nice to see you!<br/>Please be sure...</text>
 ...
</texte>
...
</root>

Now I thought the String that is read by Digester
would be "Nice to see you!<br/>Please be sure..."

NO! it doesn't contain "<br/>"

like: "Nice to see you!Please be sure..."

Am I doing something wrong?



Best regards,
Matthias


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [Digester] using (X)HTML in XML

Posted by Craig McClanahan <cr...@gmail.com>.
On Wed, 12 Jan 2005 20:41:51 +0100, Matthias Wessendorf
<ma...@matthias-wessendorf.de> wrote:
> Wendy, Craig,
> 
> thanks for the responses.
> 
> Is't it posible to say
> "all what's inside of <text>, should be *copied*
> to property "value" of clazz "Text" ?
> 
> like a String "fooBar<br/>barFoo"
> 
> Or will I need to create own Rule clazzes?
> 

If you want that literal output, then you will indeed need to create
your own Rule instance.  Or, use NodeCreateRule and then write some
code to serialize the result as a string.  If you go the "write your
own" route, the code in NodeCreateRule might still serve as a good
starting point, because you are going to have to intercept all the SAX
events inside your matching area anyway.

Craig

> I need this, since I must configure output
> for a JSF web app. One of my BackingBeans
> contains a Vector with all "<text>"-"Objects".
> (each JSF pages got's a <text> value on Random...)
> 
> So I am not allowed to code it hard...
> (It is a *prototype* which will be compined
> with a custom layout engine that generates HTML, WML, ...)
> 
> However, any hint? I am turning OT ... :-)
> 
> > -----Original Message-----
> > Wrom: PQQWOYIYZUNNYCGPKYLEJGDGVCJVTLBXFGGMEPYOQKED
> > Sent: Wednesday, January 12, 2005 7:54 PM
> > To: Jakarta Commons Users List
> > Subject: Re: [Digester] using (X)HTML in XML
> >
> >
> > The issue is that you're wanting to read body text in
> > addition to elements and attributes, and Digester was never
> > really targeted for that use case.
> >
> > If you really want to do something like this, check out
> > NodeCreateRule, which will give you back a DOM structure
> > representing the nested content.  In your example, you'd get
> > back a <text> element with three children ... the leading
> > body content, the <br> element, and the trailing body content
> > ... but at least you'd be maintaining the structure.
> >
> > Craig
> >
> >
> >
> > On Wed, 12 Jan 2005 14:03:16 +0100, Matthias Wessendorf
> > <ma...@matthias-wessendorf.de> wrote:
> > > Hi,
> > >
> > > I run into a problem with digester,
> > > when include (X)HTML in a XML file
> > > that I want to read with Digester.
> > >
> > > I've an XML and ne of those values contain
> > > (X)HTML:
> > > <root>
> > > ...
> > > <texte>
> > >  <text>Nice to see you!<br/>Please be sure...</text>
> > >  ...
> > > </texte>
> > > ...
> > > </root>
> > >
> > > Now I thought the String that is read by Digester
> > > would be "Nice to see you!<br/>Please be sure..."
> > >
> > > NO! it doesn't contain "<br/>"
> > >
> > > like: "Nice to see you!Please be sure..."
> > >
> > > Am I doing something wrong?
> > >
> > > Best regards,
> > > Matthias
> > >
> > >
> > ---------------------------------------------------------------------
> > > 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] using (X)HTML in XML

Posted by Matthias Wessendorf <ma...@matthias-wessendorf.de>.
Wendy, Craig, 

thanks for the responses.

Is't it posible to say
"all what's inside of <text>, should be *copied*
to property "value" of clazz "Text" ?

like a String "fooBar<br/>barFoo"

Or will I need to create own Rule clazzes?

I need this, since I must configure output
for a JSF web app. One of my BackingBeans
contains a Vector with all "<text>"-"Objects".
(each JSF pages got's a <text> value on Random...)

So I am not allowed to code it hard...
(It is a *prototype* which will be compined
with a custom layout engine that generates HTML, WML, ...)

However, any hint? I am turning OT ... :-)

> -----Original Message-----
> From: Craig McClanahan [mailto:craigmcc@gmail.com] 
> Sent: Wednesday, January 12, 2005 7:54 PM
> To: Jakarta Commons Users List
> Subject: Re: [Digester] using (X)HTML in XML
> 
> 
> The issue is that you're wanting to read body text in 
> addition to elements and attributes, and Digester was never 
> really targeted for that use case.
> 
> If you really want to do something like this, check out 
> NodeCreateRule, which will give you back a DOM structure 
> representing the nested content.  In your example, you'd get 
> back a <text> element with three children ... the leading 
> body content, the <br> element, and the trailing body content 
> ... but at least you'd be maintaining the structure.
> 
> Craig
> 
> 
> 
> On Wed, 12 Jan 2005 14:03:16 +0100, Matthias Wessendorf 
> <ma...@matthias-wessendorf.de> wrote:
> > Hi,
> > 
> > I run into a problem with digester,
> > when include (X)HTML in a XML file
> > that I want to read with Digester.
> > 
> > I've an XML and ne of those values contain
> > (X)HTML:
> > <root>
> > ...
> > <texte>
> >  <text>Nice to see you!<br/>Please be sure...</text>
> >  ...
> > </texte>
> > ...
> > </root>
> > 
> > Now I thought the String that is read by Digester
> > would be "Nice to see you!<br/>Please be sure..."
> > 
> > NO! it doesn't contain "<br/>"
> > 
> > like: "Nice to see you!Please be sure..."
> > 
> > Am I doing something wrong?
> > 
> > Best regards,
> > Matthias
> > 
> > 
> ---------------------------------------------------------------------
> > 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] using (X)HTML in XML

Posted by Craig McClanahan <cr...@gmail.com>.
The issue is that you're wanting to read body text in addition to
elements and attributes, and Digester was never really targeted for
that use case.

If you really want to do something like this, check out
NodeCreateRule, which will give you back a DOM structure representing
the nested content.  In your example, you'd get back a <text> element
with three children ... the leading body content, the <br> element,
and the trailing body content ... but at least you'd be maintaining
the structure.

Craig



On Wed, 12 Jan 2005 14:03:16 +0100, Matthias Wessendorf
<ma...@matthias-wessendorf.de> wrote:
> Hi,
> 
> I run into a problem with digester,
> when include (X)HTML in a XML file
> that I want to read with Digester.
> 
> I've an XML and ne of those values contain
> (X)HTML:
> <root>
> ...
> <texte>
>  <text>Nice to see you!<br/>Please be sure...</text>
>  ...
> </texte>
> ...
> </root>
> 
> Now I thought the String that is read by Digester
> would be "Nice to see you!<br/>Please be sure..."
> 
> NO! it doesn't contain "<br/>"
> 
> like: "Nice to see you!Please be sure..."
> 
> Am I doing something wrong?
> 
> Best regards,
> Matthias
> 
> ---------------------------------------------------------------------
> 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] using (X)HTML in XML

Posted by Wendy Smoak <ja...@wendysmoak.com>.
From: "Matthias Wessendorf" <ma...@matthias-wessendorf.de>
> I've an XML and ne of those values contain
> (X)HTML:
>  <text>Nice to see you!<br/>Please be sure...</text>
> Now I thought the String that is read by Digester
> would be "Nice to see you!<br/>Please be sure..."
> NO! it doesn't contain "<br/>"
> like: "Nice to see you!Please be sure..."

Based on my very limited Digester experience, I'm relatively sure that if
you look at the log output, you'll see Digester "finding" that <br/> tag
and, not finding any rules that say it's supposed to do something, ignoring
it.  I think you will have to encode the characters if you want Digester to
pass them through: < as &lt; for example.

-- 
Wendy Smoak


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org