in apache-rat-tools/src/main/java/org/apache/rat/tools/xsd/XsdGenerator.java [189:225]
private void writeMatcherElements() throws IOException {
MatcherBuilderTracker tracker = MatcherBuilderTracker.instance();
writer.open(Type.ELEMENT, "name", XMLConfig.MATCHER, "abstract", "true").close(Type.ELEMENT);
// matchers
for (Class<?> clazz : tracker.getClasses()) {
Description desc = DescriptionBuilder.buildMap(clazz);
if (desc != null) {
boolean hasResourceAttr = false;
Description inline = null;
List<Description> attributes = new ArrayList<>();
for (Description child : desc.getChildren().values()) {
if (XMLConfig.isInlineNode(desc.getCommonName(), child.getCommonName())) {
inline = child;
} else {
hasResourceAttr |= child.getCommonName().equals(XMLConfig.ATT_RESOURCE);
attributes.add(child);
}
}
writer.open(Type.ELEMENT, "name", desc.getCommonName(), "substitutionGroup", XMLConfig.MATCHER)
.open(Type.COMPLEX);
if (inline != null) {
if ("enclosed".equals(inline.getCommonName())) {
writer.open(Type.CHOICE).open(Type.ELEMENT, "ref", XMLConfig.MATCHER, "maxOccurs",
inline.isCollection() ? "unbounded" : "1", "minOccurs", hasResourceAttr ? "0" : "1")
.close(Type.CHOICE);
} else {
writer.open(Type.SIMPLE).open(Type.EXTENSION, "base", "xs:string");
}
}
for (Description child : attributes) {
attribute(child);
}
writer.close(Type.ELEMENT);
}
}
}