Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > validate custom restricted xhtml spec

Reply
Thread Tools

validate custom restricted xhtml spec

 
 
Tim
Guest
Posts: n/a
 
      02-03-2011
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
 
Reply With Quote
 
 
 
 
Joe Kesselman
Guest
Posts: n/a
 
      02-03-2011
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...lam/index.html

{} ASCII Ribbon Campaign | "may'ron DaroQbe'chugh vaj bIrIQbej" --
/\ Stamp out HTML mail! | "Put down the squeezebox & nobody gets hurt."
 
Reply With Quote
 
 
 
 
Peter Flynn
Guest
Posts: n/a
 
      02-03-2011
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/
 
Reply With Quote
 
Tim
Guest
Posts: n/a
 
      02-04-2011
On Feb 3, 5:49*pm, Peter Flynn <(E-Mail Removed)> 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
 
Reply With Quote
 
Manuel Collado
Guest
Posts: n/a
 
      02-05-2011
El 04/02/2011 16:55, Tim escribió:
> On Feb 3, 5:49 pm, Peter Flynn<(E-Mail Removed)> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to control order of spec execution in "spec specs/* " ? Andrew Chen Ruby 1 03-25-2008 12:36 PM
Validate client-side XSLT result of xhtml-math-svg C.W.Holeman II XML 7 05-30-2007 03:21 PM
parse URL (href) from xhtml, xhtml -> text, for data hawat.thufir@gmail.com XML 7 02-08-2006 07:39 PM
Help - How can I validate ASP code for XHTML, || NAME vs ID attribute Simon Barnett ASP .Net 1 12-23-2005 05:37 PM
failing to validate xhtml the idiot HTML 9 03-03-2005 10:10 PM



Advertisments