Re: Validating application-specific XHTML

Michael Kay schrieb:
>
> Sounds like you need to use schema-aware XSLT. If you use that to the
> the full, it can spot many cases of generating invalid output at
> stylesheet compile time, and the rest at run-time.

The application generating HTML currently is on PHP and XSLT 1.0. The
HTTP test tool I have in mind could make use of XSLT 2.0, that's true.
Including SA.

I'll keep on reading your book to get more familiar with 2.0, which I am
not yet.

> But it's not entirely clear to me from your post what constraints you
> are trying to validate against and whether they can all be expressed
> in a schema.

Things like this:

* body/div[@id = 'nav'] is present
* body/div[@id = 'content']/div[@class = 'bclg'] is present
* count( div[@class = 'bclg']/div[@class = 'item'] ) > 0
* div[@class = 'item']/h1 is present
* string-length(h1) > 0

Nothing too complicated, I think. (Maybe a lot of details, though.)

Using XML Schema for checking my XHTML came to my mind when reading the
documentation for HttpUnit (the Java library I mentioned that can be
used to write tests for web applications) and seeing the DOM-based
checks they suggest you do.

HttpUnit Cookbook
http://httpunit.sourceforge.net/doc/cookbook.html

But maybe XSL and XPath (especially 2.0) are better suited for this
task.

Thanks a lot for your answer.

Michael Ludwig

Received on Thursday, 27 November 2008 10:58:00 UTC