Validating FO

On Mon, January 20, 2014 6:00 am, Dave Pawson wrote [1]:
> On 19 January 2014 20:03, Tony Graham <tgraham@mentea.net> wrote:
>> On Tue, January 14, 2014 2:13 pm, Dave Pawson wrote:
...
>>> My favourite moan is the hard link to CSS.
>>> Even worse, the color syntax 'mess'.
>>
>> Does this relate to
>> http://lists.w3.org/Archives/Public/public-ppl/2013Jun/0017.html?
>
> Yes, directly. I was trying to  develop the Schema for FO when
> I came across that nightmare.

I suggest that Relax NG isn't the best technology to use for validating
XSL-FO.

> Rather than take a sensible approach to adopting one color
> schema, FO seems to have followed CSS and said 'anything goes'.

XSL-FO 2.0 was following SVG in defining its color functions [2].  Chris
Lilley came to a F2F specifically to talk about colour/color, and we
decided to align with what SVG had.

>   Mixing lengths is another irregular property set.

I do it quite often.  From a stylesheet that I happened to have open right
now:

----
<xsl:template match="item/list/item/list" priority="5">
  <fo:list-block
      start-indent="{$list-separation} + {$label-separation}"
      provisional-distance-between-starts="{$list-separation} +
					   {$label-separation}"
      provisional-label-separation="{$label-separation}">
    <xsl:apply-templates/>
    </fo:list-block>
</xsl:template>
----

I do often also parse lengths in XSLT to convert them all to pt and add
them in the XSLT to get the value to put in a property value, but that's
not nearly as convenient.

The rationale for why there's expressions in property values and why
there's other things that make XSL-FO hard to validate is, IIRC, that they
went for what was useful to express -- and I contend that getting the FO
processor to add lengths is useful -- rather that what could be shoehorned
into a schema grammar.

If you want to validate XSL-FO using a well-known schema mechanism, then
you could generate a parser for the FO expression language in XSLT using
the REx parser generator [3] and hook that up with Schematron and make
your assertions about what the parser tells you about the property values.

If you want something standalone, then use REx to make a parser in XSLT
then write a stylesheet to run over a FO file and produce error messages
as required.

And if you have a XML editor, either use REx again to produce code that
the editor runs to validate property values or hook the editor up to the
parsing stages of a FO processor such as FOP (assuming your editor is
written in Java or similar) to do the work.

Just because there's more to the property values than you can usefully
assert with Relax NG doesn't mean that it's wrong.

Regards,


Tony.

[1] http://lists.w3.org/Archives/Public/public-ppl/2014Jan/0088.html
[2] http://www.w3.org/TR/xslfo20/#expr-color-functions
[3] http://www.bottlecaps.de/rex/

Received on Monday, 20 January 2014 09:54:30 UTC