次のコードがあります。
public XsdValidator(Resource... xsds) {
Preconditions.checkArgument(xsds != null);
try {
this.xsds = ImmutableList.copyOf(xsds);
SchemaFactory schemaFactory = SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI);
LOGGER.debug("Schema factory created: {}",schemaFactory);
StreamSource[] streamSources = streamSourcesOf(xsds);
LOGGER.debug("StreamSource[] created: {}",streamSources);
Schema schema = schemaFactory.newSchema(streamSources);
LOGGER.debug("Schema created: {}",schema);
validator = schema.newValidator();
LOGGER.debug("Validator created: {}",validator);
} catch ( Exception e ) {
throw new IllegalArgumentException("Can't build XsdValidator",e);
}
}
XSD ファイルに対してこの行schemaFactory.newSchema(streamSources);
を実行するには、非常に長い時間 (30 秒) かかるようです。
この XSD で多くのテストを行った結果、次のことが原因のようです。
<xs:complexType name="entriesType">
<xs:sequence>
<xs:element type="prov:entryType" name="entry" minOccurs="0" maxOccurs="10000" />
</xs:sequence>
</xs:complexType>
問題はmaxOccurs="10000"
maxOccurs="1"
またはを使用maxOccurs="unbounded"
すると、非常に高速です。
誰かが使用の問題を教えてもらえますかmaxOccurs="10000"
?