import org.opendaylight.yangtools.yang.common.ErrorType;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
final String docRootElm = doc.getDocumentElement().getLocalName();
final String docRootNamespace = doc.getDocumentElement().getNamespaceURI();
- final List<PathArgument> iiToDataList = new ArrayList<>();
-
- final SchemaInferenceStack stack = SchemaInferenceStack.of(pathContext.getSchemaContext());
- pathContext.getInstanceIdentifier().getPathArguments().stream()
- .filter(arg -> !(arg instanceof NodeIdentifierWithPredicates))
- .filter(arg -> !(arg instanceof AugmentationIdentifier))
- .forEach(p -> stack.enterSchemaTree(p.getNodeType()));
+ final List<YangInstanceIdentifier.PathArgument> iiToDataList = new ArrayList<>();
if (isPost() && !isOperation) {
- final Deque<Object> foundSchemaNodes = findPathToSchemaNodeByName(schemaNode, docRootElm,
- docRootNamespace, stack);
+ final Deque<Object> foundSchemaNodes = findPathToSchemaNodeByName(schemaNode, docRootElm, docRootNamespace);
if (foundSchemaNodes.isEmpty()) {
throw new IllegalStateException(String.format("Child \"%s\" was not found in parent schema node \"%s\"",
docRootElm, schemaNode.getQName()));
if (schemaNode instanceof ContainerLike || schemaNode instanceof ListSchemaNode
|| schemaNode instanceof LeafSchemaNode) {
- if (isOperation) {
- stack.enterSchemaTree(schemaNode.getQName());
- }
- final XmlParserStream xmlParser = XmlParserStream.create(writer, stack.toInference());
+ final XmlParserStream xmlParser = XmlParserStream.create(writer, SchemaInferenceStack.ofInstantiatedPath(
+ pathContext.getSchemaContext(), schemaNode.getPath()).toInference());
xmlParser.traverse(new DOMSource(doc.getDocumentElement()));
parsed = resultHolder.getResult();
}
private static Deque<Object> findPathToSchemaNodeByName(final DataSchemaNode schemaNode, final String elementName,
- final String namespace, final SchemaInferenceStack stack) {
+ final String namespace) {
final Deque<Object> result = new ArrayDeque<>();
final ArrayList<ChoiceSchemaNode> choiceSchemaNodes = new ArrayList<>();
for (final DataSchemaNode child : ((DataNodeContainer) schemaNode).getChildNodes()) {
&& child.getQName().getNamespace().toString().equalsIgnoreCase(namespace)) {
// add child to result
result.push(child);
- stack.enterSchemaTree(child.getQName());
// find augmentation
if (child.isAugmenting()) {
}
for (final ChoiceSchemaNode choiceNode : choiceSchemaNodes) {
- stack.enterChoice(choiceNode.getQName());
for (final CaseSchemaNode caseNode : choiceNode.getCases()) {
- stack.enterSchemaTree(caseNode.getQName());
- final Deque<Object> resultFromRecursion = findPathToSchemaNodeByName(caseNode, elementName,
- namespace, stack);
+ final Deque<Object> resultFromRecursion = findPathToSchemaNodeByName(caseNode, elementName, namespace);
if (!resultFromRecursion.isEmpty()) {
resultFromRecursion.push(choiceNode);
if (choiceNode.isAugmenting()) {
}
return resultFromRecursion;
}
- stack.exit();
}
- stack.exit();
}
return result;
}