@Override public void endElement(String uri, String localName, String qName) throws SAXException { final Position pos = position(); stack.peek().value().endPosition(pos); storePosition(pos); stack.pop(); nsStack.pop(); }
public Set<String> attributesForElement(final List<SchemaElement> path) { Tree<SchemaElement> tree = schemaTree(); final Deque<SchemaElement> pathStack = new ArrayDeque<>(path); while (tree != null && !pathStack.isEmpty()) { final SchemaElement cur = pathStack.pop(); tree = tree.children().stream() .filter(t -> t.value().qname().equals(cur.qname())) .findFirst() .orElse(null); } final Set<String> ret = new HashSet<>(); if (tree != null && !tree.isRoot()) { ret.addAll(tree.value().attributes()); } return ret; }
public Set<SchemaElement> elementsForElement(final List<SchemaElement> path) { Tree<SchemaElement> tree = schemaTree(); final Deque<SchemaElement> pathStack = new ArrayDeque<>(path); while (tree != null && !pathStack.isEmpty()) { final SchemaElement cur = pathStack.pop(); tree = tree.children().stream() .filter(t -> t.value().qname().equals(cur.qname())) .findFirst() .orElse(null); } final Set<SchemaElement> ret = new HashSet<>(); if (tree != null && !tree.isRoot()) { ret.addAll(tree.children().stream() .map(Tree::value) .collect(Collectors.toList())); } return ret; }
@Override public void endElement(String uri, String localName, String qName) throws SAXException { switch (qName) { case "xs:element": if (activeStack().peek().value() != null && currentElement.name().equals(activeStack().peek().value().name())) { activeStack().pop(); currentElement = activeStack().peek().value(); } else { currentElement = null; } break; case "xs:complexType": if (innerComplexTypeDepth > 0) { innerComplexTypeDepth--; } else if (currentType != null) { currentType.setElements(currentTypeElementsTree); currentTypeElementsStack = null; currentTypeElementsTree = null; currentType = null; } break; } }
private void resolveElementReferences(final Tree<SchemaElement> tree) { final SchemaElement el = tree.value(); if (el != null && el.isReference()) { final SchemaElement realEl = this.elements.get(el.qname()); el.delegate(realEl); //FIXME: what about child elements? we can't capture that currently } tree.children().forEach(this::resolveElementReferences); }
private void applyTypesToElement(final Tree<SchemaElement> tree) { final SchemaElement el = tree.value(); if (el != null) { if (el.base() != null) { applyTypeToElement(this.types.get(el.base()), tree); } if (el.type() != null) { applyTypeToElement(this.types.get(el.type()), tree); } } tree.children().forEach(this::applyTypesToElement); }