# Tailf:annotate xpath printout with prefixes?

**URL:** https://dmap-community.ductus.global/t/tailf-annotate-xpath-printout-with-prefixes/4030
**Category:** YANG
**Created:** [March 19, 2022, 7:20pm UTC](https://dmap-community.ductus.global/t/tailf-annotate-xpath-printout-with-prefixes/4030 "2022-03-19T19:20:37Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![colinmc](https://avatars.discourse-cdn.com/v4/letter/c/da6949/32.png) [@colinmc](https://dmap-community.ductus.global/u/colinmc)
#### Post date: [March 19, 2022, 7:20pm UTC](https://dmap-community.ductus.global/t/tailf-annotate-xpath-printout-with-prefixes/4030/1 "2022-03-19T19:20:37Z")

</div>

I’m using tailf:annotate, with multiple namespaces and modules.

The first module “uses” a group from the 2nd. Both modules are listed in my import section with prefixes.

In my annotate line, I use the first module’s prefix to specify it, and that works, but when I use the 2nd, it says not found, although it does print the module name it was looking in, and it’s the correct module. pyang validates all the non-annotated yang files without issue.

import module a { prefix p-a; }  
// container object a, which has container object b inside, and object b “uses” group that contains object c  
import module b { prefix p-b; }  
// defines grouping that contains object c

This compiles in pyang:

tailf:annotate /p-a:-object-a/p-a:object-b {

This does not, saying it cannot find object c in the prefix b module.

tailf:annotate /p-a:-object-a/p-a:object-b/p-b:object-c {

I tried using pyang --flatten (with various options) to print the xpath with prefixes, but it prints the “top” level prefix for everything, even stuff that’s in a “sub” module.

Is there a way to get pyang to print the xpath in a format that will let me craft the correct xpath for the annotate call?

---

<div class="post-metadata">

### Author: ![mvf](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/mvf/32/182_2.png) [@mvf](https://dmap-community.ductus.global/u/mvf)
#### Post date: [March 20, 2022, 8:52pm UTC](https://dmap-community.ductus.global/t/tailf-annotate-xpath-printout-with-prefixes/4030/2 "2022-03-20T20:52:38Z")

</div>

You can use `--flatten-qualified-module-and-prefix-path`; I don’t find the output particularly readable, but it uses prefixes everywhere. But pyang is correct in your case: when you do `uses grp` in the module `a`, contents of the grouping becomes effectively inlined in your module, so the “model instance” of the container `object-c` really belongs to `a`. By `uses` alone you never get xpaths that need to change the prefix in the middle, you’d have to employ `augment` for that.

By the way: you may want to use `tailf:annotate-module` and `tailf:annotate-statement` instead of `tailf:annotate`, the two statements address module syntax tree and hence are a bit less confusing.

---

<div class="post-metadata">

### Author: ![colinmc](https://avatars.discourse-cdn.com/v4/letter/c/da6949/32.png) [@colinmc](https://dmap-community.ductus.global/u/colinmc)
#### Post date: [March 21, 2022, 2:55pm UTC](https://dmap-community.ductus.global/t/tailf-annotate-xpath-printout-with-prefixes/4030/3 "2022-03-21T14:55:10Z")

</div>

> [@mvf](#):
>
> By `uses` alone you never get xpaths that need to change the prefix in the middle, you’d have to employ `augment` for that.

That explains why it was inserting the “top” prefix everywhere with `--flatten-qualified-module-and-prefix-path`. I thought was some kind of formatting bug.

I had been using `augment` previously, and it needed different prefixes all along the xpath, but then I refactored to use `uses` instead.

Thanks for the help!

---

<div class="post-metadata">

### Author: ![colinmc](https://avatars.discourse-cdn.com/v4/letter/c/da6949/32.png) [@colinmc](https://dmap-community.ductus.global/u/colinmc)
#### Post date: [March 21, 2022, 4:50pm UTC](https://dmap-community.ductus.global/t/tailf-annotate-xpath-printout-with-prefixes/4030/4 "2022-03-21T16:50:18Z")

</div>

Everything compiles now, sort of. In the generated c header files, all my callpoints I define inside the annotates have vanished.

They’re not in the module a header, nor in the module b (they used to be in b)

---

<div class="post-metadata">

### Author: ![mvf](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/mvf/32/182_2.png) [@mvf](https://dmap-community.ductus.global/u/mvf)
#### Post date: [March 21, 2022, 5:33pm UTC](https://dmap-community.ductus.global/t/tailf-annotate-xpath-printout-with-prefixes/4030/5 "2022-03-21T17:33:54Z")

</div>

It’s not clear how you are compiling, I guess you have something wrong in this: keep in mind that the grouping/uses makes the container part of the module `a`. So you need to compile the module `a` with the `-a` option and the callpoint symbolic name should appear in `a`'s header file (and this is what happens when I test this scenario).

---

<div class="post-metadata">

### Author: ![colinmc](https://avatars.discourse-cdn.com/v4/letter/c/da6949/32.png) [@colinmc](https://dmap-community.ductus.global/u/colinmc)
#### Post date: [March 21, 2022, 6:59pm UTC](https://dmap-community.ductus.global/t/tailf-annotate-xpath-printout-with-prefixes/4030/6 "2022-03-21T18:59:47Z")

</div>

I think I figured it out, I needed to point the -a for compiling module a at the ann file I was using for module b previously, because now it’s “annotating” the path in module a.

I created a very basic test build, and that seems to have worked.
