|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: styling a schema document (XSL needed)
> 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: http://titanium.dstc.edu.au/xml/xs3p/ .
You can also find below a sample stylesheet that will give you the following
output:
FIX/RECORD
Sequence of {
X_SPHERICAL
Y_SPHERICAL
Z_SPHERICAL
FIX_ID
minLength 3 maxLength 12
MAG_DECLINATION
minInclusive -90.0 maxInclusive 90.0
}
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:output method="text"/>
<xsl:template match="xs:element[@name='RECORD' and
ancestor::xs:element/@name='FIX']">
<xsl:text>FIX/RECORD</xsl:text>
<xsl:apply-templates mode="showContent"/>
</xsl:template>
<xsl:template match="xs:sequence" mode="showContent">
<xsl:text>Sequence of {</xsl:text>
<xsl:apply-templates mode="showContent"/>
<xsl:text>}</xsl:text>
</xsl:template>
<xsl:template match="xs:element" mode="showContent">
<xsl:value-of select="@name"/>
<xsl:apply-templates mode="showContent"/>
</xsl:template>
<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>
<xsl:template match="*" mode="showContent">
<xsl:apply-templates select="*" mode="showContent"/>
</xsl:template>
<xsl:template match="*">
<xsl:apply-templates select="*"/>
</xsl:template>
</xsl:stylesheet>
Your input schema after applying some corrections looks like:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xdb="http://xmlns.oracle.com/xdb">
<xs:element name="FIX" xdb:defaultTable="FIX_TAB">
<xs:complexType>
<xs:sequence>
<xs:element name="RECORD">
<xs:complexType>
<xs:sequence>
<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:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="3"/>
<xs:maxLength value="12"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="MAG_DECLINATION">
<xs:simpleType>
<xs:restriction base="xs:float">
<xs:minInclusive value="-90.0"/>
<xs:maxInclusive value="90.0"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Hope that helps,
George
-------------------------------------------------------------
George Cristian Bina mailto:george@xxxxxxxxxxxxx
<oXygen/> XML Editor - http://www.oxygenxml.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








