validate custom restricted xhtml spec

T

Tim

hi,
I produce xhtml documentation with some particular restrictions on
what metadata must be included, as well as the header and footer
structure.

Is there a way I can write or extend a validator (I'm thinking
relaxng) that would test my xhtml files to insure they have the proper
structure?

thanks for info or pointers to other documentation.
--Tim Arnold
 
J

Joe Kesselman

Is there a way I can write or extend a validator (I'm thinking
relaxng) that would test my xhtml files to insure they have the proper
structure?

What kind of constraints are you trying to enforce? Since XHTML is an
XML language, you could create an extended XHTML Schema which enforced
your additional constraints; you could also use XHTML modularity to add
elements from another namespace (and another schema working alongside
the standard XHTML).

But XML Schemas are focused very much on document structure and
datatypes; they don't handle interactions between specific data values.

RelaxNG or Schematron or some of the other secondary tools have
different tradeoffs and may or may not handle constraints that can't be
expressed easily in schemas.

But remember: Schema-level validation is very much about the next level
of language syntax above the basic XML layer. Validating semantics is
something that should be handled in the application layer. You can
certainly write applications to check XML documents for anything you
could possibly want to check them for, limited only by your own
programming skill -- start with a standard XML API like SAX or DOM and
run your algorithm on top of that. Of course that requires that you be
able to install that code on the machine which should do the checking.



--
Joe Kesselman,
http://www.love-song-productions.com/people/keshlam/index.html

{} ASCII Ribbon Campaign | "may'ron DaroQbe'chugh vaj bIrIQbej" --
/\ Stamp out HTML mail! | "Put down the squeezebox & nobody gets hurt."
 
P

Peter Flynn

hi,
I produce xhtml documentation with some particular restrictions on
what metadata must be included, as well as the header and footer
structure.

Is there a way I can write or extend a validator (I'm thinking
relaxng) that would test my xhtml files to insure they have the proper
structure?

You could just create a personal version of XHTML which makes the
required elements compulsory. However, making it require (for example)
multiple instances of the meta element, with different attribute values
each time, would be trickier.

It might be worth considering a combination of a private version of
XHTML and an XSLT script that would check for the correct number and
value of multiple occurrences of certain element types.

There is only so much that a Schema or DTD can do: after that it's
really down to the application to do any additional checking.

///Peter
 
T

Tim

You could just create a personal version of XHTML which makes the
required elements compulsory. However, making it require (for example)
multiple instances of the meta element, with different attribute values
each time, would be trickier.

It might be worth considering a combination of a private version of
XHTML and an XSLT script that would check for the correct number and
value of multiple occurrences of certain element types.

There is only so much that a Schema or DTD can do: after that it's
really down to the application to do any additional checking.

///Peter

Thanks Joe, for helping me understand the problem domain schemas are
meant to deal with. I think I was jumping to conclusions.
Peter, now that I have a better understanding I slap my hand to
forehead at your suggestion of using xslt. Why didn't I think of that
to start with? That's the easy way to handle this. I have to have
certain meta tags with certain values and a specific hierarchy of
elements inside the navigation headers.

That will be very easy to check using xslt and xpath. Along with
writing xsl:messages for certain outcomes I should be able to get a
script together very easily to make sure my xhtml files conform to the
restrictions.

thanks!
--Tim Arnold
 
M

Manuel Collado

El 04/02/2011 16:55, Tim escribió:
Thanks Joe, for helping me understand the problem domain schemas are
meant to deal with. I think I was jumping to conclusions.
Peter, now that I have a better understanding I slap my hand to
forehead at your suggestion of using xslt. Why didn't I think of that
to start with? That's the easy way to handle this. I have to have
certain meta tags with certain values and a specific hierarchy of
elements inside the navigation headers.

That will be very easy to check using xslt and xpath. Along with
writing xsl:messages for certain outcomes I should be able to get a
script together very easily to make sure my xhtml files conform to the
restrictions.

You can also consider using Schematron. It is a rule-based, higher level
validation language based on XPath. The schematron compiler translates it
to a standard XSLT code that can be used to finally validate the desired
XML documents:

http://www.schematron.com/
 

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

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top