import java.io.Closeable;
import java.io.Flushable;
import java.io.IOException;
-import java.net.URI;
import java.net.URISyntaxException;
import java.util.AbstractMap.SimpleImmutableEntry;
import java.util.Deque;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stax.StAXSource;
-import org.opendaylight.yangtools.odlext.model.api.YangModeledAnyxmlSchemaNode;
import org.opendaylight.yangtools.rfc7952.model.api.AnnotationSchemaNode;
import org.opendaylight.yangtools.rfc8528.data.api.MountPointContext;
import org.opendaylight.yangtools.rfc8528.data.api.MountPointContextFactory;
import org.opendaylight.yangtools.rfc8528.model.api.SchemaMountConstants;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.common.XMLNamespace;
import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
import org.opendaylight.yangtools.yang.data.util.AbstractMountPointDataWithSchema;
import org.opendaylight.yangtools.yang.data.util.AbstractNodeDataWithSchema;
import org.opendaylight.yangtools.yang.data.util.OperationAsContainer;
import org.opendaylight.yangtools.yang.data.util.ParserStreamUtils;
import org.opendaylight.yangtools.yang.data.util.SimpleNodeDataWithSchema;
-import org.opendaylight.yangtools.yang.data.util.YangModeledAnyXmlNodeDataWithSchema;
import org.opendaylight.yangtools.yang.model.api.AnydataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode;
import org.opendaylight.yangtools.yang.model.api.ContainerLike;
* annotations.
*/
@Deprecated
- public static final QNameModule LEGACY_ATTRIBUTE_NAMESPACE = QNameModule.create(URI.create("")).intern();
+ public static final QNameModule LEGACY_ATTRIBUTE_NAMESPACE = QNameModule.create(XMLNamespace.of("")).intern();
private static final Logger LOG = LoggerFactory.getLogger(XmlParserStream.class);
private static final String XML_STANDARD_VERSION = "1.0";
nodeDataWithSchema = new ContainerNodeDataWithSchema((ContainerLike) parentNode);
} else if (parentNode instanceof ListSchemaNode) {
nodeDataWithSchema = new ListNodeDataWithSchema((ListSchemaNode) parentNode);
- } else if (parentNode instanceof YangModeledAnyxmlSchemaNode) {
- nodeDataWithSchema = new YangModeledAnyXmlNodeDataWithSchema((YangModeledAnyxmlSchemaNode) parentNode);
} else if (parentNode instanceof AnyxmlSchemaNode) {
nodeDataWithSchema = new AnyXmlNodeDataWithSchema((AnyxmlSchemaNode) parentNode);
} else if (parentNode instanceof LeafSchemaNode) {
return;
}
- if (parent instanceof YangModeledAnyxmlSchemaNode) {
- parent.setAttributes(getElementAttributes(in));
- }
-
switch (in.nextTag()) {
case XMLStreamConstants.START_ELEMENT:
// FIXME: 7.0.0: why do we even need this tracker? either document it or remove it.
final Set<Entry<String, String>> namesakes = new HashSet<>();
while (in.hasNext()) {
final String xmlElementName = in.getLocalName();
-
- DataSchemaNode parentSchema = parent.getSchema();
+ final DataSchemaNode parentSchema = parent.getSchema();
final String parentSchemaName = parentSchema.getQName().getLocalName();
if (parentSchemaName.equals(xmlElementName)
break;
}
- if (parentSchema instanceof YangModeledAnyxmlSchemaNode) {
- parentSchema = ((YangModeledAnyxmlSchemaNode) parentSchema).getSchemaOfAnyXmlData();
- }
-
final String elementNS = in.getNamespaceURI();
final boolean added = namesakes.add(new SimpleImmutableEntry<>(elementNS, xmlElementName));
- final URI nsUri;
+ final XMLNamespace nsUri;
try {
nsUri = rawXmlNamespace(elementNS).getNamespace();
} catch (IllegalArgumentException e) {
if (!added && !elementList) {
throw new XMLStreamException(String.format(
"Duplicate element \"%s\" in namespace \"%s\" with parent \"%s\" in XML input",
- xmlElementName, elementNS, parent.getSchema()), in.getLocation());
+ xmlElementName, elementNS, parentSchema), in.getLocation());
}
// We have a match, proceed with it
} else if (parentSchema instanceof ListSchemaNode) {
optMount = MountPointSchemaNode.streamAll((ListSchemaNode) parentSchema).findFirst();
} else {
- throw new XMLStreamException("Unhandled mount-aware schema " + parentSchema);
+ throw new XMLStreamException("Unhandled mount-aware schema " + parentSchema,
+ in.getLocation());
}
if (optMount.isPresent()) {
if (strictParsing) {
throw new XMLStreamException(String.format(
"Schema for node with name %s and namespace %s does not exist at %s", xmlElementName,
- elementNS, parentSchema.getPath(), in.getLocation()));
+ elementNS, parentSchema.getPath()), in.getLocation());
}
LOG.debug("Skipping unknown node ns=\"{}\" localName=\"{}\" at path {}", elementNS, xmlElementName,
return last instanceof ListSchemaNode || last instanceof LeafListSchemaNode;
}
- private static void addMountPointChild(final MountPointData mount, final URI namespace, final String localName,
- final DOMSource source) {
+ private static void addMountPointChild(final MountPointData mount, final XMLNamespace namespace,
+ final String localName, final DOMSource source) {
final DOMSourceMountPointChild child = new DOMSourceMountPointChild(source);
if (YangLibraryConstants.MODULE_NAMESPACE.equals(namespace)) {
final Optional<ContainerName> optName = ContainerName.forLocalName(localName);
private Optional<QNameModule> resolveXmlNamespace(final String xmlNamespace) {
return resolvedNamespaces.computeIfAbsent(xmlNamespace, nsUri -> {
- final Iterator<? extends Module> it = codecs.getEffectiveModelContext().findModules(URI.create(nsUri))
+ final Iterator<? extends Module> it = codecs.getEffectiveModelContext().findModules(XMLNamespace.of(nsUri))
.iterator();
return it.hasNext() ? Optional.of(it.next().getQNameModule()) : Optional.empty();
});
}
private QNameModule rawXmlNamespace(final String xmlNamespace) {
- return rawNamespaces.computeIfAbsent(xmlNamespace, nsUri -> QNameModule.create(URI.create(nsUri)));
+ return rawNamespaces.computeIfAbsent(xmlNamespace, nsUri -> QNameModule.create(XMLNamespace.of(nsUri)));
}
}