# ADLParser ArchetypeInternalRef **Category:** [Technical (archive)](https://discourse.openehr.org/c/technical-archive/156) **Created:** 2014-03-21 10:43 UTC **Views:** 1 **Replies:** 2 **URL:** https://discourse.openehr.org/t/adlparser-archetypeinternalref/15613 --- ## Post #1 by @system Hi, I think I found something strange in the ADL-parser. See following ADL: `attribute3 matches {` `use_node SECTION /items[at0001]` `use_node SECTION /items[at0002]` `}` `attribute4 cardinality matches {0..*} matches {` `use_node SECTION[at0006] /items[at0002]` `use_node SECTION[at0005] /items[at0001]` `}` The nodes where pointed to, exist, they look like this `items cardinality matches {0..*} matches {` `SECTION[at0001] occurrences matches {0..1} matches {*}` `SECTION[at0002] occurrences matches {1..2} matches {*}` `}` When I parse this, I come to following questions At /attribute3, it only occurs once in the Archetype's->pathNodeMap. I think that one entry is overwritten by the next, because the path's are the same This is a faulty entry in the archetype. But /attribute4 is parsed wrong I think. It should occur twice in the pathNodeMap because the path's shoudl be different. But they do not. And that is because the archetype_node_id is not taken into account. There should, in my opinion, have been two paths /attribute4[at0006] /attribute4[at0007] So if I am right, there is a bug in the code in ADL.jj which parses internal-refs, it should add the node_id's Can someone please comment on this. Repairing may not be that hard Thanks Bert Verhees --- ## Post #2 by @yampeku I think that could be related to the parser assuming that Internal References have no atxxxx code (which they can according to the specifications) --- ## Post #3 by @system The NodeId is detected but it was forgotten to add it to the path, like is done in c_complex_object. It was taken into account that there can be a nodeId, and it is read also, but it is forgotten to add it to the path, for example, like is done in c_complex_object in adl.jj As I expected, easy to repair. The function archetype_internal_ref in adl.jj should be rewritten like this. I tested it. I see that I have the right to do so. So I think, I just do so, if someone complains, it is easy to restore the old version. ArchetypeInternalRef archetype_internal_ref(String path, CAttribute parent) : { String type; Interval occurrences = new Interval(1, 1); String target; String nodeID = null; } { type = type_identifier() [ nodeID = constraint_ref() ] [ occurrences = c_occurrences() ] { if(path == null) { path = "/"; } else { path += (nodeID == null ? "" : "[" + nodeID + "]"); } } target = absolute_path() { return new ArchetypeInternalRef(path, type, occurrences, nodeID, parent, target); } } Thanks Diego I see that --- **Canonical:** https://discourse.openehr.org/t/adlparser-archetypeinternalref/15613 **Original content:** https://discourse.openehr.org/t/adlparser-archetypeinternalref/15613