Re: [xsl] dtd limit depth of elements

Subject: Re: [xsl] dtd limit depth of elements
From: "W. Eliot Kimber" <eliot@xxxxxxxxxx>
Date: Sat, 25 Jan 2003 09:33:47 -0600
Hubert Holtz wrote:

But another sect inside the third has to be invalid!
So, how can i limit the depth of elements inside a dtd?

There is no way to do it in a DTD.


As a rule, any production XML system must provide some form of validation application that enforces all of the business rules defined by the document type. A DTD is an intentionally simple syntactic constraint specification--there are many potential business rules that cannot be defined using DTD syntax. The same is true for XML Schema or any other declarative constraint language.

It's certainly easy to write an XSLT style sheet that will check these sorts of constraints, e.g:

<xsl:template match="//section/section/section/section">
  <xsl:message>+++ ERROR: Sections may only be nested at most three deep.
      <xsl:call-template name="show-ancestry"/></xsl:message>
</xsl:template>

For a more generic solution, you might find SchemaTron useful (http://www.ascc.net/xml/resource/schematron/schematron.html)

Cheers,

Eliot
--
W. Eliot Kimber, eliot@xxxxxxxxxx
Consultant, ISOGEN International

1016 La Posada Dr., Suite 240
Austin, TX  78752 Phone: 512.656.4139


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread