Why use の instead of が?


I know that の can be used instead of が when modifying a noun like in these
examples:

  1. 日本語のわかる人
  2. 私のできる日本語

But in these cases:

> 健康のためにあるいはリクリエーションのためにという **スポーツのある** 一方で、スポーツが仕事というプロスポーツも存在している。

> 頂点に通じる長い山道のどこを歩いているのか **の違いであり**
> 、険しさや空気の薄さは上に行くほどつらくはなるが、歩いて進むことや歩き方には変わりはない。

Why is の used here in the parts in bold？ Isn't it supposed to be が? I get the
meaning but don't understand the grammar here.




As you say の can replace が as a subject marker.

For the first sentence, just as in 1 and 2 in the question, の/が are (to an
extent) interchangeable: スポーツのある/スポーツがある are both fine.

In the second one, using が is most probably possible and won't change meaning
much. But grammatically, as noted in the comment, they are different:

The sentence as is has an implicit subject which should be what is being
discussed: (それは)...どこを歩いているのか **の** 違いであり, which literally means _It is a
matter **of** where you are walking..._.

On the other hand, using が would make _where you..._ the subject (of である）:
どこを歩いているか **が** 違いである = _Where you are walking ... **is** the difference_.
This is ok grammatically, but it sounds like emphasizing the difference and
does not seem to fit the context (the emphasis should be 変わりはない).

