XML parser patterns

M

Magnus Heino

Hi.

Are there any patterns or other design techniques that could be used
when implementing a xml parser that needs to be able to handle
different versions of a schema?

Let's say that I write a xml parser that can parse xhtml 1.0. Now I
want it to be able to handle both xhtml 1.0 and xhtml 1.1. How should
I design my application?

Thanks,

/Magnus
 
M

Martin Honnen

Magnus said:
Are there any patterns or other design techniques that could be used
when implementing a xml parser that needs to be able to handle
different versions of a schema?

Let's say that I write a xml parser that can parse xhtml 1.0. Now I
want it to be able to handle both xhtml 1.0 and xhtml 1.1. How should
I design my application?

A nonvalidating parser only needs to check for well-formedness and
should therefore be able to parse any XML language, whether that is
XTHML 1.0 or XHTML 1.1 or SVG.
Even a validating parser should be able to validate against any DTD
and/or XML schema and not just parse against the DTD for for instance
XHTML 1.0 strict. That is the whole reason to have a meta language XML
as an extensible markup language so that parsers can be written for XML
in general and not one for each XML language/application someone comes
up with.
I am not a parser developer however and we do not have many questions on
such topics here, maybe the list http://xml.org/xml/xmldev.shtml is a
better place to get answers from developers and implementers
 
R

Richard Tobin

Magnus Heino said:
Let's say that I write a xml parser that can parse xhtml 1.0.

That's not how it's usually done.

You write a parser that can parse *any* well-formed XML, and then you
write a validation layer on top of it that checks that the elements
and attributes conform to the DTD or schema.

-- Richard
 

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,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top