I am confused as to why the edef below does not get expanded in the link?
The \GetTexFilePath is from Text being output when none should be, which is expandable, and the \GetTexFilePathOld is the older version which is not. Both yield identical results in this case.
I attempted various \expandafter magic but could not figure out the correct combination.
\documentclass{article}
\usepackage{xstring}
\usepackage{xparse}
\usepackage{hyperref}
\ExplSyntaxOn
\NewDocumentCommand{\GetTexFilePath}{m m m}{% Expandable version
\str_if_eq:xxTF{#1}{SpecialValue}{#1/#2#3}{../#1/#2#3}%
}%
\ExplSyntaxOff
\NewDocumentCommand{\GetTexFilePathOld}{m m m}{%
\IfStrEq{#1}{SpecialValue}{#1/#2#3}{../#1/#2#3}%
}%
\begin{document}
\edef\FullExpandedFileName{\GetTexFilePath{foo}{bar}{.tex}}
\href{run:\FullExpandedFileName}{\GetTexFilePath{foo}{bar}{}}
%
\edef\FullExpandedFileName{\GetTexFilePathOld{foo}{bar}{.tex}}
\href{run:\FullExpandedFileName}{\GetTexFilePathOld{foo}{bar}{}}
\edef\FullExpandedFileName{\GetTexFilePath{SpecialValue}{bar}{.tex}}
\href{run:\FullExpandedFileName}{\GetTexFilePath{SpecialValue}{bar}{}}
%
\edef\FullExpandedFileName{\GetTexFilePathOld{SpecialValue}{bar}{.tex}}
\href{run:\FullExpandedFileName}{\GetTexFilePathOld{SpecialValue}{bar}{}}
\end{document}
\edef, it is simpler to do\expandafter\empty\yourcommand, so\edef\FullExpandedFileName{\expandafter\empty\GetTeXFilePath...}. – Bruno Le Floch Feb 08 '12 at 23:19