nico_debeissat wrote:

> It is one of the reason I never saw a good use of text nodes. I saw a
> lot of times configuration files like web.xml :
> 
>  <servlet>
>    <servlet-name>YourServlet</servlet-name>
>    <servlet-class>YourServletClass</servlet-class>
>  </servlet>
> 
> It is always a problem : you have to trim the text, test if it is
> empty, it is a lot verbose... I think that when you expect a value in
> a XML file, it should always be inside an attribute.

I don't think that there is a big difference in storing value (just
single value, no mixed content) inside element or attribute. If you
don't care about whitespaces you have to trim value anyway in both
(except that attribute values are normalized, but in a way which is more
confusing then useful for many users). You can model non-existing value
by optional attribute/element.

> If that is a text content of a web page, an article, I understand
> that, but for the rest, I think the main problem of XML specifications
> in general is that they use too many text nodes.
> For tomcat configuration of users, it is better done :
> 
> <user name="admin" password="pwd" roles="admin"/>
> 
> Some of the XML expert people should publish a guide of good habits in
> order to specify XML, I did not find any when I was trying to make
> schemas.
> 
> What do you think about that ?

In general, elements are much more flexible -- you can attach metadata
to them, you can further extend them with subelements without breaking
existing code, its easier to internationalize their content (xml:lang,
its:dir), ...

Apart from less verbosity, attributes can be treated only as a legacy
from SGML days, especially if you use RELAX NG for modeling and you are
not forced to put some info into attributes in order to simplify content
model.

                        Jirka

-- 
------------------------------------------------------------------
  Jirka Kosek      e-mail: [email protected]      http://xmlguru.cz
------------------------------------------------------------------
       Professional XML consulting and training services
  DocBook customization, custom XSLT/XSL-FO document processing
------------------------------------------------------------------
 OASIS DocBook TC member, W3C Invited Expert, ISO JTC1/SC34 member
------------------------------------------------------------------

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to