Re: [xsl] styling a schema document (XSL needed)

Subject: Re: [xsl] styling a schema document (XSL needed)
From: "George Cristian Bina" <george@xxxxxxx>
Date: Thu, 12 Feb 2004 10:04:06 +0200
> I am not sure how to write the
> stylesheet - i.e. what to use in the template match for XSL to extract
> those.

XSD schemas are represented as XML documents so you can process them with
XSLT as any other XML document.
Please note that your sample schema is not wellformed and even if the
wellformed errors are corrected it is not valid. You can find the corrected
schema below.

> Please send me a basic stylesheet example, if possible, for the desire
> output I have also included below. I do not need help with the HTML
> styling elements, just how to do a template match to extract these
> values. I have used XSL stylesheets before to style XML docs, but not
> XSD docs.

You may find interesting the XS3P schema documentation generator that is
basically a stylesheet that applied on a schema generates a comprehensive
XHTML documentation: .

You can also find below a sample stylesheet that will give you the following

          Sequence of {
                minLength 3 maxLength 12

                minInclusive -90.0 maxInclusive 90.0


<xsl:stylesheet xmlns:xsl="";

    <xsl:output method="text"/>
    <xsl:template match="xs:element[@name='RECORD' and
       <xsl:apply-templates mode="showContent"/>

    <xsl:template match="xs:sequence" mode="showContent">
        <xsl:text>Sequence of {</xsl:text>
        <xsl:apply-templates mode="showContent"/>

    <xsl:template match="xs:element" mode="showContent">
        <xsl:value-of select="@name"/>
        <xsl:apply-templates mode="showContent"/>

    <xsl:template match="xs:restriction/*" mode="showContent">
        <xsl:value-of select="local-name(.)"/>
        <xsl:text xml:space="preserve"> </xsl:text>
        <xsl:value-of select="@value"/>
        <xsl:text xml:space="preserve"> </xsl:text>

    <xsl:template match="*" mode="showContent">
        <xsl:apply-templates select="*" mode="showContent"/>
    <xsl:template match="*">
        <xsl:apply-templates select="*"/>


Your input schema after applying some corrections looks like:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="";
  <xs:element name="FIX" xdb:defaultTable="FIX_TAB">
        <xs:element name="RECORD">
              <xs:element name="X_SPHERICAL" type="xs:integer"/>
              <xs:element name="Y_SPHERICAL" type="xs:integer"/>
              <xs:element name="Z_SPHERICAL" type="xs:integer"/>
              <xs:element name="FIX_ID">
                  <xs:restriction base="xs:string">
                    <xs:minLength value="3"/>
                    <xs:maxLength value="12"/>
              <xs:element name="MAG_DECLINATION">
                  <xs:restriction base="xs:float">
                    <xs:minInclusive value="-90.0"/>
                    <xs:maxInclusive value="90.0"/>

Hope that helps,
George Cristian Bina mailto:george@xxxxxxxxxxxxx
<oXygen/> XML Editor -

 XSL-List info and archive:

Current Thread