Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JDOM User »

Re: [jdom-interest] Problems with Mixed Content and XMLOutputter

frode

2007-07-26

Replies:



Hi.

If the textual content of the tag 'Content' is to be treated as text, it should either be escaped, or inserted as CDATA.
Then all spaces/tags within is kept as is.

How can You otherwise extract this HTML-part from a DOM-tree, if not as the Elementtext of 'Content' ?

Frode







                                                                               
        Paul Libbrecht                                                              
        <paul@(protected)>                                                        
        Sent by:                                                                To
        jdom-interest-bounces@(protected)>                    
                                                                             cc
                                     jdom-interest@(protected)                          
        26.07.2007 14:57                                                       Subject
                                     Re: [jdom-interest] Problems with Mixed Content and        
                                     XMLOutputter                                  
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               




Markus,

my solution was rely on the faithful formatting... does your solution avoid this ?
whitespaces in xml are tricky as hell!
You might want to post your patch or class... we would be interested to test this!

paul


Le 26 juil. 07 à 13:29, Grimm, Markus a écrit :



   Hi,





   We handle with XML-Documents including elements with mixed-content.





   an easy example:


   =============


   …


   <text>


               <Content><P>Hello <B>World</B> how are you?</P></Content>


   </text>


   …





   I have to use Compact-Format to output the document as string. Later this output is used to create a html-view of
   the content.


   But the outputter-result looks like:  <Content><P>Hello<B>World</B>how are you?</P></Content>


   The space befor <B>World and after World</B> is deleted.


   The reason is simple, if you look in the XMLOutputter. But I think it’s a fault?!


   In Mixed-Content perhaps I need a single space at those positions. In such cases of mixed-content they should be
   handled as spaces in a string.


   They shouldn’t be trimed.





   So,  I had to pimp the XMLOutputter for my needs. Now he knows what kind of node a) follows to a text-node or b)
   follows to an Element.


   When it’s a) an Element, the text-node isn’t right-trimed and it’s b) a text-node so the same text-node isn’t
   left-trimmed. So far so good.





   What do the developers think about a own solution in the jdom-package for this problem?





   Bye,


   Markus









   _______________________________________________
   To control your jdom-interest membership:
   http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
(See attached file: smime.p7s)_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)

Attachment: smime.p7s
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
©2008 junlu.com - Jax Systems, LLC, U.S.A.