Creating XML Schema is Time-consuming

I have the following code:

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);
    }
  }

It seems that the line schemaFactory.newSchema(streamSources);takes a very long time (30 seconds) to execute my XSD file.

After many tests on this XSD, it looks like what I have:

  <xs:complexType name="entriesType">
    <xs:sequence>
      <xs:element type="prov:entryType" name="entry" minOccurs="0" maxOccurs="10000" />
    </xs:sequence>
  </xs:complexType>

Task maxOccurs="10000"

With maxOccurs="1"or maxOccurs="unbounded"it is very fast.

Can someone tell me what the problem is with using maxOccurs="10000"?

+4
source share
1 answer

Based on my personal experience, the presence of particles limited to what some might consider “unfounded” high values ​​is causing performance problems ( this link is from my favorite browsers).

, -, ( , maxOccurs).

, , , , , maxOccurs , , XSD ( , ).

+4

All Articles