[jdom-interest] Problem with mixed content

Brett McLaughlin brett.mclaughlin at lutris.com
Wed Sep 13 08:41:47 PDT 2000


Vyacheslav Pedak wrote:
> 
> Brett McLaughlin <brett.mclaughlin at lutris.com> wrote:
> 
> > > I have simple xml like this:
> > > <?xml version="1.0" encoding="ISO-8859-1"?>
> > > <test>
> > >   <element>
> > >     text
> > >   </element>
> > > </test>
> > >
> > > and when I do
> > >
> > >         Document doc = builder.build(new File(filename));
> > >         Element root = doc.getRootElement();
> > >         System.out.println("hasMixedContent="+root.hasMixedContent());
> > >
> > > I receive true, but there no mixed content in this xml.
> >
> > Yes it does. The root element has both character data (white space) and
> > elements. It would only have no mixed content if a DTD was present, and
> > specified that the element "test" could only have nested elements. JDOM
> > is doing exactly the right thing.
> >
> 
> Thank you and Jason Hunter, now I understand my error.
> But when I try to solve it, I found another one.
> I rewrite my xml like this:
> 
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <!DOCTYPE test [
>   <!ELEMENT test (child) >
>   <!ELEMENT child (#PCDATA| b)* >
>   <!ELEMENT b (#PCDATA)>
> ]>
> <test>
>   <child>
>     text <b>bold text</b> text
>   </child>
> </test>
> 
> So now root element did not have mixed content and child element has it.
> But when I try this:
>         Element root = doc.getRootElement();
>         System.out.println("root.hasMixedContent="+root.hasMixedContent());
>         Element elem = root.getChild("child");
>         System.out.println("elem.hasMixedContent="+elem.hasMixedContent());
> 
> I received false in both cases.
> What wrong again?

Now you did hit a bug ;-) We have some weird problems with inline DTDs
that I need to work on. So don't worry - this is not your fault ;-)

-Brett

> 
> Vyacheslav Pedak
> 
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com

-- 
Brett McLaughlin, Enhydra Strategist
Lutris Technologies, Inc. 
1200 Pacific Avenue, Suite 300 
Santa Cruz, CA 95060 USA 
http://www.lutris.com
http://www.enhydra.org



More information about the jdom-interest mailing list