@Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { final String namespace = attributes.getValue("xmlns"); if (namespace != null) { nsStack.push(namespace); } else { nsStack.push(nsStack.peek()); } stack.push(stack.peek().addChild(new DocElement(qname(qName), attributes) .startPosition(lastPosition))); }
public DocElement(final QName name, final Attributes attributes) { this(name, attributesToMap(attributes)); }
parentName = docPath.get(docPath.size() - 2).name(); ctx.docElementSiblings(docPath, e -> e.qname().equals(error.element()) && (attr == null || attrValue.equals(e.attributes().get(attr)))); result.addSecondaryMessage(I18N.Key.ELEMENT_DUPLICATED_FIRST_OCCURRENCE, el); result.addSecondaryResult(new HandledResult(otherEl.startPosition().line, otherEl.startPosition().col, null));
@Override public boolean equals(Object obj) { if (obj == null) return false; if (obj == this) return true; if (!(obj instanceof DocElement)) return false; final DocElement that = (DocElement)obj; return this.qname().equals(that.qname()) && this.attributes.equals(that.attributes) && this.startPosition.equals(that.startPosition) && this.endPosition.equals(that.endPosition); }
@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 List<SchemaElement> schemaPathWithPrefix(final List<SchemaElement> path) { if (this.prefixProvider == null) { this.prefixProvider = (p, __) -> { final List<List<DocElement>> prefixPaths = documentTree().pathsToValue(e -> e.name().equals(p.get(0).getLocalPart())); if (!prefixPaths.isEmpty()) { return prefixPaths.get(0) .stream() .map(e -> QName.valueOf(e.name())) .collect(Collectors.toList()); } return Collections.emptyList(); }; } final List<QName> prefix = this.prefixProvider.prefixFor(path.stream() .map(SchemaElement::qname) .collect(Collectors.toList()), this); if (prefix != null && !prefix.isEmpty()) { final List<SchemaElement> fullPath = new ArrayList<>(); fullPath.addAll(prefix.stream() .map(SchemaElement::new) .collect(Collectors.toList())); fullPath.addAll(path); return fullPath; } return path; }