[jdom-interest] Problem with mixed content
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)>
> text <b>bold text</b> text
> So now root element did not have mixed content and child element has it.
> But when I try this:
> Element root = doc.getRootElement();
> Element elem = root.getChild("child");
> 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 ;-)
> Vyacheslav Pedak
> To control your jdom-interest membership:
Brett McLaughlin, Enhydra Strategist
Lutris Technologies, Inc.
1200 Pacific Avenue, Suite 300
Santa Cruz, CA 95060 USA
More information about the jdom-interest