Subject: RE: [xsl] Documenting XML schema: a schema-to-XHTML stylesheet? From: "Conal Tuohy" <conalt@xxxxxxxxxxxxxxx> Date: Tue, 29 Apr 2003 10:10:35 +1200 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Documenting XML schema: a, Michael Kay | Thread | RE: [xsl] Documenting XML schema: a, Conal Tuohy |
[xsl] xml to xml transformation, Steven Curry | Date | RE: [xsl] Editing URLs, Hemi Kara |
Month |