code: def yang_to_xpath(self, xpe):
          
          if self.gg_level:
              pref = "$pref:"
          else:
              pref = self.prefix_stack[-1] + ":"
          toks = xpath_lexer.scan(xpe)
          prev = None
          res = ""
          for tok in toks:
              if (tok.type == "SLASH" and
                  prev not in ("DOT", "DOTDOT", "RPAREN", "RBRACKET", "name",
                               "wildcard", "prefix_test")):
                  res += "$root"
              elif tok.type == "name" and ":" not in tok.value:
                  res += pref
              res += tok.value
              if tok.type != "_whitespace": prev = tok.type
          return res
docs: Transform YANG's `xpath` to a form suitable for Schematron.
  
          1. Prefixes are added to unprefixed local names. Inside global
             groupings, the prefix is represented as the variable
             '$pref' which is substituted via Schematron abstract
             patterns.
          2. '$root' is prepended to every absolute location path.