W3C home > Mailing lists > Public > xmlschema-dev@w3.org > March 2016

Re: Tool that finds unused simpleTypes?

From: Michael Kay <mike@saxonica.com>
Date: Wed, 30 Mar 2016 16:34:20 +0100
Cc: "Costello, Roger L." <costello@mitre.org>, "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
Message-Id: <49D1FF90-7AA1-4DF8-91E6-89279152B2EC@saxonica.com>
To: Loren Cahlander <loren.cahlander@gmail.com>
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
>>> 
>> 
>> 
>> 
Received on Wednesday, 30 March 2016 15:34:57 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 30 March 2016 15:34:57 UTC