Commit 7645938b authored by Andreas Zwinkau's avatar Andreas Zwinkau

Update rdfref

Fixes a bug with missing links.
parent 228abcca
......@@ -22,23 +22,52 @@
}
\newcommand\SetProperty[3]{%
\protected@csxdef{rdf@#1@#2}{#3}%
% \protected@csxdef{rdf@#1@#2}{#3}%
\listcsxadd{rdf@#1@#2}{#3}%
}
\newcommand\IfProperty[2]{%
\ifcsdef{rdf@#1@#2}%
}
% we use etoolbox's list to store property array
% character | is used to delimit the records, it has
% changed catcode, so we must do some trickery to parse
% it correctly
\@tempcnta=\the\catcode`\|
\catcode`\|=3
\def\MatchFirstProperty#1|#2\@nil{#1}
\newcommand\GetFirstProperty[1]{%
\MatchFirstProperty#1|\@nil
}
\catcode`\|=\the\@tempcnta
% Object can have multiple occassions of an property,
% we get only the first one with \GetProperty command
% You need to use looping commands to get also the other
% values
\newcommand\GetProperty[2]{%
\IfProperty{#1}{#2}{%
\csuse{rdf@#1@#2}%
}{%
\PropertyNotDef{#1}{#2}%
}%
\IfProperty{#1}{#2}{%
\edef\@temp{\csname rdf@#1@#2\endcsname}%
\expandafter\GetFirstProperty\expandafter{\@temp}%
}{%
\PropertyNotDef{#1}{#2}%
}%
}
\newcommand\PropertyNotDef[2]{%
???%
%\typeout{rdf warning: subject #1 has no property #2}%
\typeout{rdf warning: subject #1 has no property #2}%
}
% #1 object, #2 property
\newcommand\MapObjectList[3]{%
\def\do##1{#3}%
\ifcsdef{rdf@#1@#2}{%
\dolistcsloop{rdf@#1@#2}%
}{}%
}
\edef\Hash{\string#}
\newcommand\Prefix[2]{%
......@@ -51,14 +80,15 @@
\csgdef{rdfprefix@#1}{#2}%
}
}
\newcommand\SubjectListAdd[2]{%
\listcsgadd{sbjlst@#1}{#2}%
\newcommand\SubjectListAdd[3]{%
\listcsgadd{sbjlst@#1}{{#2}{#3}}%
}
\newcommand\MapSubjectList[2]{%
\def\do##1{#2}%
\ifcsdef{sbjlst@#1}{%
\dolistcsloop{sbjlst@#1}%
}{}%
% \def\tmp@sbj{\MapObjectList{
\def\do##1{#2}%
\ifcsdef{sbjlst@#1}{%
\dolistcsloop{sbjlst@#1}%
}{}%
}
\newcommand\PropertyListAdd[3]{%
......@@ -74,7 +104,7 @@
\newcommand\LoadTriple[3]{%
\SetProperty{#1}{#2}{#3}%
\SubjectListAdd{#1}{#2}%
\SubjectListAdd{#1}{#2}{#3}%
\PropertyListAdd{#1}{#2}{#3}%
}
......
......@@ -62,20 +62,25 @@
}%
}
\DeclareQueryProcessor{llv}{%
\def\Value##1{##1}%
\def\Var##1{##1}%
\IfProperty{\subject}{\predicate}{%
\SaveVal\object{\GetProperty{\subject}{\predicate}}
\continue}{}
\def\Value##1{##1}%
\def\Var##1{##1}%
% Subject can have multiple values of property, so we need to loop over them
\MapPropertyList\predicate{%
\IfStrEq\subject{\ifx\\##1\\\else\First##1\fi}{%
\SaveVal\object{\ifx\\##1\\\else\Second##1\fi}%
\continue}{}%
}%
}%
\DeclareQueryProcessor{lvv}{%
\def\Value##1{##1}%
\def\Var##1{##1}%
\MapSubjectList\subject{%
\SaveVal\predicate{##1}%
\SaveVal\object{\GetProperty{\subject}{##1}}%
\SaveVal\predicate{\ifx\\##1\\\else\First##1\fi}%
\SaveVal\object{\ifx\\##1\\\else\Second##1\fi}%
\continue%
}%
}
......@@ -84,8 +89,9 @@
\def\Value##1{##1}%
\def\Var##1{##1}%
\MapSubjectList\subject{%
\IfStrEq{\GetProperty{\subject}{##1}}{\object}{%
\SaveVal\predicate{##1}%
% \IfStrEq{\GetProperty{\subject}{##1}}{\object}{%
\IfStrEq{\ifx\\##1\\\else\Second##1\fi}{\object}{%
\SaveVal\predicate{\ifx\\##1\\\else\First##1\fi}%
\continue%
}{}%
}%
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment