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

RE: Documenting XML schema: a schema-to-XHTML styleshe

Subject: RE: Documenting XML schema: a schema-to-XHTML stylesheet?
From: "Conal Tuohy" <conalt@xxxxxxxxxxxxxxx>
Date: Tue, 29 Apr 2003 10:10:35 +1200
documenting xml messages
Graham Hannington wrote:

> Argh... I've just found out that one of the XML document
> types that I'd
> planned to document (by writing an XDR schema, and then using XSLT to
> produce documentation in XHTML) cannot be fully expressed in
> either XDR or
> XSD, but (from what I've read in Jeni Tennison's tutorials)
> *might* be able
> to be described via Schematron.
>
> This is because, in this XML document type, allowable child
> elements vary,
> depending on the value of an attribute in the parent element.

This can certainly be described easily in Schematron.

NB Schematron is very expressive: a Schematron schema consists of a bunch of
pattern-matching rules (which are xpath expressions), and associated textual
descriptions and diagnostic messages.

This is very like an XSLT stylesheet, and in fact Schematron schemas ARE
typically applied by transforming them into an XSLT stylesheet, and then
using that XSLT to transform an instance document, producing a "report"
document describing the validity of the instance doc. So Schematron is a
very appropriate application for XSLT - maybe we're not TOO off-topic yet
;-)

For example: a schematron schema for the example you gave would be something
like:

<sch:schema xmlns:sch="http://www.ascc.net/xml/schematron" >

     <sch:pattern name="check 'element' element">

          <sch:rule context="element[@attrA='this']">
               <sch:assert test="*[not(self::elementX1) and
not(self:elementX2)]">
                   element with attrA = "this" may only contain elementX1 or
elementX2
               </sch:assert>
          </sch:rule>

          <sch:rule context="element[@attrA='that']">
               <sch:assert test="*[not(self::elementX3) and
not(self:elementX4)]">
                   element with attrA = "that" may only contain elementX3 or
elementX4
               </sch:assert>
          </sch:rule>

     </sch:pattern>

</sch:schema>

You can see the "rule-based" schema is already almost in the format you want
(unlike a DTD or XMLSchema) and the transformation to HTML is very
straightforward - I suggest you bite the bullet and write one to suit
yourself.

http://directory.google.com/Top/Computers/Data_Formats/Markup_Languages/XML/
Validation/Schematron

Cheers!

Con


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


Current Thread

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
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.