import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
+import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
}
// child nodes
- processUsesNode(usesNode, targetGrouping);
+ processUsesNode(module, usesNode, targetGrouping);
}
}
usesNode.addRefineNode(nodeToRefine);
}
- processUsesNode(usesNode, targetGroupingBuilder);
+ processUsesNode(module, usesNode, targetGroupingBuilder);
}
}
}
* Add nodes defined in target grouping to current context. Refinement has
* to be already performed.
*
+ * @param module current module
* @param usesNode
* @param targetGrouping
*/
- private void processUsesNode(final UsesNodeBuilder usesNode, final GroupingBuilder targetGrouping) {
+ private void processUsesNode(final ModuleBuilder module, final UsesNodeBuilder usesNode, final GroupingBuilder targetGrouping) {
List<SchemaNodeBuilder> refineNodes = usesNode.getRefineNodes();
DataNodeContainerBuilder parent = usesNode.getParent();
+ URI namespace = null;
+ Date revision = null;
+ String prefix = null;
+ if (parent instanceof ModuleBuilder || parent instanceof AugmentationSchemaBuilder) {
+ namespace = module.getNamespace();
+ revision = module.getRevision();
+ prefix = module.getPrefix();
+ } else {
+ QName parentQName = parent.getQName();
+ namespace = parentQName.getNamespace();
+ revision = parentQName.getRevision();
+ prefix = parentQName.getPrefix();
+ }
SchemaPath parentPath = parent.getPath();
for (DataSchemaNodeBuilder child : targetGrouping.getChildNodeBuilders()) {
if (child != null) {
// if node is refined, take it from refined nodes and continue
SchemaNodeBuilder refined = getRefined(child.getQName(), refineNodes);
if (refined != null) {
- refined.setPath(createSchemaPath(parentPath, refined.getQName().getLocalName()));
+ refined.setPath(createSchemaPath(parentPath, refined.getQName().getLocalName(), namespace,
+ revision, prefix));
parent.addChildNode((DataSchemaNodeBuilder) refined);
continue;
}
((GroupingMember) newChild).setAddedByUses(true);
}
- newChild.setPath(createSchemaPath(parentPath, newChild.getQName().getLocalName()));
+ newChild.setPath(createSchemaPath(parentPath, newChild.getQName().getLocalName(), namespace, revision,
+ prefix));
parent.addChildNode(newChild);
}
}
for (GroupingBuilder g : targetGrouping.getGroupingBuilders()) {
GroupingBuilder newGrouping = new GroupingBuilderImpl(g);
newGrouping.setAddedByUses(true);
- newGrouping.setPath(createSchemaPath(parentPath, newGrouping.getQName().getLocalName()));
+ newGrouping.setPath(createSchemaPath(parentPath, newGrouping.getQName().getLocalName(), namespace,
+ revision, prefix));
parent.addGrouping(newGrouping);
}
for (TypeDefinitionBuilder td : targetGrouping.getTypeDefinitionBuilders()) {
TypeDefinitionBuilder newType = new TypeDefinitionBuilderImpl(td);
newType.setAddedByUses(true);
- newType.setPath(createSchemaPath(parentPath, newType.getQName().getLocalName()));
+ newType.setPath(createSchemaPath(parentPath, newType.getQName().getLocalName(), namespace, revision, prefix));
parent.addTypedef(newType);
}
for (UsesNodeBuilder un : targetGrouping.getUses()) {
for (UnknownSchemaNodeBuilder un : targetGrouping.getUnknownNodeBuilders()) {
UnknownSchemaNodeBuilder newUn = new UnknownSchemaNodeBuilder(un);
newUn.setAddedByUses(true);
- newUn.setPath(createSchemaPath(parentPath, un.getQName().getLocalName()));
+ newUn.setPath(createSchemaPath(parentPath, un.getQName().getLocalName(), namespace, revision, prefix));
parent.addUnknownNodeBuilder(newUn);
}
}
final int line = usesNode.getLine();
List<SchemaNodeBuilder> refineNodes = usesNode.getRefineNodes();
DataNodeContainerBuilder parent = usesNode.getParent();
+ URI namespace = null;
+ Date revision = null;
+ String prefix = null;
+ if (parent instanceof ModuleBuilder) {
+ ModuleBuilder module = (ModuleBuilder) parent;
+ namespace = module.getNamespace();
+ revision = module.getRevision();
+ prefix = module.getPrefix();
+ } else {
+ QName parentQName = parent.getQName();
+ namespace = parentQName.getNamespace();
+ revision = parentQName.getRevision();
+ prefix = parentQName.getPrefix();
+ }
SchemaPath parentPath = parent.getPath();
for (DataSchemaNode child : targetGrouping.getChildNodes()) {
if (child != null) {
// if node is refined, take it from refined nodes and continue
SchemaNodeBuilder refined = getRefined(child.getQName(), refineNodes);
if (refined != null) {
- refined.setPath(createSchemaPath(parentPath, refined.getQName().getLocalName()));
+ refined.setPath(createSchemaPath(parentPath, refined.getQName().getLocalName(), namespace,
+ revision, prefix));
parent.addChildNode((DataSchemaNodeBuilder) refined);
continue;
}
if (newChild instanceof GroupingMember) {
((GroupingMember) newChild).setAddedByUses(true);
}
- newChild.setPath(createSchemaPath(parentPath, newChild.getQName().getLocalName()));
+ newChild.setPath(createSchemaPath(parentPath, newChild.getQName().getLocalName(), namespace, revision,
+ prefix));
parent.addChildNode(newChild);
}
}
for (GroupingDefinition g : targetGrouping.getGroupings()) {
GroupingBuilder newGrouping = createGrouping(g, moduleName, line);
newGrouping.setAddedByUses(true);
- newGrouping.setPath(createSchemaPath(parentPath, newGrouping.getQName().getLocalName()));
+ newGrouping.setPath(createSchemaPath(parentPath, newGrouping.getQName().getLocalName(), namespace,
+ revision, prefix));
parent.addGrouping(newGrouping);
}
for (TypeDefinition<?> td : targetGrouping.getTypeDefinitions()) {
TypeDefinitionBuilder newType = createTypedef((ExtendedType) td, moduleName, line);
newType.setAddedByUses(true);
- newType.setPath(createSchemaPath(parentPath, newType.getQName().getLocalName()));
+ newType.setPath(createSchemaPath(parentPath, newType.getQName().getLocalName(), namespace, revision, prefix));
parent.addTypedef(newType);
}
for (UsesNode un : targetGrouping.getUses()) {
for (UnknownSchemaNode un : targetGrouping.getUnknownSchemaNodes()) {
UnknownSchemaNodeBuilder newNode = createUnknownSchemaNode(un, moduleName, line);
newNode.setAddedByUses(true);
- newNode.setPath(createSchemaPath(parentPath, un.getQName().getLocalName()));
+ newNode.setPath(createSchemaPath(parentPath, un.getQName().getLocalName(), namespace, revision, prefix));
parent.addUnknownNodeBuilder(newNode);
}
}