rdfref-core.sty 1.72 KB
Newer Older
Andreas Zwinkau's avatar
initial  
Andreas Zwinkau committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
\ProvidesPackage{rdfref-core}
\RequirePackage{etoolbox,xstring}
\def\Nil{}%
\def\First#1#2{#1}
\def\Second#1#2{#2}

\def\parsecolon#1:#2\relax{\ifx#2\Nil\Nil\else#1\fi}%
\newcommand\RdfPrefix[1]{%
\parsecolon#1:\Nil\relax%
}
\newcommand\AddTriple[3]{%
%\edef\rdf@object{#3}
\immediate\write\@auxout{\noexpand\LoadTriple{#1}{#2}{\expandafter\detokenize\expandafter{#3}}}%
%\immediate\write\@auxout{\noexpand\LoadTriple{#1}{#2}{\rdf@object}}
}

% If we need to write something expanded, like \thepage
\newcommand\AddTripleEx[3]{%
% \edef\rdf@object{#3}%
% \immediate\write\@auxout{\noexpand\LoadTriple{#1}{#2}{\rdf@object}}%
\protected@write\@auxout{}{\protect\LoadTriple{#1}{#2}{#3}}
}

\newcommand\SetProperty[3]{%
\protected@csxdef{rdf@#1@#2}{#3}%
}

\newcommand\IfProperty[2]{%
\ifcsdef{rdf@#1@#2}%
}
\newcommand\GetProperty[2]{%
\IfProperty{#1}{#2}{%
\csuse{rdf@#1@#2}%
}{%
\PropertyNotDef{#1}{#2}%
}%
}
\newcommand\PropertyNotDef[2]{%
???%
%\typeout{rdf warning: subject #1 has no property #2}%
}
\edef\Hash{\string#}

\newcommand\Prefix[2]{%
%\edef\fuf{Prefix #2}
\ifcsdef{rdfprefix@#1}{%
\IfStrEq{\csuse{rdfprefix@#1}}{#2}{%
\typeout{Prefix #1 already exists for #2}%
}{\typeout{Prefix clash, uri #2 has already prefix \csuse{rdfprefix@#1}, #1 provided}%
}}{%
\csgdef{rdfprefix@#1}{#2}%
}
}
\newcommand\SubjectListAdd[2]{%
\listcsgadd{sbjlst@#1}{#2}%
}
\newcommand\MapSubjectList[2]{%
\def\do##1{#2}%
\ifcsdef{sbjlst@#1}{%
\dolistcsloop{sbjlst@#1}%
}{}%
}

\newcommand\PropertyListAdd[3]{%
\listcsgadd{prprtlst@#2}{{#1}{#3}}%
}
\newcommand\MapPropertyList[2]{%
\def\do##1{#2}%
\ifcsdef{prprtlst@#1}{%
\dolistcsloop{prprtlst@#1}%
}{}%
}


\newcommand\LoadTriple[3]{%
\SetProperty{#1}{#2}{#3}%
\SubjectListAdd{#1}{#2}%
\PropertyListAdd{#1}{#2}{#3}%
}