[Fontconfig] DTD

Peter Flynn peter at silmaril.ie
Tue Apr 3 21:05:31 UTC 2018


On 03/04/18 10:13, Lawrence D'Oliveiro wrote:
> On Tue, 3 Apr 2018 09:36:27 +0100, Peter Flynn wrote:
> 
>> Do you have examples or documentation of valid Fontconfig XML configs
> 
> Have you tried looking in the Fontconfig source?

I had, but had failed to find the files. Thanks for the pointer.

>> A validating XML parser on its own doesn't do anything either
> 
> On the contrary, 

No, you didn't read what I wrote: "on its own".  Of course it will do
something if you feed it a file.

> Fontconfig’s config parser does everything we need it to do: accept
> exactly that set of valid config files and reject everything else.
So the problem is *what* exactly? It's admittedly an interesting use
case for XML, but it's what XSLT does (in a different way).

> And it doesn’t just provide syntactic validation, but also semantic
> validation as well: we can use it to test that the config does in
> fact do what we expected it to do.

That sounds fine. But that's an application function. The DTD's task is
to inform a validating XML parser (like one in an editor, or in your C
code) what markup is allowed and where, so it can detect whether an
instance conforms to it or not, and what the current instance contains.

The only errors in the current DTD are that it's missing the element
type 'description', and missing the element types in the its: namespace.
Having made those changes, all the files validate just fine (diff attached).

If there is no risk that someone will accidentally type bogus characters
into the element type like int, then I don't see any need to use
anything else.  The DTD in this case is basically a placeholder for
validation which is done elsewhere (in the C code, for example).

>> I think someone may have misunderstood what XML is for.
> 
> No, I think you have misunderstood what DTDs are for.

:-) I don't think so. Thanks for the explanations.

///Peter

-------------- next part --------------
A non-text attachment was scrubbed...
Name: fonts.dtd.diff
Type: text/x-patch
Size: 691 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/fontconfig/attachments/20180403/b17b902c/attachment.bin>


More information about the Fontconfig mailing list