2 * Copyright (c) 2019 PANTHEON.tech, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.data.codec.xml;
10 import static java.util.Objects.requireNonNull;
12 import java.io.IOException;
13 import javax.xml.stream.XMLStreamException;
14 import javax.xml.stream.XMLStreamReader;
15 import javax.xml.transform.dom.DOMSource;
16 import org.eclipse.jdt.annotation.NonNullByDefault;
17 import org.opendaylight.yangtools.yang.data.api.schema.MountPointContext;
18 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
19 import org.opendaylight.yangtools.yang.data.impl.schema.AbstractMountPointChild;
22 * Internal MountPointChild implementation, reusing data bits from {@link DOMSourceAnydata}.
25 final class DOMSourceMountPointChild extends AbstractMountPointChild {
26 private final DOMSource source;
28 DOMSourceMountPointChild(final DOMSource source) {
29 this.source = requireNonNull(source);
33 public void writeTo(final NormalizedNodeStreamWriter writer, final MountPointContext mountCtx) throws IOException {
34 final XmlParserStream xmlParser;
36 xmlParser = XmlParserStream.create(writer, mountCtx);
37 } catch (IllegalArgumentException e) {
38 throw new IOException("Failed to instantiate XML parser", e);
42 final XMLStreamReader reader = new DOMSourceXMLStreamReader(source);
43 xmlParser.parse(reader).flush();
44 } catch (XMLStreamException e) {
45 throw new IOException("Failed to parse payload", e);