validate custom restricted xhtml spec

Discussion in 'XML' started by Tim, Feb 3, 2011.

  1. Tim

    Tim Guest

    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
     
    Tim, Feb 3, 2011
    #1
    1. Advertising

  2. On 2/3/2011 11:26 AM, Tim wrote:
    > 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."
     
    Joe Kesselman, Feb 3, 2011
    #2
    1. Advertising

  3. Tim

    Peter Flynn Guest

    On 03/02/11 16:26, Tim wrote:
    > 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
    --
    XML FAQ: http://xml.silmaril.ie/
     
    Peter Flynn, Feb 3, 2011
    #3
  4. Tim

    Tim Guest

    On Feb 3, 5:49 pm, Peter Flynn <> wrote:
    > On 03/02/11 16:26, Tim wrote:
    >
    > > 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
    > --
    > XML FAQ:http://xml.silmaril.ie/


    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
     
    Tim, Feb 4, 2011
    #4
  5. El 04/02/2011 16:55, Tim escribió:
    > On Feb 3, 5:49 pm, Peter Flynn<> wrote:
    >> On 03/02/11 16:26, Tim wrote:
    >>
    >>> 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
    >> --
    >> XML FAQ:http://xml.silmaril.ie/

    >
    > 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/

    --
    Manuel Collado - http://lml.ls.fi.upm.es/~mcollado
     
    Manuel Collado, Feb 5, 2011
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Simon Barnett
    Replies:
    1
    Views:
    651
    Bruce Barker
    Dec 23, 2005
  2. the idiot

    failing to validate xhtml

    the idiot, Mar 1, 2005, in forum: HTML
    Replies:
    9
    Views:
    4,010
    Jukka K. Korpela
    Mar 3, 2005
  3. Replies:
    7
    Views:
    927
  4. C.W.Holeman II
    Replies:
    7
    Views:
    699
    C.W.Holeman II
    May 30, 2007
  5. Andrew Chen
    Replies:
    1
    Views:
    219
    David Chelimsky
    Mar 25, 2008
Loading...

Share This Page