Invalid XML

E

Esther

I'm pretty new to XML/XSLT, although not to development. I had thought
that one of the premises of XML is that every tag requires a closing
tag.

I've just been handed a spec prepared by one of our vendors that
includes instructions and samples like these:

"<difficulty_section> Tag

This tag defines a difficulty level that will be used for all
subsequent questions. This difficulty level will be used until a new
<difficulty_section> tag is found, or until a </difficulty_section>
end tag clears the level.

Example:

<difficulty_section>
Advanced

<difficulty_section>
Beginner"

I wasn't aware this was possible, especially since nesting is allowed
in their model. Could someone please clarify for me if I'm missing one
of the finer points of XML, or are these people just idiots?
 
J

jmm-list-gn

Esther said:
I've just been handed a spec prepared by one of our vendors that
includes instructions and samples like these:

"<difficulty_section> Tag

I wasn't aware this was possible, especially since nesting is allowed
in their model. Could someone please clarify for me if I'm missing one
of the finer points of XML, or are these people just idiots?
It certainly not valid XML. It is not even well-formed. This does not
mean a parser cannot parse the document; only that the document is poorly
created.
XML is similar to HTML in this respect. A lot of very bad HTML markup
can be rendered (more or less) as expected; bad markup makes the browser
work harder and reduces the chances that the result is the same for all
browsers.
So they are not idiots, exactly. They just don't bother with validation.
 
A

Andy Dingley

Could someone please clarify for me if I'm missing one
of the finer points of XML, or are these people just idiots?

Hard to tell. Is this even XML ? If they're using SGML, then they
_might_ get away with this.

I'm loath to call them idiots (we haven't even been introduced, after
all) but the worst part of this IMHO is their (all too common)
treatment of an _example_ as a _specification_. This is just a very
bad idea - examples only describe one single instance, not the whole
problem domain. It's a good route to all sorts of obscure future
problem, and a particular bugbear of mine.

If you're specifiying the format of an XML document, use either a DTD
or (better) a schema. If you can't do either, or don;t know why you
ought to, then you might not be an idiot but you're certainly out of
your depth.
 
P

Patrick TJ McPhee

% > I've just been handed a spec prepared by one of our vendors that
% > includes instructions and samples like these:
% >
% > "<difficulty_section> Tag
% >
% > I wasn't aware this was possible, especially since nesting is allowed
% > in their model. Could someone please clarify for me if I'm missing one
% > of the finer points of XML, or are these people just idiots?
% >
% It certainly not valid XML. It is not even well-formed. This does not
% mean a parser cannot parse the document; only that the document is poorly
% created.

Conforming XML parsers are required to stop passing parsing information
to the application when they encounter well-formedness errors. The
reason for this is to prevent the problem with HTML, which is that
everyone has to be able to process garbage documents in order to
inter-operate with everyone else.

% So they are not idiots, exactly. They just don't bother with validation.

It seems like they didn't bother using XML at all. To the OP, is this
supposed to be XML, or is it SGML? The kind of mark-up you describe is
quite common and perfectly legal in the SGML world.
 
E

Esther

Andy Dingley said:
Hard to tell. Is this even XML ? If they're using SGML, then they
_might_ get away with this.

Nope, it's supposed to be XML.
I'm loath to call them idiots (we haven't even been introduced, after
all) but the worst part of this IMHO is their (all too common)
treatment of an _example_ as a _specification_. This is just a very
bad idea - examples only describe one single instance, not the whole
problem domain. It's a good route to all sorts of obscure future
problem, and a particular bugbear of mine.

I *have* been introduced, and it would not be the most inaccurate
name...
If you're specifiying the format of an XML document, use either a DTD
or (better) a schema. If you can't do either, or don;t know why you
ought to, then you might not be an idiot but you're certainly out of
your depth.

I know why you should use DTD/schema, but as I said - I'm new to this
and hesitated to call them on it because I wasn't positive there
wasn't some advanced concept I was missing that would allow it.

Thanks all of you for your answers.
 
M

Malcolm Dew-Jones

Patrick TJ McPhee ([email protected]) wrote:
: In article <[email protected]>,
: % Esther wrote:
: % > I've just been handed a spec prepared by one of our vendors that
: % > includes instructions and samples like these:
: % >
: % > "<difficulty_section> Tag
: % >
: % > I wasn't aware this was possible, especially since nesting is allowed
: % > in their model. Could someone please clarify for me if I'm missing one
: % > of the finer points of XML, or are these people just idiots?
: % >
: % It certainly not valid XML. It is not even well-formed. This does not
: % mean a parser cannot parse the document; only that the document is poorly
: % created.

: Conforming XML parsers are required to stop passing parsing information
: to the application when they encounter well-formedness errors.

The problem is not a well-formedness error though, so a SAX parser could
parse past the tags, the error would not occur until later when the
balancing didn't work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,830
Latest member
HeleneMull

Latest Threads

Top