Imported Upstream version 1.77.1
[platform/upstream/docbook-xsl-stylesheets.git] / assembly / assemble.xsl
1 <?xml version="1.0" encoding="utf-8"?>
2 <xsl:stylesheet 
3   xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
4   xmlns:exsl="http://exslt.org/common"
5   xmlns:xlink="http://www.w3.org/1999/xlink"
6   xmlns="http://docbook.org/ns/docbook"
7   exclude-result-prefixes="exsl d xlink"
8   version="1.0">
9
10 <!-- $Id: assemble.xsl,v 1.10 2012-04-10 07:56:58 bobs Exp $ -->
11
12 <xsl:preserve-space elements="*"/>
13 <xsl:strip-space elements="d:assembly d:structure d:module d:resources d:resource"/>
14
15 <xsl:key name="id" match="*" use="@id|@xml:id"/>
16
17
18 <xsl:param name="docbook.version">5.0</xsl:param>
19 <xsl:param name="root.default.renderas">book</xsl:param>
20 <xsl:param name="topic.default.renderas">section</xsl:param>
21
22 <xsl:param name="output.type" select="''"/>
23 <xsl:param name="output.format" select="''"/>
24 <!-- May be used to select one structure among several to  process -->
25 <xsl:param name="structure.id" select="''"/>
26
27
28 <!-- default mode is to copy all content nodes -->
29 <xsl:template match="node()|@*" priority="-5" mode="copycontent">
30   <xsl:param name="omittitles"/>
31     <xsl:copy>
32       <xsl:apply-templates select="@*" mode="copycontent"/>
33       <xsl:apply-templates mode="copycontent">
34         <xsl:with-param name="omittitles" select="$omittitles"/>
35       </xsl:apply-templates>
36    </xsl:copy>
37 </xsl:template>
38
39 <xsl:template match="processing-instruction('oxygen')"/>
40
41 <!-- skip assembly info elements -->
42 <xsl:template match="d:info"/>
43
44 <!-- including for structure info element -->
45 <xsl:template match="d:structure/d:info"/>
46
47 <!-- handle omittitles, but only top level title of resource -->
48 <xsl:template match="/*/d:title 
49                    | /*/d:info/d:title 
50                    | /*/d:subtitle  
51                    | /*/d:info/d:subtitle
52                    | /*/d:titleabbrev  
53                    | /*/d:info/d:titleabbrev"
54               mode="copycontent">
55   <xsl:param name="omittitles"/>
56
57   <xsl:choose>
58     <xsl:when test="$omittitles = 'yes' or $omittitles = 'true' or $omittitles = '1'">
59       <!-- omit it -->
60     </xsl:when>
61     <xsl:otherwise>
62       <xsl:copy>
63         <xsl:apply-templates select="@*" mode="copycontent"/>
64         <xsl:apply-templates mode="copycontent"/>
65       </xsl:copy>
66     </xsl:otherwise>
67   </xsl:choose>
68 </xsl:template>
69
70 <!-- handled in a mode -->
71 <xsl:template match="d:resources"/>
72 <xsl:template match="d:output|d:filterin|d:filterout|d:merge|d:revhistory"/>
73 <xsl:template match="d:output|d:filterin|d:filterout|d:merge|d:revhistory"
74               mode="copycontent"/>
75
76 <xsl:template match="d:assembly">
77   <xsl:choose>
78     <xsl:when test="$structure.id != ''">
79       <xsl:variable name="id.structure" select="key('id', $structure.id)"/>
80       <xsl:choose>
81         <xsl:when test="count($id.structure) = 0">
82           <xsl:message terminate="yes">
83             <xsl:text>ERROR: structure.id param set to '</xsl:text>
84             <xsl:value-of select="$structure.id"/>
85             <xsl:text>' but no element with that xml:id exists in assembly.</xsl:text>
86           </xsl:message>
87         </xsl:when>
88         <xsl:when test="local-name($id.structure) != 'structure'">
89           <xsl:message terminate="yes">
90             <xsl:text>ERROR: structure.id param set to '</xsl:text>
91             <xsl:value-of select="$structure.id"/>
92             <xsl:text>' but no structure with that xml:id exists in assembly.</xsl:text>
93           </xsl:message>
94         </xsl:when>
95         <xsl:otherwise>
96           <xsl:apply-templates select="key('id', $structure.id)"/>
97         </xsl:otherwise>
98       </xsl:choose>
99     </xsl:when>
100     <xsl:when test="$output.type != '' and not(d:structure[@type = $output.type])">
101       <xsl:message terminate="yes">
102         <xsl:text>ERROR: output.type param set to '</xsl:text>
103         <xsl:value-of select="$output.type"/>
104         <xsl:text> but no structure element has that type attribute. Exiting.</xsl:text>
105       </xsl:message>
106     </xsl:when>
107     <xsl:when test="$output.type != '' and d:structure[@type = $output.type]">
108       <xsl:apply-templates select="d:structure[@type = $output.type][1]"/>
109     </xsl:when>
110     <xsl:otherwise>
111       <!-- otherwise process the first structure -->
112       <xsl:apply-templates select="d:structure[1]"/>
113     </xsl:otherwise>
114   </xsl:choose>
115 </xsl:template>
116
117 <xsl:template match="d:structure[not(@resourceref)]">
118
119   <xsl:variable name="output.root.element">
120     <xsl:apply-templates select="." mode="compute.element.name"/>
121   </xsl:variable>
122
123   <xsl:element name="{$output.root.element}" namespace="http://docbook.org/ns/docbook">
124     <xsl:attribute name="version">
125       <xsl:value-of select="$docbook.version"/>
126     </xsl:attribute>
127     <xsl:copy-of select="@xml:id"/>
128
129     <xsl:apply-templates> 
130       <xsl:with-param name="parent" select="$output.root.element"/>
131     </xsl:apply-templates>
132
133   </xsl:element>
134 </xsl:template>
135
136 <xsl:template match="d:glossary|d:bibliography|d:index|d:toc">
137    <xsl:param name="parent" select="''"/>
138   <xsl:apply-templates select="." mode="copycontent"/>
139 </xsl:template>
140
141 <xsl:template match="d:title|d:titleabbrev|d:subtitle">
142    <xsl:param name="parent" select="''"/>
143   <xsl:apply-templates select="." mode="copycontent"/>
144 </xsl:template>
145
146 <!-- module without a resourceref creates an element -->
147 <xsl:template match="d:module[not(@resourceref)]">
148   <xsl:param name="parent" select="''"/>
149   
150   <xsl:variable name="module" select="."/>
151
152   <xsl:variable name="element.name">
153     <xsl:apply-templates select="." mode="compute.element.name"/>
154   </xsl:variable>
155
156   <xsl:element name="{$element.name}" namespace="http://docbook.org/ns/docbook">
157     <xsl:choose>
158       <!-- Use the module's xml:id if it has one -->
159       <xsl:when test="@xml:id">
160         <xsl:attribute name="xml:id">
161           <xsl:value-of select="@xml:id"/>
162         </xsl:attribute>
163       </xsl:when>
164     </xsl:choose>
165
166     <xsl:call-template name="merge.info">
167       <xsl:with-param name="merge.element" select="$module/d:merge"/>
168     </xsl:call-template>
169       
170     <xsl:apply-templates>
171       <xsl:with-param name="parent" select="$element.name"/>
172     </xsl:apply-templates>
173
174   </xsl:element>
175 </xsl:template>
176
177 <xsl:template name="compute.renderas">
178   <xsl:variable name="output.value">
179     <xsl:call-template name="compute.output.value">
180       <xsl:with-param name="property">renderas</xsl:with-param>
181     </xsl:call-template>
182   </xsl:variable>
183
184   <xsl:value-of select="$output.value"/>
185
186 </xsl:template>
187
188 <!-- This utility template is passed a value for output format
189      and the name of a property and computes the value
190      of the property from output children of context element -->
191 <xsl:template name="compute.output.value">
192   <xsl:param name="property" select="''"/>
193   
194   <xsl:variable name="default.format"
195                 select="ancestor::d:structure/@defaultformat"/>
196
197   <xsl:variable name="property.value">
198     <xsl:choose>
199       <!-- if a child output element has a format that matches the param value 
200            and it has that property -->
201       <!-- The format attribute can be multivalued -->
202       <xsl:when test="$output.format != '' and 
203                       d:output[contains(concat(' ', normalize-space(@format), ' '),  
204                                  $output.format)]
205                         [@*[local-name() = $property]]">
206         <xsl:value-of 
207            select="d:output[contains(concat(' ', normalize-space(@format), ' '), 
208                               $output.format)]
209                            [@*[local-name() = $property]][1]
210                            /@*[local-name() = $property]"/>
211       </xsl:when>
212       <!-- try with the structure's @defaultformat -->
213       <xsl:when test="$default.format != '' and 
214                       d:output[contains(concat(' ', normalize-space(@format), ' '),  
215                                  $default.format)]
216                         [@*[local-name() = $property]]">
217         <xsl:value-of 
218            select="d:output[contains(concat(' ', normalize-space(@format), ' '), 
219                               $default.format)]
220                            [@*[local-name() = $property]][1]
221                            /@*[local-name() = $property]"/>
222       </xsl:when>
223       <!-- try the first output with the property-->
224       <xsl:when test="d:output[@*[local-name() = $property]]">
225         <xsl:value-of 
226            select="d:output[@*[local-name() = $property]][1]
227                            /@*[local-name() = $property]"/>
228       </xsl:when>
229       <!-- and try the module element itself -->
230       <xsl:when test="@*[local-name() = $property]">
231         <xsl:value-of 
232            select="@*[local-name() = $property]"/>
233       </xsl:when>
234     </xsl:choose>
235   </xsl:variable>
236
237   <xsl:value-of select="$property.value"/>
238 </xsl:template>
239
240 <xsl:template match="d:module[not(@resourceref)]" mode="compute.element.name">
241
242   <xsl:variable name="renderas">
243     <xsl:call-template name="compute.renderas"/>
244   </xsl:variable>
245
246   <xsl:choose>
247     <xsl:when test="string-length($renderas) != 0">
248       <xsl:value-of select="$renderas"/>
249     </xsl:when>
250     <xsl:otherwise>
251       <xsl:message terminate="yes">
252         <xsl:text>ERROR: cannot determine output element name for </xsl:text>
253         <xsl:text>module with no @resourceref and no @renderas. Exiting.</xsl:text>
254       </xsl:message>
255     </xsl:otherwise>
256   </xsl:choose>
257 </xsl:template>
258
259 <xsl:template match="d:module[@resourceref]" mode="compute.element.name">
260   <xsl:param name="ref.name" select="''"/>
261
262   <xsl:variable name="renderas">
263     <xsl:call-template name="compute.renderas"/>
264   </xsl:variable>
265
266   <xsl:choose>
267     <xsl:when test="string-length($renderas) != 0">
268       <xsl:value-of select="$renderas"/>
269     </xsl:when>
270     <xsl:when test="$ref.name = 'topic' and 
271                     string-length($topic.default.renderas) != 0"> 
272       <xsl:value-of select="$topic.default.renderas"/>
273     </xsl:when>
274     <xsl:when test="string-length($ref.name) != 0">
275       <xsl:value-of select="$ref.name"/> 
276     </xsl:when>
277     <xsl:otherwise>
278       <xsl:message terminate="yes">
279         <xsl:text>ERROR: cannot determine output element name for </xsl:text>
280         <xsl:text>@resourceref="</xsl:text>
281         <xsl:value-of select="@resourceref"/>
282         <xsl:text>". Exiting.</xsl:text>
283       </xsl:message>
284     </xsl:otherwise>
285   </xsl:choose>
286 </xsl:template>
287
288 <xsl:template match="d:structure" mode="compute.element.name">
289   <xsl:param name="ref.name" select="''"/>
290
291   <xsl:variable name="renderas">
292     <xsl:call-template name="compute.renderas"/>
293   </xsl:variable>
294
295   <xsl:choose>
296     <xsl:when test="string-length($renderas) != 0">
297       <xsl:value-of select="$renderas"/>
298     </xsl:when>
299     <xsl:when test="string-length($ref.name) != 0">
300       <xsl:value-of select="$ref.name"/> 
301     </xsl:when>
302     <xsl:when test="string-length($root.default.renderas) != 0">
303       <xsl:value-of select="$root.default.renderas"/>
304     </xsl:when>
305     <xsl:otherwise>
306       <xsl:message terminate="yes">
307         <xsl:text>ERROR: cannot determine output element name for </xsl:text>
308         <xsl:text>structure with no @renderas and no $root.default.renderas. </xsl:text>
309         <xsl:text>Exiting.</xsl:text>
310       </xsl:message>
311     </xsl:otherwise>
312   </xsl:choose>
313 </xsl:template>
314
315 <xsl:template match="d:module[@resourceref] | d:structure[@resourceref]">
316   <xsl:param name="parent" select="''"/>
317
318   <xsl:variable name="module" select="."/>
319   <xsl:variable name="resourceref" select="@resourceref"/>
320   <xsl:variable name="resource" select="key('id', $resourceref)"/>
321
322   <xsl:choose>
323     <xsl:when test="not($resource)">
324       <xsl:message terminate="yes">
325         <xsl:text>ERROR: no xml:id matches @resourceref = '</xsl:text>
326         <xsl:value-of select="$resourceref"/>
327         <xsl:text>'.</xsl:text>
328       </xsl:message>
329     </xsl:when>
330     <xsl:when test="not($resource/self::d:resource)">
331       <xsl:message terminate="yes">
332         <xsl:text>ERROR: xml:id matching @resourceref = '</xsl:text>
333         <xsl:value-of select="$resourceref"/>
334         <xsl:text> is not a resource element'.</xsl:text>
335       </xsl:message>
336     </xsl:when>
337   </xsl:choose>
338
339   <xsl:variable name="fileref.att" select="$resource/@fileref"/>
340   <xsl:variable name="fileref">
341     <xsl:choose>
342       <xsl:when test="$resource/ancestor::d:resources/@xml:base">
343         <xsl:value-of 
344             select="concat($resource/ancestor::d:resources[@xml:base][1]/@xml:base,
345                                  '/', $fileref.att)"/>
346       </xsl:when>
347       <xsl:otherwise>
348         <xsl:value-of select="$fileref.att"/>
349       </xsl:otherwise>
350     </xsl:choose>
351   </xsl:variable>
352
353   <xsl:choose>
354     <xsl:when test="string-length($fileref) = 0">
355       <!-- A resource without @fileref gets its content copied -->
356       <xsl:apply-templates select="$resource/node()" mode="copycontent"/>
357     </xsl:when>
358     <xsl:otherwise>
359
360       <xsl:variable name="ref.content" select="document($fileref,/)"/>
361     
362       <xsl:variable name="ref.root" select="$ref.content/*[1]"/>
363
364       <xsl:if test="count($ref.root) = 0">
365         <xsl:message terminate="yes">
366           <xsl:text>ERROR: @fileref = '</xsl:text>
367           <xsl:value-of select="$fileref"/>
368           <xsl:text>' has no content or is unresolved.</xsl:text>
369         </xsl:message>
370       </xsl:if>
371     
372       <xsl:variable name="element.name">
373         <xsl:apply-templates select="." mode="compute.element.name">
374           <xsl:with-param name="ref.name" select="local-name($ref.content/*[1])"/>
375         </xsl:apply-templates>
376       </xsl:variable>
377
378       <xsl:variable name="omittitles.property">
379         <xsl:call-template name="compute.output.value">
380           <xsl:with-param name="property">omittitles</xsl:with-param>
381         </xsl:call-template>
382       </xsl:variable>
383     
384       <xsl:variable name="contentonly.property">
385         <xsl:call-template name="compute.output.value">
386           <xsl:with-param name="property">contentonly</xsl:with-param>
387         </xsl:call-template>
388       </xsl:variable>
389     
390       <xsl:choose>
391         <xsl:when test="$contentonly.property = 'true' or 
392                         $contentonly.property = 'yes' or
393                         $contentonly.property = '1'">
394           <xsl:apply-templates select="$ref.content/*[1]/node()" mode="copycontent">
395             <xsl:with-param name="omittitles" select="$omittitles.property"/>
396           </xsl:apply-templates>
397         </xsl:when>
398         <!-- use xsl:copy if using the ref element to get its namespaces -->
399         <xsl:when test="$element.name = local-name($ref.root)">
400           <!-- must use for-each to set context node for xsl:copy -->
401           <xsl:for-each select="$ref.root">
402             <xsl:copy>
403               <xsl:copy-of select="@*[not(name = 'xml:id')]"/>
404               <xsl:choose>
405                 <!-- Use the module's xml:id if it has one -->
406                 <xsl:when test="$module/@xml:id">
407                   <xsl:attribute name="xml:id">
408                     <xsl:value-of select="$module/@xml:id"/>
409                   </xsl:attribute>
410                 </xsl:when>
411                 <!-- otherwise use the resource's id -->
412                 <xsl:otherwise>
413                   <xsl:copy-of select="@xml:id"/>
414                 </xsl:otherwise>
415               </xsl:choose>
416           
417               <xsl:call-template name="merge.info">
418                 <xsl:with-param name="merge.element" select="$module/d:merge"/>
419                 <xsl:with-param name="ref.content" select="$ref.content"/>
420                 <xsl:with-param name="omittitles" select="$omittitles.property"/>
421               </xsl:call-template>
422       
423               <!-- copy through all but titles, which moved to info -->
424               <xsl:apply-templates select="node()
425                        [not(local-name() = 'title') and
426                         not(local-name() = 'subtitle') and
427                         not(local-name() = 'info') and
428                         not(local-name() = 'titleabbrev')]" mode="copycontent"/>
429           
430               <xsl:apply-templates select="$module/node()"> 
431                 <xsl:with-param name="parent" select="$element.name"/>
432               </xsl:apply-templates>
433             </xsl:copy>
434           </xsl:for-each>
435         </xsl:when>
436         <xsl:otherwise>
437           <!-- create the element instead of copying it -->
438           <xsl:element name="{$element.name}" namespace="http://docbook.org/ns/docbook">
439             <xsl:copy-of select="$ref.content/*[1]/@*[not(name = 'xml:id')]"/>
440             <xsl:choose>
441               <!-- Use the module's xml:id if it has one -->
442               <xsl:when test="@xml:id">
443                 <xsl:attribute name="xml:id">
444                   <xsl:value-of select="@xml:id"/>
445                 </xsl:attribute>
446               </xsl:when>
447               <!-- otherwise use the resource's id -->
448               <xsl:when test="$ref.content/*[1]/@xml:id">
449                 <xsl:attribute name="xml:id">
450                   <xsl:value-of select="$ref.content/*[1]/@xml:id"/>
451                 </xsl:attribute>
452               </xsl:when>
453             </xsl:choose>
454         
455             <xsl:call-template name="merge.info">
456               <xsl:with-param name="merge.element" select="d:merge"/>
457               <xsl:with-param name="ref.content" select="$ref.content"/>
458               <xsl:with-param name="omittitles" select="$omittitles.property"/>
459             </xsl:call-template>
460     
461             <!-- copy through all but titles, which moved to info -->
462             <xsl:apply-templates select="$ref.content/*[1]/node()
463                      [not(local-name() = 'title') and
464                       not(local-name() = 'subtitle') and
465                       not(local-name() = 'info') and
466                       not(local-name() = 'titleabbrev')]" mode="copycontent"/>
467         
468             <xsl:apply-templates> 
469               <xsl:with-param name="parent" select="$element.name"/>
470             </xsl:apply-templates>
471           </xsl:element>
472         </xsl:otherwise>
473       </xsl:choose>
474     </xsl:otherwise>
475   </xsl:choose>
476 </xsl:template>
477
478 <xsl:template name="merge.info">
479   <xsl:param name="merge.element" select="NOTANODE"/>
480   <xsl:param name="ref.content" select="NOTANODE"/>
481   <xsl:param name="omittitles"/> 
482
483   <!-- a merge element may use resourceref as well as literal content -->
484   <!-- any literal content overrides the merge resourceref content -->
485   <xsl:variable name="merge.ref.content">
486     <xsl:if test="$merge.element/@resourceref">
487       <xsl:variable name="resourceref" select="$merge.element/@resourceref"/>
488       <xsl:variable name="resource" select="key('id', $resourceref)"/>
489
490       <xsl:choose>
491         <xsl:when test="not($resource)">
492           <xsl:message terminate="yes">
493             <xsl:text>ERROR: no xml:id matches @resourceref = '</xsl:text>
494             <xsl:value-of select="$resourceref"/>
495             <xsl:text>'.</xsl:text>
496           </xsl:message>
497         </xsl:when>
498         <xsl:when test="not($resource/self::d:resource)">
499           <xsl:message terminate="yes">
500             <xsl:text>ERROR: xml:id matching @resourceref = '</xsl:text>
501             <xsl:value-of select="$resourceref"/>
502             <xsl:text> is not a resource element'.</xsl:text>
503           </xsl:message>
504         </xsl:when>
505       </xsl:choose>
506
507       <xsl:variable name="fileref.att" select="$resource/@fileref"/>
508
509       <xsl:variable name="fileref">
510         <xsl:choose>
511           <xsl:when test="$resource/ancestor::d:resources/@xml:base">
512             <xsl:value-of 
513                 select="concat($resource/ancestor::d:resources[@xml:base][1]/@xml:base,
514                                '/', $fileref.att)"/>
515           </xsl:when>
516           <xsl:otherwise>
517             <xsl:value-of select="$fileref.att"/>
518           </xsl:otherwise>
519         </xsl:choose>
520       </xsl:variable>
521
522       <xsl:if test="string-length($fileref) != 0">
523         <xsl:copy-of select="document($fileref,/)"/>
524       </xsl:if>
525     </xsl:if>
526   </xsl:variable>
527
528   <xsl:variable name="merge.ref.info" 
529                 select="exsl:node-set($merge.ref.content)//d:info[1]"/>
530
531   <xsl:if test="$merge.element/@resourceref and not($merge.ref.info)">
532     <xsl:message terminate="yes">
533       <xsl:text>ERROR: merge element with resourceref '</xsl:text>
534       <xsl:value-of select="$merge.element/@resourceref"/>
535       <xsl:text>' must point to something with an info element.'</xsl:text>
536     </xsl:message>
537   </xsl:if>
538
539   <xsl:variable name="omittitles.boolean">
540     <xsl:choose>
541       <xsl:when test="$omittitles = 'yes' or $omittitles = 'true' or omittitles = '1'">
542         <xsl:value-of select="1"/>
543       </xsl:when>
544       <xsl:otherwise>
545         <xsl:value-of select="0"/>
546       </xsl:otherwise>
547     </xsl:choose>
548   </xsl:variable>
549   <!-- output info if there is any -->
550   <xsl:if test="$merge.element/node() or 
551                 $merge.ref.info/node() or
552                 $ref.content/*/d:info/node() or
553                 $ref.content/*/d:title[$omittitles.boolean = 0] or
554                 $ref.content/*/d:subtitle[$omittitles.boolean = 0] or
555                 $ref.content/*/d:titleabbrev[$omittitles.boolean = 0]">
556
557     <xsl:variable name="ref.info" select="$ref.content/*/d:info"/>
558     <xsl:variable name="ref.title" select="$ref.content/*/d:title"/>
559     <xsl:variable name="ref.subtitle" select="$ref.content/*/d:subtitle"/>
560     <xsl:variable name="ref.titleabbrev" select="$ref.content/*/d:titleabbrev"/>
561     <xsl:variable name="ref.info.title" select="$ref.content/*/d:info/d:title"/>
562     <xsl:variable name="ref.info.subtitle" select="$ref.content/*/d:info/d:subtitle"/>
563     <xsl:variable name="ref.info.titleabbrev" select="$ref.content/*/d:info/d:titleabbrev"/>
564
565     <info>
566       <!-- First copy through any merge attributes and elements and comments -->
567       <xsl:copy-of select="$merge.element/@*[not(local-name(.) = 'resourceref')]"/>
568
569       <!-- And copy any resource info attributes not in merge-->
570       <xsl:for-each select="$ref.info/@*">
571         <xsl:variable name="resource.att" select="local-name(.)"/>
572         <xsl:choose>
573           <xsl:when test="$merge.element/@*[local-name(.) = $resource.att]">
574             <!-- do nothing because overridden -->
575           </xsl:when>
576           <xsl:otherwise>
577             <!-- copy through if not overridden -->
578             <xsl:copy-of select="."/>
579           </xsl:otherwise>
580         </xsl:choose>
581       </xsl:for-each>
582
583       <!-- Copy through the merge children as they have highest priority -->
584       <xsl:copy-of select="$merge.element/node()"/>
585
586       <!-- and copy through those merge resource elements not in merge element -->
587       <xsl:for-each select="$merge.ref.info/node()">
588         <xsl:variable name="resource.node" select="local-name(.)"/>
589         <xsl:choose>
590           <xsl:when test="$merge.element/node()[local-name(.) = $resource.node]">
591             <!-- do nothing because overridden -->
592           </xsl:when>
593           <xsl:otherwise>
594             <!-- copy through -->
595             <xsl:copy-of select="."/>
596           </xsl:otherwise>
597         </xsl:choose>
598       </xsl:for-each>
599
600       <!-- And copy any module's resource info node not in merge or merge.ref -->
601       <xsl:for-each select="$ref.info/node() | 
602                             $ref.title[$omittitles.boolean = 0] |
603                             $ref.subtitle[$omittitles.boolean = 0] |
604                             $ref.titleabbrev[$omittitles.boolean = 0] |
605                             $ref.info.title[$omittitles.boolean = 0] |
606                             $ref.info.subtitle[$omittitles.boolean = 0] |
607                             $ref.info.titleabbrev[$omittitles.boolean = 0]">
608         <xsl:variable name="resource.node" select="local-name(.)"/>
609         <xsl:choose>
610           <xsl:when test="$merge.element/node()[local-name(.) = $resource.node]">
611             <!-- do nothing because overridden -->
612           </xsl:when>
613           <xsl:when test="$merge.ref.info/node()[local-name(.) = $resource.node]">
614             <!-- do nothing because overridden -->
615           </xsl:when>
616           <xsl:otherwise>
617             <!-- copy through -->
618             <xsl:copy-of select="."/>
619           </xsl:otherwise>
620         </xsl:choose>
621       </xsl:for-each>
622
623     </info>
624   </xsl:if>
625 </xsl:template>
626
627 <xsl:template match="d:relationships">
628   <xsl:message>
629     <xsl:text>WARNING: the &lt;relationships&gt; element is not currently </xsl:text>
630     <xsl:text>supported by this stylesheet.</xsl:text>
631   </xsl:message>
632 </xsl:template>
633
634 <xsl:template match="d:transforms">
635   <xsl:message>
636     <xsl:text>WARNING: the &lt;transforms&gt; element is not currently </xsl:text>
637     <xsl:text>supported by this stylesheet.</xsl:text>
638   </xsl:message>
639 </xsl:template>
640
641 <xsl:template match="d:filterin">
642   <xsl:message>
643     <xsl:text>WARNING: the &lt;filterin&gt; element is not currently </xsl:text>
644     <xsl:text>supported by this stylesheet.</xsl:text>
645   </xsl:message>
646 </xsl:template>
647
648 <xsl:template match="d:filterout">
649   <xsl:message>
650     <xsl:text>WARNING: the &lt;filterin&gt; element is not currently </xsl:text>
651     <xsl:text>supported by this stylesheet.</xsl:text>
652   </xsl:message>
653 </xsl:template>
654
655 </xsl:stylesheet>