[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: DTD Entity

  • From: Rick Jelliffe <ricko@a...>
  • To: jcowan@r..., xml-dev@l...
  • Date: Sun, 11 Mar 2001 10:59:39 +0800

dtd entity
From: jcowan@r... <jcowan@r...>

>Richard Knapp scripsit:
>
>> We are working on DTD with the following requirement:
>>
>> - Base element consists of Child elements First, Second, Third, and
Fourth.
>> - First must appear under Base.
>> - Second, Third, and Fourth may appear zero or one time.
>> - Order is not important for elements Second, Third, and Fourth.

In Schematron, you can express that like this

<rule context="Base">
    <assert test="count(*)=count(First) + count(Second) + count(Third) +
count(Fourth)"
    >Base element consists of Child elements First, Second, Third, and
Fourth</assert>
    <assert test="count(Base)=1"
    >First must appear under Base.</assert>
    <assert test="count(Second) &lt; 2 and count(Third) &lt; 2 and
count(Fourth) &lt; 2"
    >Second, Third, and Fourth may appear zero or one time</assert>
    <assert test="*[1]/self::Base"
    >Order is not important for elements Second, Third, and Fourth.</assert>
</assert>

Note that there is a one-to-one correspondence between the original text
specification
the assertions' statements.  This is common with Schematron schemas.
(However, it is an interesting question whether, just because it is easy to
write Schematron schemas from informal/partial specs, such specs are also
easier to read by third parties.
Of course, there are consiseness issues too, when thinking of readability,
however that really is a notation issue of XML versus DTD syntax versus some
mixture.)

Note also that the process of finding a test to implements the statement
also sheds
light on the statement, allowing it to be refined: in this case that "First
must appear
under Base" means that First is a required element that is no repeating (it
seems).
In the Schematron schema, there is a clear separation from the requirements
(the text
statements) and the implementation (the test attributes).

(For anyone interested, Schematron is a free software language and toolkit
for programmers at http://www.ascc.net/xml/schematron  )

Cheers
Rick Jelliffe


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.