Published on :
Reporting CREATION_INTERNE

Creating an ODS Tagset for Multiple Stylesheets

This code is also available in: Deutsch Español Français
This program uses the TEMPLATE procedure to define a new 'tagset' (tagsets.multi_url). The goal is to override the default behavior of the 'stylesheet_link' event to allow the inclusion of multiple stylesheet (CSS) URLs, separated by spaces, generating an HTML <link> tag for each of them.
Data Analysis

Type : CREATION_INTERNE


The code does not read any external or internal data sources (SAS tables). It acts on the ODS output structure.

1 Code Block
PROC TEMPLATE
Explanation :
Definition of the tagset structure. The 'stylesheet_link' event initializes a loop ('urlLoop') that iterates through the provided URL string, splits it by spaces, and triggers the 'link' event to generate the appropriate HTML code for each CSS file.
Copied!
1PROC TEMPLATE;
2
3 
4 define tagset tagsets.multi_url;
5 
6 define event stylesheet_link;
7 break /IF !exists(url);
8 SET $urlList url;
9 trigger urlLoop ;
10 unset $urlList;
11 END;
12 
13 define event link;
14 putq '<link rel="stylesheet" type="text/css" href=' $current_url; '>' nl;
15 END;
16 
17 define event urlLoop;
18 eval $space_pos index($urlList, " ");
19 
20 DO /while $space_pos ne 0;
21 
22 SET $current_url substr($urlList,1,$space_pos);
23 SET $current_url trim($current_url);
24 
25 trigger link;
26 
27 SET $urlList substr($urlList,$space_pos);
28 SET $urlList strip($urlList);
29 
30 eval $space_pos index($urlList, " ");
31 done;
32 
33 /* when space_pos is 0 it's either the only link or the last link */
34 SET $current_url $urlList;
35 trigger link;
36 END;
37 END;
38RUN;
2 Code Block
ODS
Explanation :
Instantiation of the ODS destination using the previously defined tagset. The output file 'multi_url_out.txt' is specified, and a list of three CSS files is passed to the 'stylesheet' parameter.
Copied!
1ods tagsets.multi_url file="multi_url_out.txt" stylesheet=(url="file1.css file2.css file3.css");
2ods tagsets.multi_url close;
3 
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.