XML newbie question

M

masood.iqbal

In a nutshell, what would you say is the difference between an XML
serializer and an XML parser? My apologies if this question sounds
too basic.

Thanks,
Masood
 
P

Pavel Lepin

In a nutshell, what would you say is the difference
between an XML serializer and an XML parser? My apologies
if this question sounds too basic.

Homework? Anyway, in terms that likely won't get you through
an exam: you stuff a data structure into a serializer and
get a serialized document out of it. You stuff a serialized
document into a parser and get a data structure out of it.
 
J

Jürgen Kahrs

Pavel said:
Homework? Anyway, in terms that likely won't get you through
an exam: you stuff a data structure into a serializer and
get a serialized document out of it. You stuff a serialized
document into a parser and get a data structure out of it.

Hmm, strictly speaking a parser is mereley a function
that reads an input text and decides if it is syntactically
correct or not (so a parser is a boolean function producing
no output). A serializer is indeed a function that produces
output.
 
P

P. Lepin

Jürgen Kahrs said:
Hmm, strictly speaking a parser is mereley a function
that reads an input text and decides if it is syntactically
correct or not (so a parser is a boolean function producing
no output). A serializer is indeed a function that produces
output.

Hardly the most authoritative source, but Wikipedia seems to disagree
strongly. From <http://en.wikipedia.org/wiki/Parser>:

In computer science and linguistics, parsing (more formally: syntactic
analysis) is the process of analyzing a sequence of tokens to determine
its grammatical structure with respect to a given formal grammar. A parser
is the component of a compiler that carries out this task.

Parsing transforms input text into a data structure, usually a tree, which
is suitable for later processing and which captures the implied hierarchy
of the input.

That's precisely how I always understood the nature of parsing. Could you
provide a reference to your source? Could be an interesting read.
 
J

Jürgen Kahrs

P. Lepin said:
In computer science and linguistics, parsing (more formally: syntactic
analysis) is the process of analyzing a sequence of tokens to determine
its grammatical structure with respect to a given formal grammar. A parser
is the component of a compiler that carries out this task.

Up to here, I see no disagreement.
Parsing transforms input text into a data structure, usually a tree, which
is suitable for later processing and which captures the implied hierarchy
of the input.

That's precisely how I always understood the nature of parsing. Could you
provide a reference to your source? Could be an interesting read.

When I studied compiler construction (in the early 1980s),
I learned from Niklaus Wirth's books what a minimal parser is.
Have a look at this (updated) book:

http://www.oberon.ethz.ch/WirthPubl/CBEAll.pdf


For example, in exercise 4.3 on page 25 he writes:

"Write a parser for EBNF and extend it with statements
generating the data structure (for table-driven parsing)
corresponding to the read syntax."

On the following pages he consistently distinguishes
between a parser (merely recognizing a language) and a translator.
This attitude is what I meant when I said that a parser is
only a "predicate". Maybe this attitude is outdated.
 
J

Joseph Kesselman

Jürgen Kahrs said:
This attitude is what I meant when I said that a parser is
only a "predicate". Maybe this attitude is outdated.

In common use these days, "parser" tends to imply the combination of
lexical analyser, parser, and some form of output from the parser that
permits the user to do something useful with the information developed
by the parser. "XML parser" in particular is usually interpreted as "XML
processor" as defined in the spec, and the output stage is usually
implmented either as callbacks (most often SAX) or as a model builder
(most often DOM).

The only folks who still talk about the parser as an independent piece
are those who are implementing parsers, and even there they often draw a
distinction between the parser engine and the parser tool.
 

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
474,174
Messages
2,570,941
Members
47,476
Latest member
blackwatermelon

Latest Threads

Top