xsl-list
[Top] [All Lists]

Re: [xsl] Want to use XSLT to sort an XML Schema

2008-02-15 08:56:56
you miss namespace :)

but OxygenXml have feature "Generate Schema Documentation" - maybe it
help for you better?

try http://oxygenxml.com - it have trial

with best wishes,
Slav

On Fri, Feb 15, 2008 at 6:49 PM, Glen Mazza 
<glen(_dot_)mazza(_at_)gmail(_dot_)com> wrote:
Hello,

 I have a huge XML Schema file consisting of xs:imports,
 xs:simpleTypes, and xs:complexTypes.  It is out of alphabetical order,
 making it very difficult to quickly find definitions of needed types.
 Also, the simpleTypes are interspersed with the complexTypes, and I
 would like to keep them separated as well.

 I would like to use XSLT to sort the document, first by imports, then
 by simpleTypes, and then by complexTypes, and for each the three
 groups, to have them sorted alphabetically.

 As for the stylesheet, this is the best I can come up with:

 <?xml version="1.0" encoding="UTF-8"?>

 <xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

 <xsl:template match="schema">

    <xsl:for-each select="./import">
         <xsl:sort select="@namespace"/>
         <xsl:apply-templates select="."/>
    </xsl:for-each>

    <xsl:for-each select="./simpleType">
         <xsl:sort select="@name"/>
         <xsl:apply-templates select="."/>
    </xsl:for-each>

    <xsl:for-each select="./complexType">
         <xsl:sort select="@name"/>
         <xsl:apply-templates select="."/>
    </xsl:for-each>

 </xsl:template>

 <xsl:template match="import">
    <xsl:copy-of select="."/>
 </xsl:template>

 <xsl:template match="simpleType">
    <xsl:copy-of select="."/>
 </xsl:template>

 <xsl:template match="complexType">
    <xsl:copy-of select="."/>
 </xsl:template>

 </xsl:stylesheet>

 And it's resulting in a huge blank file.  Oh well.  Does anyone know
 what I'm missing here to get this to work?  Also, I'm not really
 handling namespaces here, i.e., the elements are actually called
 xs:import, xs:simpleType, etc.  What (if anything) do I need to do to
 take care of the namespaces as well?

 Thanks,
 Glen

 --~------------------------------------------------------------------
 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
 To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
 or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
 --~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--