Tags v.s. Attributes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • gaijinco

    Tags v.s. Attributes

    I'm fairly new to using XML and I tend to be quite verbose when
    writting files.

    Is there any disadvantage of writting:

    <person>
    <name first="Carlos" second="" />
    <lastname first="Obregon" second="Jimenez " />
    <id type="CC" number="7987938 9" />
    <birthday day="17" month="02" year="1979" />
    <member day="01" month="06" year="2007" />
    <adress id="Evegreen Cr. 1234" />
    <telephone number="555-123456" />
    <email user="me" domain="home.co m" />
    </person>

    Intead of:

    <person>
    <name>
    <first>Carlos </first>
    <second></second>
    </name>
    <lastname>
    <first>Obrego n</first>
    <second>Jimenez </second>
    </lastname>
    <id>
    <type>CC</type>
    <number>7987938 9</number>
    </id>
    <birthday>
    <day>17</day>
    <month>02</month>
    <year>1979</year>
    </birthday>
    <member>
    <day>01</day>
    <month>06</month>
    <year>2008</year>
    </member>
    <adress>Evegree n Cr. 1234</adress>
    <telephone>55 5-123456</telephone>
    <email>
    <user>me</user>
    <domain>home.co m</domain>
    </email>
    </person>

    Thanks.
  • Mukul Gandhi

    #2
    Re: Tags v.s. Attributes

    I think this article should be good read,
    http://www.ibm.com/developerworks/xm.../x-eleatt.html ..

    Comment

    • Peter Flynn

      #3
      Re: Tags v.s. Attributes

      gaijinco wrote:
      I'm fairly new to using XML and I tend to be quite verbose when
      writting files.
      FAQ. See http://xml.silmaril.ie/developers/attributes/

      ///Peter

      Comment

      • Peter Flynn

        #4
        Re: Tags v.s. Attributes

        Stefan Ram wrote:
        Peter Flynn <peter.nosp@m.s ilmaril.iewrite s:
        >Again, not true. <rose owner="Jack Jill Stefan"/is the normal solution
        >to multiple parallel values, where owner is declared as IDREFS or ENTITIES.
        >
        Thank you, I was not aware of IDREFS or ENTITIES yet.
        So, there is limited support for parallel values in XML.
        >
        One might say for »parallel /references/« (to ids or entities).
        It seems as if it can not be used when the values are literals
        (not references) such as numerals (numbers), for example.
        That's correct. XML is based on SGML DTDs, and was aimed at the document
        publishing field. There are many things that users of rectangular data
        would like to see allowed, but for that you need another syntax.

        ///Peter

        Comment

        • David Carlisle

          #5
          Re: Tags v.s. Attributes

          Stefan Ram wrote:
          Peter Flynn <peter.nosp@m.s ilmaril.iewrite s:
          >Again, not true. <rose owner="Jack Jill Stefan"/is the normal solution
          >to multiple parallel values, where owner is declared as IDREFS or ENTITIES.
          >
          Thank you, I was not aware of IDREFS or ENTITIES yet.
          So, there is limited support for parallel values in XML.
          >
          One might say for »parallel /references/« (to ids or entities).
          It seems as if it can not be used when the values are literals
          (not references) such as numerals (numbers), for example.
          >
          That though is a restriction of DTD rather than of XML itself. Other XML
          validation languages such as XSD or Relax NG Schema, or schematron for
          exampes can all easily be used to constrain an attribute to be (for
          example) a white space separated list of integer values.

          David

          --

          Comment

          • David Carlisle

            #6
            Re: Tags v.s. Attributes

            Stefan Ram wrote:
            David Carlisle <david-news@dcarlisle. demon.co.ukwrit es:
            >That though is a restriction of DTD rather than of XML itself. Other XML
            >validation languages such as XSD or Relax NG Schema, or schematron for
            >exampes can all easily be used to constrain an attribute to be (for
            >example) a white space separated list of integer values.
            >
            You can also create a validation language that can be used to
            constrain an attribute to be a valid Java program.
            >
            However, the structure of such an attribute is not being
            described by the XML language anymore. The XML TR does not
            describe the Java syntax. So it is not provided by the XML TR.
            >
            The XML TR describes a document made of elements and possibly
            attributes. It provides rules and names for these structural parts.
            >
            XML provides rules and names for a list of IDREFs within an
            attribute, so this still »is« XML.
            >
            But the XML TR does not provide rules and syntactical names
            (nonterminal symbols) for a list of integer numerals (integer
            literals) within an attribut.
            >
            This is another language. It might be call »Relax-XML« or so.
            >
            Such a valid Relax-XML document also can be a valid XML document.
            Insofar it »is« XML. But XML does not describe a special
            syntax for integer numerals within an attribute value. To XML,
            this is just an opaque attribute value. Interpreting this as a
            list of integers is not backed by the XML TR anymore, this needs
            the additional Relax specification.
            >
            there are lots of things the XML spec doesn't secify, but to say XML
            encoding lists of numbers (an SVG path attribute for example) isn't XML
            is a rather strange conclusion to draw. For a start a lot (quite
            possibly a majority) of XML is "just" well formed and not validated at
            all so the relative expressive strengths of validation languages are
            irrelevant. For documents that are to be validated, it's issentially
            irrelevant to the end user, the internal organisation and timing of the
            various working groups that mean that xml is split across a range of
            specifications, xml itself, xml names, sax, dom, xsd etc. If you just go
            by what's in the XML rec without relying on anything else, you can not
            even use any standard parsing model, so use fo XML woul dbe rather hard,
            or you may decide it's legal to use names like <a:b:c/but then find
            that the vast majority of current xml tools follow the additinal
            constraints in the namespace spec and would reject such an element.

            Actually even by your definition XML can do more than you imply: IDREFS
            isn't the only list type NMTOKENS for example would allow you to specify
            an attribute is a white space list of something, even if you can't, in
            DTD, restrict the tokens further to be just digits. But to say XML with
            lists of integers in an attribute isn't really XML because DTD can't
            validate the XML is just like saying that an XMl document containing
            english text isn't really XML because DTD can't enforce spell checking.
            By that definition, what can XML be used for?

            David

            --

            Comment

            Working...