Shows the importance of stating requirements unambiguously! Loren has interpreted the question as meaning "simple types that are not referenced from anywhere in the schema", whereas I interpreted it as "simple types that are not used in the course of a particular validation episode".
But even if Loren's interpretation is correct, his solution is incomplete: it doesn't allow for multiple schema documents, it doesn't allow for @type having a namespace prefix, and it doesn't allow for references to a type from another type, e.g. in @base, @itemType, or @memberTypes.
Michael Kay
Saxonica
> On 30 Mar 2016, at 16:24, Loren Cahlander <loren.cahlander@gmail.com> wrote:
>
> Try the following (untested) snippet
>
> fn:distinct-values($schema//xs:simpleType/@name[not(.=$schema//xs:element/@type/string())])
>
> Loren Cahlander
>
> On Mar 28, 2016, at 1:19 PM, Michael Kay <mike@saxonica.com <mailto:mike@saxonica.com>> wrote:
>
>> Saxon's schema processor has the option -stats:filename to report on the usage of schema components during a validation episode. IIRC it only lists the components that were used (not those that weren't) but you could do some post-processing to derive this information.
>>
>> Michael Kay
>> Saxonica
>>
>>
>>> On 28 Mar 2016, at 17:42, Costello, Roger L. <costello@mitre.org <mailto:costello@mitre.org>> wrote:
>>>
>>> Hi Folks,
>>>
>>> I am seeking a Java tool that finds all unused simpleTypes in an XML Schema.
>>>
>>> Does such a tool exist?
>>>
>>> /Roger
>>>
>>
>>
>>