News for hackers. Stuff that matters.
Re:How to Avoid Being Called a Bozo When Producing XML (2005) by 616c on Sunday July 31, 2016 @02:01PM (#12198005)
I think the worst of this is what I call semantic incoherence.

I have a system that has things like <Task ID="6">Blah</Task>. Why is the ID, clearly always an integer in every sample of hundreds I see, represented as a string?

Another favorite: <ExecuteCommand>[CDATA[Batchfile.bat]]</ExecuteCommand>, while a binary or something else will be <ExecuteCommand>"program.exe /argument:f /argument2:x"</ExecuteCommand>.

By the way, this is an enterprise as it gets: a software tool from a four-letter hardware company, quite huge, trying to sell off its software division. I wonder why.

XML is like all other "crap" tools: Java, PHP, SOAP: some people do not grok the spirit of the law, and they do weird things that reflect their discomfort and hurried need to operate with it. Many write it off.

I agree with your points, this is just my corrolary. The sad thing is SEXPR and XML are not far removed, one is arguably a subset of the other, and notice how people lose their shit when you ask them to consider Lisp languages for daily works because "all those parens are stupid" and how the culture surrounding a potentially viable tools makes people close up without delving in with curiosity.

https://en.wikipedia.org/wiki/SXML

http://arclanguage.org/item?id=19453

Re:How to Avoid Being Called a Bozo When Producing XML (2005) by ams6110 on Sunday July 31, 2016 @02:19PM (#12198104)
> Why is the ID, clearly always an integer in every sample of hundreds I see, represented as a string

Becase XML is a text-based markup. If you truly want binary data you need to encode it and use CDATA sections.

Re:How to Avoid Being Called a Bozo When Producing XML (2005) by 616c on Sunday July 31, 2016 @02:24PM (#12198131)
That was not quite my point.

Why pretend it is a string at all?

<Task> <ID>3</ID> </Task>

I should have been more clear. Sometimes you have these argument type deals <Task ID="3"> where I would at least hope for <Task ID=3> or the monstrosity above (I assume ID=3 is not valid in hindsight, I am getting tired just writing this all on the second pass even!). And I see all different variations in the same XML file! There is no logical consistency, not even in the same config for the same function of this multi-stage system.

I am not even a novice programmer, and I find the variation annoying, and sometimes hard to reason about when I want to know what the hell the programer was thinking.

The valid part for the CDATA portion has changed several times in minor releases, so when our server team upgrades, I get to figure out the new syntax.

I thought XML was proposed to avoid these things! Haha. Again, tools in the hands of "wise men" like me are dangerous. I am probably as ignorant as them, I just think I know better!

Re:How to Avoid Being Called a Bozo When Producing XML (2005) by oceanswave on Sunday July 31, 2016 @03:27PM (#12198436)
Enclosing the attribute within double quotes isn't pre-disposing the value to be of a particular type. It's part of the XML spec that attribute values are contained within double quotes, and must be to be valid. The type isn't implied in the file.

An xml schema such as <xs:element name="Task"> <xs:complexType> <xs:attribute name="ID" type="xs:int" use="required" /> </xs:complexType> </xs:element>

could more explicitly declare the type of the value.

Re:How to Avoid Being Called a Bozo When Producing XML (2005) by 616c on Sunday July 31, 2016 @04:02PM (#12198574)
Thanks for the explanation. I guess in this case I learned be careful what you wish for. I guess this is why I prefer the

<Item> <Parameter><Data></Parameter> </Item>

But this is my ignorance of XML and familiarity with HTML showing.

Re:How to Avoid Being Called a Bozo When Producing XML (2005) by ams6110 on Sunday July 31, 2016 @02:51PM (#12198279)
XML as a config file format was a disaster in every example I ever encountered. Config files are supposed to be editable by humans using editors, and most that I saw were too complex for that. In particular the NeXT/Apple property file formats are horrible abuses of XML.

As a format to represent structured data, it could be fine as long as you were pragmatic about it. In the case of <task id="3"> you either assumed that "id" was always an integer or you validated it with a schema declaration, which quickly got hairy.

In practice I never validated XML beyond it being well-formed (which was provided by default in any parser) and never had any real problems.

Re:How to Avoid Being Called a Bozo When Producing XML (2005) by thangalin on Sunday July 31, 2016 @02:53PM (#12198294)
What takes fewer lines of code to parse?

    <element.name id.value="3.14">
Or accepting both:

    <element.name id.value="3.14">
    <element.name id.value=3.14>
How would you specify an empty value for mandatory attributes?
Re:How to Avoid Being Called a Bozo When Producing XML (2005) by colejohnson66 on Sunday July 31, 2016 @03:12PM (#12198372)
I've seen empty values written as

    <tag attr1 attr2="val">data</tag>
Whether that's legal or not, I don't know.
Re:How to Avoid Being Called a Bozo When Producing XML (2005) by oceanswave on Sunday July 31, 2016 @03:28PM (#12198447)
not valid. wondering if you've seen that within HTML, where it is valid.
Re:How to Avoid Being Called a Bozo When Producing XML (2005) by colejohnson66 on Sunday July 31, 2016 @04:42PM (#12198741)
Actually, now that you mention it, I think it's from Chrome's Inspect Element tool, but I can't check right now.

I think if you wrote something like

    <div class="">...</div>
it would display in the tool as

    <div class>...</div>
Re:How to Avoid Being Called a Bozo When Producing XML (2005) by kozak on Monday August 01, 2016 @07:15AM (#12201516)
Chrome's Inspect Element shows you the non-serialized DOM structure, which means it's neither XML nor HTML at that point.
Re:How to Avoid Being Called a Bozo When Producing XML (2005) by chiph on Sunday July 31, 2016 @02:51PM (#12198280)
Oh, this is the difference between attribute-oriented XML, element-oriented XML, and whatever-the-hell-we-feel-like-oriented XML. Publishers should pick one of the first two and be consistent about it.
Re:How to Avoid Being Called a Bozo When Producing XML (2005) by ams6110 on Sunday July 31, 2016 @03:00PM (#12198322)
Agree. Practical/pragmatic use of XML as a data format requires consistency.
Re:How to Avoid Being Called a Bozo When Producing XML (2005) by CamperBob2 on Sunday July 31, 2016 @04:03PM (#12198579)
I have a system that has things like <Task ID="6">Blah</Task>. Why is the ID, clearly always an integer in every sample of hundreds I see, represented as a string?

You're really asking a different question here: "Why should an integer be used as a task ID?" Storing the task ID as a string may give you options in the future that you wouldn't otherwise have, at a relatively small cost in parsing performance and validation overhead.

Most of the world's regrettable XML schemas were faulty at the specification stage, not the implementation stage. To minimize the likelihood of eventual regret, I usually prefer to store stuff in strings unless there's a very good reason not to. The fact that I'm using XML means that I'm not that concerned about performance, so... strings, it is.

A similar argument can be applied to the child/attribute dilemma. If there's even the slightest chance that a field isn't always going to be a leaf node, I'll do the extra typing and make it a child. Ideally the parser would be written to make them both work the same anyway.

Re:How to Avoid Being Called a Bozo When Producing XML (2005) by 616c on Monday August 01, 2016 @01:31PM (#12204271)
I see were you were downvoted, but I happen to see merit with your comment. Again, a lot of people make technical decisions without stepping back and just scanning their choices as non-specialist (in the context of their programming domain) and ask hey, does this make sense?
Re:How to Avoid Being Called a Bozo When Producing XML (2005) by CamperBob2 on Monday August 01, 2016 @05:28PM (#12206163)
Technically all attributes are supposed to be surrounded by quotes regardless of how they're interpreted. That renders the premise of my whole comment invalid, to be "technically correct," so the people downvoting may have had that in mind.

Still, there are plenty of XML applications that leave out the quotes on numeric attributes. My point was really that they're not doing themselves any favors by abusing the spec that way. A text-based markup language is a great example of how premature optimization is unhelpful most of the time.