Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: XML element structure Q.

From: Peter Flynn <peter.nosp@-.--------.-->
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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent