Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - XML element structure Q. [Thread Next] Re: XML element structure Q.To: NULL Date: 2/1/2009 9:22:00 PM Jules wrote:
> I was just reading the w3cschools pages on XML (it's been years since I've
> actively used XML for anything) and it claims that elements can contain a
> mixture of other elements and simple text.
Yes, this is normal, just like HTML does. I'm slightly puzzled by the
"claim" aspect, though. While you're right to be suspicious of the
w3cschools documents, does something like
<para>The <productname>Splosh</productname> parser is definitely
the <emphasis>best</emphasis> product.</para>
describe what you mean?
> Fair enough - but from a parser point of view, what's the correct
> behaviour if multiple blocks of text are found amongst multiple "sub
> elements"?
A parser would normally report the components separately. If you run
onsgmls -wxml on the example above, you get:
(PARA
-The
(PRODUCTNAME
-Splosh
)PRODUCTNAME
- parser is definitely\n the
(EMPHASIS
-best
)EMPHASIS
- product.
)PARA
"(" means start-tag, ")" means end-tag, and "-" means character data
(text). \n is the embedded linebreak.
> Should the parser somehow concatenate the blocks and present a single
> text string at the API layer?
Only if requested, as Martin has described.
///Peter
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
