News for hackers. Stuff that matters.
Re:How to Avoid Being Called a Bozo When Producing XML (2005) by voltagex_ on Sunday July 31, 2016 @08:38PM (#12199616)
How would you write that example while taking advantage of the XML features you're talking about?
Re:How to Avoid Being Called a Bozo When Producing XML (2005) by bane on Sunday July 31, 2016 @08:59PM (#12199664)
I think what you might be asking is "what would more idiomatic XML look like?" And that's a fair question for people who haven't spent lots of time working with XML.

First off, I think attributes are evil. In theory, they're good, but nobody knows how to use them, so they shouldn't ever be part of your XML. They're simply elements with cardinality of 1.

The format would probably be better as:

   <format>
      <record>
         <id>1</id>
         <name>
            abc
            <comment>blah blah</comment>
         </name>
         <attribute>this is the attribute value</attribute>
      </record>
      <record>
      ...
      </record>
   </format>
This is a completely valid XML language, is much more clearer, less verbose, doesn't overload element names, doesn't abuse attributes, etc. etc.

One important thing that most people don't get about XML is that XML is a specification for describing data-interchange formats. XML isn't a format, or a language. The result of following the XML spec is an "XML format".

If somebody asks what format some data format is in, it's more appropriate to say "it's in an XML" rather than "it's in XML".

Re:How to Avoid Being Called a Bozo When Producing XML (2005) by lmm on Monday August 01, 2016 @05:30AM (#12201101)
Well this reduces to something like:

    <abc>
      blah blah
      <attribute>this is the attribute value</field>
    </abc>
The point is not to write a flexible meta-format for expressing arbitrary objects, because XML is already that. Each specific thing you want to express should have its own specific format. That way you can actually use the validation features too.