summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tagpdf/tagpdf-roles.dtx
blob: 78dccdc02aca81851433ef3d4978a9f1580c42cd (plain)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
% \iffalse meta-comment
%
%% File: tagpdf-roles.dtx
%
% Copyright (C) 2019-2021 Ulrike Fischer
%
% It may be distributed and/or modified under the conditions of the
% LaTeX Project Public License (LPPL), either version 1.3c of this
% license or (at your option) any later version.  The latest version
% of this license is in the file
%
%    https://www.latex-project.org/lppl.txt
%
% This file is part of the "tagpdf bundle" (The Work in LPPL)
% and all files in that bundle must be distributed together.
%
% -----------------------------------------------------------------------
%
% The development version of the bundle can be found at
%
%    https://github.com/u-fischer/tagpdf
%
% for those people who are interested.
%<*driver>
\RequirePackage{pdfmanagement-testphase}
\DeclareDocumentMetadata{}
\makeatletter
\declare@file@substitution{doc.sty}{doc-v3beta.sty}
\makeatother
\documentclass{l3doc}
\usepackage{array,booktabs,caption}
\hypersetup{pdfauthor=Ulrike Fischer,
 pdftitle=tagpdf-checks module (tagpdf)}
\begin{document}
  \DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
% \title{^^A
%   The \pkg{tagpdf-roles} module\\ Tags, roles and namesspace code   ^^A
%   \\ Part of the tagpdf package
% }
%
% \author{^^A
%  Ulrike Fischer\thanks
%    {^^A
%      E-mail:
%        \href{mailto:fischer@troubleshooting-tex.de}
%          {fischer@troubleshooting-tex.de}^^A
%    }^^A
% }
%
% \date{Version 0.92, released 2021-08-27}
% \maketitle
% \begin{implementation}
%    \begin{macrocode}
%<@@=tag>
%<*header>
\ProvidesExplPackage {tagpdf-roles-code} {2021-08-27} {0.92}
 {part of tagpdf - code related to roles and structure names}
%</header>
%    \end{macrocode}
% \section{Code related to roles and structure names}
% \subsection{Variables}
% Tags have both a name (a string) and a number (for the lua attribute).
% Testing a name is easier with a prop, while accessing with a number is
% better done with a seq. So both are used and must be kept in sync if a new
% tag is added. The number is only relevant for the MC type, tags with the same
% name from different names spaces can have the same number.
% \begin{variable}{\g_@@_role_tags_seq,\g_@@_role_tags_prop}
%    \begin{macrocode}
%<*package>
\@@_seq_new:N  \g_@@_role_tags_seq  %to get names (type/NS) from numbers
\@@_prop_new:N \g_@@_role_tags_prop %to get numbers  from names (type/NS)
%    \end{macrocode}
% \end{variable}
% \begin{variable}{\g_@@_role_tags_NS_prop}
% in pdf 2.0 tags belong to a name space. For every tag we store a default
% name space.
% The keys are the tags, the value shorthands like pdf2, or mathml.
% There is no need to access this from lua, so we use the standard prop commands.
%    \begin{macrocode}
\prop_new:N    \g_@@_role_tags_NS_prop %to namespace info
%    \end{macrocode}
% \end{variable}
% \begin{variable}{\g_@@_role_NS_prop}
% The standard names spaces are the following. The keys are the name
% tagpdf will use,  the urls are the identifier in the namespace object.
% \begin{description}
% \item[mathml] http://www.w3.org/1998/Math/MathML
% \item[pdf2]   http://iso.org/pdf2/ssn
% \item[pdf]    http://iso.org/pdf/ssn (default)
% \item[user]   \cs{c_@@_role_userNS_id_str} (random id, for user tags)
% \end{description}
% More namespaces are possible and
% their objects references and the ones of the namespaces must be collected
% so that an array can be written to the StructTreeRoot at the end (see tagpdf-tree).
% We use a prop to store also the object reference as it will be needed rather
% often.
%    \begin{macrocode}
\prop_new:N \g_@@_role_NS_prop % collect namespaces
%    \end{macrocode}
% \end{variable}
%
% We need also a bunch of temporary variables:
% \begin{variable}
%  {
%     \l_@@_role_tag_tmpa_tl
%     ,\l_@@_role_tag_namespace_tmpa_tl
%     ,\l_@@_role_role_tmpa_tl
%     ,\l_@@_role_role_namespace_tmpa_tl
%  }
%    \begin{macrocode}
\tl_new:N \l_@@_role_tag_tmpa_tl
\tl_new:N \l_@@_role_tag_namespace_tmpa_tl
\tl_new:N \l_@@_role_role_tmpa_tl
\tl_new:N \l_@@_role_role_namespace_tmpa_tl
%    \end{macrocode}
% \end{variable}
% \subsection{Namesspaces}
% The following commands setups a names space. Namespace dictionaries can
% contain an optional |/Schema| and |/RoleMapNS| entry. We only reserve the
% objects but delay the writing to the finish code, where we can test if the
% keys and the name spaces are actually needed
% This commands setups objects for the name space and its rolemap. It also
% initialize a prop to collect the rolemaps if needed.
% \begin{function}{\@@_role_NS_new:nnn}
%  \begin{syntax}
%   \cs{@@_role_NS_new:nnn}\Arg{shorthand}\Arg{URI-ID}{Schema}
%  \end{syntax}
% \end{function}
% \begin{macro}{\@@_role_NS_new:nnn}
%    \begin{macrocode}
\cs_new_protected:Npn \@@_role_NS_new:nnn #1 #2 #3
  {
    \pdf_object_new:nn {tag/NS/#1}{dict}
    \pdfdict_new:n     {g_@@_role/Namespace_#1_dict}
    \pdf_object_new:nn {@@/RoleMapNS/#1}{dict}
    \pdfdict_new:n     {g_@@_role/RoleMapNS_#1_dict}
    \pdfdict_gput:nnn
      {g_@@_role/Namespace_#1_dict}
      {Type}
      {/Namespace}
    \pdf_string_from_unicode:nnN{utf8/string}{#2}\l_tmpa_str
    \tl_if_empty:NF \l_tmpa_str
      {
        \pdfdict_gput:nnx
          {g_@@_role/Namespace_#1_dict}
          {NS}
          {\l_tmpa_str}
      }
    %RoleMapNS is added in tree
    \tl_if_empty:nF  {#3}
     {
       \pdfdict_gput:nnx{g_@@_role/Namespace_#1_dict}
        {Schema}{#3}
     }
    \prop_gput:Nnx \g_@@_role_NS_prop {#1}{\pdf_object_ref:n{tag/NS/#1}~}
  }
%    \end{macrocode}
% \end{macro}
% We need an id for the user space. For the tests it should be possible
% to set it to a fix value. So we use random numbers which can
% be fixed by setting a seed. We fake a sort of
% GUID but not try to be really exact as it doesn't matter ...
%
% \begin{variable}{\c_@@_role_userNS_id_str}
%    \begin{macrocode}
\str_const:Nx \c_@@_role_userNS_id_str
  { data:,
    \int_to_Hex:n{\int_rand:n {65535}}
    \int_to_Hex:n{\int_rand:n {65535}}
    -
    \int_to_Hex:n{\int_rand:n {65535}}
    -
    \int_to_Hex:n{\int_rand:n {65535}}
    -
    \int_to_Hex:n{\int_rand:n {65535}}
    -
    \int_to_Hex:n{\int_rand:n {16777215}}
    \int_to_Hex:n{\int_rand:n {16777215}}
  }
%    \end{macrocode}
% \end{variable}
% Now we setup the standard names spaces. Currently only if we detect pdf2.0 but
% this will perhaps have to change if the structure code gets to messy.
%    \begin{macrocode}
\pdf_version_compare:NnT > {1.9}
  {
    \@@_role_NS_new:nnn {pdf}   {http://iso.org/pdf/ssn}{}
    \@@_role_NS_new:nnn {pdf2}  {http://iso.org/pdf2/ssn}{}
    \@@_role_NS_new:nnn {mathml}{http://www.w3.org/1998/Math/MathML}{}
    \exp_args:Nnx
    \@@_role_NS_new:nnn {user}{\c_@@_role_userNS_id_str}{}
  }
%    \end{macrocode}
%
% \subsection{Data}
% In this section we setup the standard data.
% At first the list of structure types. We split them in three lists,
% the tags with which are both in the pdf and pdf2 namespace,
% the one only in pdf and the one with the tags only in pdf2.
% We also define a rolemap for the pdfII only type to pdf so that
% they can always be used.
% \begin{variable}
%   {
%     \c_@@_role_sttags_pdf_pdfII_clist,
%     \c_@@_role_sttags_only_pdf_clist,
%     \c_@@_role_sttags_only_pdfII_clist,
%     \c_@@_role_sttags_mathml_clist,
%     \c_@@_role_sttags_pdfII_to_pdf_prop
%   }
%    \begin{macrocode}
%
\clist_const:Nn \c_@@_role_sttags_pdf_pdfII_clist
  {
    Document,   %A complete document. This is the root element
                %of any structure tree containing
                %multiple parts or multiple articles.
    Part,       %A large-scale division of a document.
    Sect,       %A container for grouping related content elements.
    Div,        %A generic block-level element or group of elements
    Caption,    %A brief portion of text describing a table or figure.
    Index,
    NonStruct,  %probably not needed
    H,
    H1,
    H2,
    H3,
    H4,
    H5,
    H6,
    P,
    L,           %list
    LI,          %list item (around label and list item body)
    Lbl,         %list label
    LBody,       %list item body
    Table,
    TR,          %table row
    TH,          %table header cell
    TD,          %table data cell
    THead,       %table header (n rows)
    TBody,       %table rows
    TFoot,       %table footer
    Span,        %generic inline marker
    Link,        %
    Annot,
    Figure,
    Formula,
    Form,
    % ruby warichu etc ..
    Ruby,
    RB,
    RT,
    Warichu,
    WT,
    WP,
    Artifact % only MC-tag ?...
  }

\clist_const:Nn \c_@@_role_sttags_only_pdf_clist
 {
   Art,        %A relatively self-contained body of text
               %constituting a single narrative or exposition
   BlockQuote, %A portion of text consisting of one or more paragraphs
               %attributed to someone other than the author of the
               %surrounding text.
   TOC,        %A list made up of table of contents item entries
               %(structure tag TOCI; see below) and/or other
               %nested table of contents entries
   TOCI,       %An individual member of a table of contents.
               %This entry's children can be any of the following structure  tags:
               %Lbl,Reference,NonStruct,P,TOC
   Index,
   Private,
   Quote,       %inline quote
   Note,        %footnote, endnote. Lbl can be child
   Reference,   %A citation to content elsewhere in the document.
   BibEntry,    %bibentry
   Code
 }

\clist_const:Nn \c_@@_role_sttags_only_pdfII_clist
 {
   DocumentFragment
   ,Aside
   ,H7
   ,H8
   ,H9
   ,H10
   ,Title
   ,FENote
   ,Sub
   ,Em
   ,Strong
   ,Artifact
 }

\clist_const:Nn \c_@@_role_sttags_mathml_clist
 {
   abs
   ,and
   ,annotation
   ,apply
   ,approx
   ,arccos
   ,arccosh
   ,arccot
   ,arccoth
   ,arccsc
   ,arccsch
   ,arcsec
   ,arcsech
   ,arcsin
   ,arcsinh
   ,arctan
   ,arctanh
   ,arg
   ,bind
   ,bvar
   ,card
   ,cartesianproduct
   ,cbytes
   ,ceiling
   ,cerror
   ,ci
   ,cn
   ,codomain
   ,complexes
   ,compose
   ,condition
   ,conjugate
   ,cos
   ,cosh
   ,cot
   ,coth
   ,cs
   ,csc
   ,csch
   ,csymbol
   ,curl
   ,declare
   ,degree
   ,determinant
   ,diff
   ,divergence
   ,divide
   ,domain
   ,domainofapplication
   ,emptyset
   ,eq
   ,equivalent
   ,eulergamma
   ,exists
   ,exp
   ,exponentiale
   ,factorial
   ,factorof
   ,false
   ,floor
   ,fn
   ,forall
   ,gcd
   ,geq
   ,grad
   ,gt
   ,ident
   ,image
   ,imaginary
   ,imaginaryi
   ,implies
   ,in
   ,infinity
   ,int
   ,integers
   ,intersect
   ,interval
   ,inverse
   ,lambda
   ,laplacian
   ,lcm
   ,leq
   ,limit
   ,ln
   ,log
   ,logbase
   ,lowlimit
   ,lt
   ,maction
   ,maligngroup
   ,malignmark
   ,math
   ,matrix
   ,matrixrow
   ,max
   ,mean
   ,median
   ,menclose
   ,merror
   ,mfenced
   ,mfrac
   ,mglyph
   ,mi
   ,min
   ,minus
   ,mlabeledtr
   ,mlongdiv
   ,mmultiscripts
   ,mn
   ,mo
   ,mode
   ,moment
   ,momentabout
   ,mover
   ,mpadded
   ,mphantom
   ,mprescripts
   ,mroot
   ,mrow
   ,ms
   ,mscarries
   ,mscarry
   ,msgroup
   ,msline
   ,mspace
   ,msqrt
   ,msrow
   ,mstack
   ,mstyle
   ,msub
   ,msubsup
   ,msup
   ,mtable
   ,mtd
   ,mtext
   ,mtr
   ,munder
   ,munderover
   ,naturalnumbers
   ,neq
   ,none
   ,not
   ,notanumber
   ,notin
   ,notprsubset
   ,notsubset
   ,or
   ,otherwise
   ,outerproduct
   ,partialdiff
   ,pi
   ,piece
   ,piecewise
   ,plus
   ,power
   ,primes
   ,product
   ,prsubset
   ,quotient
   ,rationals
   ,real
   ,reals
   ,reln
   ,rem
   ,root
   ,scalarproduct
   ,sdev
   ,sec
   ,sech
   ,selector
   ,semantics
   ,sep
   ,set
   ,setdiff
   ,share
   ,sin
   ,sinh
   ,subset
   ,sum
   ,tan
   ,tanh
   ,tendsto
   ,times
   ,transpose
   ,true
   ,union
   ,uplimit
   ,variance
   ,vector
   ,vectorproduct
   ,xor
 }

\prop_const_from_keyval:Nn \c_@@_role_sttags_pdfII_to_pdf_prop
  {
    DocumentFragment = Art,
    Aside = Note,
    Title = H1,
    Sub   = Span,
    H7    = H6 ,
    H8    = H6 ,
    H9    = H6 ,
    H10   = H6,
    FENote= Note,
    Em    = Span,
    Strong= Span,
  }
%    \end{macrocode}
% \end{variable}
% We fill the structure tags in to the seq. We allow all pdf1.7 and pdf2.0,
% and role map if needed the 2.0 tags.
%    \begin{macrocode}
% get tag name from number: \seq_item:Nn \g_@@_role_tags_seq { n }
% get tag number from name: \prop_item:Nn \g_@@_role_tags_prop { name }

\clist_map_inline:Nn \c_@@_role_sttags_pdf_pdfII_clist
  {
    \@@_seq_gput_right:Nn \g_@@_role_tags_seq { #1 }
    \prop_gput:Nnn \g_@@_role_tags_NS_prop    { #1 }{ pdf2 }
  }
\clist_map_inline:Nn \c_@@_role_sttags_only_pdf_clist
  {
    \@@_seq_gput_right:Nn \g_@@_role_tags_seq { #1 }
    \prop_gput:Nnn \g_@@_role_tags_NS_prop    { #1 }{ pdf }
  }
\clist_map_inline:Nn \c_@@_role_sttags_only_pdfII_clist
  {
    \@@_seq_gput_right:Nn \g_@@_role_tags_seq { #1 }
    \prop_gput:Nnn \g_@@_role_tags_NS_prop    { #1 }{ pdf2 }
  }
\pdf_version_compare:NnT > {1.9}
  {
     \clist_map_inline:Nn \c_@@_role_sttags_mathml_clist
       {
         \@@_seq_gput_right:Nn \g_@@_role_tags_seq { #1 }
         \prop_gput:Nnn \g_@@_role_tags_NS_prop    { #1 }{ mathml }
       }
  }
%    \end{macrocode}
% For luatex and the MC we need a name/number relation.
% The name space is not relevant.
%    \begin{macrocode}
\int_step_inline:nnnn { 1 }{ 1 }{ \seq_count:N \g_@@_role_tags_seq }
  {
    \@@_prop_gput:Nxn \g_@@_role_tags_prop
      {
        \seq_item:Nn \g_@@_role_tags_seq  { #1 }
      }
      { #1 }
  }
%    \end{macrocode}
%
% \subsection{Adding new tags and rolemapping}
%
% \subsubsection{pdf 1.7 and earlier}
% With this versions only RoleMap is filled.
% At first the dictionary:
% \begin{variable}{g_@@_role/RoleMap_dict}
%    \begin{macrocode}
\pdfdict_new:n {g_@@_role/RoleMap_dict}
%    \end{macrocode}
% \end{variable}
% \begin{macro}{\@@_role_add_tag:nn}
% The pdf 1.7 version has only two arguments: new and rolemap name.
% To make pdf 2.0 types usable we directly define a rolemapping for them.
%
%    \begin{macrocode}
\cs_new_protected:Nn \@@_role_add_tag:nn %(new) name, reference to old
  {
    \prop_if_in:NnF \g_@@_role_tags_prop {#1}
      {
        \int_compare:nNnT {\l_@@_loglevel_int} > { 0 }
          {
            \msg_info:nnn { tag }{new-tag}{#1}
          }
         \@@_seq_gput_right:Nn \g_@@_role_tags_seq { #1 }
         \@@_prop_gput:Nnx \g_@@_role_tags_prop    { #1 }
           {
             \seq_count:N \g_@@_role_tags_seq
           }
         \prop_gput:Nnn \g_@@_role_tags_NS_prop    { #1 }{ user }
      }
    \@@_check_add_tag_role:nn {#1}{#2}
    \tl_if_empty:nF { #2 }
      {
        \pdfdict_gput:nnx {g_@@_role/RoleMap_dict}
          {#1}
          {\pdf_name_from_unicode_e:n{#2}}
      }
  }
\cs_generate_variant:Nn \@@_role_add_tag:nn {VV}

\pdf_version_compare:NnT < {2.0}
  {
     \prop_map_inline:Nn \c_@@_role_sttags_pdfII_to_pdf_prop
       {
         \@@_role_add_tag:nn {#1}{#2}
       }
  }

%    \end{macrocode}
% \end{macro}
% \subsubsection{The pdf 2.0 version}
% \begin{macro}{\@@_role_add_tag:nnnn}
% The pdf 2.0 version takes four arguments:
% tag/namespace/role/namespace
%    \begin{macrocode}
\cs_new_protected:Nn \@@_role_add_tag:nnnn %tag/namespace/role/namespace
  {
    \int_compare:nNnT {\l_@@_loglevel_int} > { 0 }
      {
        \msg_info:nnn { tag }{new-tag}{#1}
      }
    \@@_seq_gput_right:Nn \g_@@_role_tags_seq { #1 }
    \@@_prop_gput:Nnx \g_@@_role_tags_prop    { #1 }
       {
         \seq_count:N \g_@@_role_tags_seq
       }
    \prop_gput:Nnn \g_@@_role_tags_NS_prop    { #1 }{ #2 }
    \@@_check_add_tag_role:nn {#1}{#3}
    \pdfdict_gput:nnx {g_@@_role/RoleMapNS_#2_dict}{#1}
       {
         [
           \pdf_name_from_unicode_e:n{#3}
           \c_space_tl
           \pdf_object_ref:n {tag/NS/#4}
         ]
       }
   }
\cs_generate_variant:Nn \@@_role_add_tag:nnnn {VVVV}
%    \end{macrocode}
% \end{macro}
% \subsection{Key-val user interface}
%  The user interface use the key |add-new-tag|, which takes either a
%  keyval list as argument, or a tag/role.
%  \begin{macro}{tag,tag-namespace,role,role-namespace,add-new-tag}
%    \begin{macrocode}
\keys_define:nn { @@ / tag-role }
  {
    ,tag .tl_set:N = \l_@@_role_tag_tmpa_tl
    ,tag-namespace  .tl_set:N = \l_@@_role_tag_namespace_tmpa_tl
    ,role .tl_set:N = \l_@@_role_role_tmpa_tl
    ,role-namespace .tl_set:N = \l_@@_role_role_namespace_tmpa_tl
  }

\keys_define:nn { @@ / setup }
  {
    add-new-tag .code:n =
     {
       \keys_set_known:nnnN
         {@@/tag-role}
         {
           tag-namespace=user,
           role-namespace=, %so that we can test for it.
          #1
         }{@@/tag-role}\l_tmpa_tl
       \tl_if_empty:NF \l_tmpa_tl
         {
           \exp_args:NNno \seq_set_split:Nnn \l_tmpa_seq { / } {\l_tmpa_tl/}
           \tl_set:Nx \l_@@_role_tag_tmpa_tl  { \seq_item:Nn \l_tmpa_seq {1} }
           \tl_set:Nx \l_@@_role_role_tmpa_tl { \seq_item:Nn \l_tmpa_seq {2} }
         }
      \tl_if_empty:NT \l_@@_role_role_namespace_tmpa_tl
         {
           \prop_get:NVNTF
             \g_@@_role_tags_NS_prop
             \l_@@_role_role_tmpa_tl
             \l_@@_role_role_namespace_tmpa_tl
             {
                \prop_if_in:NVF\g_@@_role_NS_prop \l_@@_role_role_namespace_tmpa_tl
                 {
                   \tl_set:Nn \l_@@_role_role_namespace_tmpa_tl {user}
                 }
             }
             {
               \tl_set:Nn \l_@@_role_role_namespace_tmpa_tl {user}
             }
         }
      \pdf_version_compare:NnTF < {2.0}
       {
        %TODO add check for emptyness?
          \@@_role_add_tag:VV
              \l_@@_role_tag_tmpa_tl
              \l_@@_role_role_tmpa_tl
       }
       {
         \@@_role_add_tag:VVVV
           \l_@@_role_tag_tmpa_tl
           \l_@@_role_tag_namespace_tmpa_tl
           \l_@@_role_role_tmpa_tl
           \l_@@_role_role_namespace_tmpa_tl
       }
    }
  }
%</package>
%    \end{macrocode}
% \end{macro}
% \end{implementation}
% \PrintIndex