|
9 | 9 | version="1.0">
|
10 | 10 | <xsl:output indent="yes" encoding="UTF-8"/>
|
11 | 11 |
|
| 12 | + <xsl:key name="ids" match="*[@id]" use="@id"/> |
| 13 | + <xsl:key name="ids" match="ezxhtml5:a[@name]" use="@name"/> |
| 14 | + |
12 | 15 | <xsl:template match="/ezxhtml5:section">
|
13 | 16 | <section xmlns="http://docbook.org/ns/docbook"
|
14 | 17 | xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
85 | 88 | </xsl:choose>
|
86 | 89 | </xsl:template>
|
87 | 90 |
|
| 91 | + <xsl:template name="conditionallyAddIdAttribute"> |
| 92 | + <xsl:param name="attribute"/> |
| 93 | + |
| 94 | + <xsl:if test="$attribute"> |
| 95 | + <xsl:choose> |
| 96 | + <xsl:when test="count(key('ids', $attribute)) > 1"> |
| 97 | + <xsl:attribute name="xml:id"> |
| 98 | + <xsl:value-of select="concat($attribute, '_', generate-id(.))"/> |
| 99 | + </xsl:attribute> |
| 100 | + </xsl:when> |
| 101 | + <xsl:otherwise> |
| 102 | + <xsl:attribute name="xml:id"> |
| 103 | + <xsl:value-of select="$attribute"/> |
| 104 | + </xsl:attribute> |
| 105 | + </xsl:otherwise> |
| 106 | + </xsl:choose> |
| 107 | + </xsl:if> |
| 108 | + </xsl:template> |
| 109 | + |
88 | 110 | <xsl:template match="ezxhtml5:p" name="paragraph">
|
89 | 111 | <para>
|
90 |
| - <xsl:if test="@id"> |
91 |
| - <xsl:attribute name="xml:id"> |
92 |
| - <xsl:value-of select="@id"/> |
93 |
| - </xsl:attribute> |
94 |
| - </xsl:if> |
| 112 | + <xsl:call-template name="conditionallyAddIdAttribute"> |
| 113 | + <xsl:with-param name="attribute" select="@id"/> |
| 114 | + </xsl:call-template> |
95 | 115 | <xsl:if test="@class">
|
96 | 116 | <xsl:attribute name="ezxhtml:class">
|
97 | 117 | <xsl:value-of select="@class"/>
|
|
125 | 145 |
|
126 | 146 | <xsl:template match="ezxhtml5:pre">
|
127 | 147 | <xsl:element name="programlisting">
|
128 |
| - <xsl:if test="@id"> |
129 |
| - <xsl:attribute name="xml:id"> |
130 |
| - <xsl:value-of select="@id"/> |
131 |
| - </xsl:attribute> |
132 |
| - </xsl:if> |
| 148 | + <xsl:call-template name="conditionallyAddIdAttribute"> |
| 149 | + <xsl:with-param name="attribute" select="@id"/> |
| 150 | + </xsl:call-template> |
133 | 151 | <xsl:if test="@class">
|
134 | 152 | <xsl:attribute name="ezxhtml:class">
|
135 | 153 | <xsl:value-of select="@class"/>
|
|
243 | 261 | </xsl:otherwise>
|
244 | 262 | </xsl:choose>
|
245 | 263 | </xsl:attribute>
|
246 |
| - <xsl:if test="@id"> |
247 |
| - <xsl:attribute name="xml:id"> |
248 |
| - <xsl:value-of select="@id"/> |
249 |
| - </xsl:attribute> |
250 |
| - </xsl:if> |
| 264 | + <xsl:call-template name="conditionallyAddIdAttribute"> |
| 265 | + <xsl:with-param name="attribute" select="@id"/> |
| 266 | + </xsl:call-template> |
251 | 267 | <xsl:if test="@title">
|
252 | 268 | <xsl:attribute name="xlink:title">
|
253 | 269 | <xsl:value-of select="@title"/>
|
|
268 | 284 | <xsl:template name="link.anchor">
|
269 | 285 | <xsl:param name="attribute"/>
|
270 | 286 | <anchor>
|
271 |
| - <xsl:attribute name="xml:id"> |
272 |
| - <xsl:value-of select="$attribute"/> |
273 |
| - </xsl:attribute> |
| 287 | + <xsl:call-template name="conditionallyAddIdAttribute"> |
| 288 | + <xsl:with-param name="attribute" select="$attribute"/> |
| 289 | + </xsl:call-template> |
274 | 290 | </anchor>
|
275 | 291 | </xsl:template>
|
276 | 292 |
|
277 |
| - <xsl:template match="ezxhtml5:a[not(@name=preceding::ezxhtml5:a/@name)]"> |
| 293 | + <xsl:template match="ezxhtml5:a"> |
278 | 294 | <xsl:choose>
|
279 | 295 | <xsl:when test="@href">
|
280 | 296 | <xsl:call-template name="link.href"/>
|
|
307 | 323 | <xsl:value-of select="@class"/>
|
308 | 324 | </xsl:attribute>
|
309 | 325 | </xsl:if>
|
310 |
| - <xsl:if test="@id"> |
311 |
| - <xsl:attribute name="xml:id"> |
312 |
| - <xsl:value-of select="@id"/> |
313 |
| - </xsl:attribute> |
314 |
| - </xsl:if> |
| 326 | + <xsl:call-template name="conditionallyAddIdAttribute"> |
| 327 | + <xsl:with-param name="attribute" select="@id"/> |
| 328 | + </xsl:call-template> |
315 | 329 | <xsl:if test="contains( @style, 'text-align:' )">
|
316 | 330 | <xsl:variable name="textAlign">
|
317 | 331 | <xsl:call-template name="extractTextAlignValue">
|
|
334 | 348 |
|
335 | 349 | <xsl:template match="ezxhtml5:ol">
|
336 | 350 | <orderedlist>
|
337 |
| - <xsl:if test="@id"> |
338 |
| - <xsl:attribute name="xml:id"> |
339 |
| - <xsl:value-of select="@id"/> |
340 |
| - </xsl:attribute> |
341 |
| - </xsl:if> |
| 351 | + <xsl:call-template name="conditionallyAddIdAttribute"> |
| 352 | + <xsl:with-param name="attribute" select="@id"/> |
| 353 | + </xsl:call-template> |
342 | 354 | <xsl:if test="@class">
|
343 | 355 | <xsl:attribute name="ezxhtml:class">
|
344 | 356 | <xsl:value-of select="@class"/>
|
|
351 | 363 |
|
352 | 364 | <xsl:template match="ezxhtml5:ul">
|
353 | 365 | <itemizedlist>
|
354 |
| - <xsl:if test="@id"> |
355 |
| - <xsl:attribute name="xml:id"> |
356 |
| - <xsl:value-of select="@id"/> |
357 |
| - </xsl:attribute> |
358 |
| - </xsl:if> |
| 366 | + <xsl:call-template name="conditionallyAddIdAttribute"> |
| 367 | + <xsl:with-param name="attribute" select="@id"/> |
| 368 | + </xsl:call-template> |
359 | 369 | <xsl:if test="@class">
|
360 | 370 | <xsl:attribute name="ezxhtml:class">
|
361 | 371 | <xsl:value-of select="@class"/>
|
|
397 | 407 | </xsl:choose>
|
398 | 408 | </xsl:variable>
|
399 | 409 | <xsl:element name="{$tablename}" namespace="http://docbook.org/ns/docbook">
|
400 |
| - <xsl:if test="@id"> |
401 |
| - <xsl:attribute name="xml:id"> |
402 |
| - <xsl:value-of select="@id"/> |
403 |
| - </xsl:attribute> |
404 |
| - </xsl:if> |
| 410 | + <xsl:call-template name="conditionallyAddIdAttribute"> |
| 411 | + <xsl:with-param name="attribute" select="@id"/> |
| 412 | + </xsl:call-template> |
405 | 413 | <xsl:if test="@class">
|
406 | 414 | <xsl:attribute name="class">
|
407 | 415 | <xsl:value-of select="@class"/>
|
|
625 | 633 | </xsl:template>
|
626 | 634 |
|
627 | 635 | <xsl:template name="addCommonEmbedAttributes">
|
628 |
| - <xsl:if test="@id"> |
629 |
| - <xsl:attribute name="xml:id"> |
630 |
| - <xsl:value-of select="@id"/> |
631 |
| - </xsl:attribute> |
632 |
| - </xsl:if> |
| 636 | + <xsl:call-template name="conditionallyAddIdAttribute"> |
| 637 | + <xsl:with-param name="attribute" select="@id"/> |
| 638 | + </xsl:call-template> |
633 | 639 | <xsl:if test="@data-href">
|
634 | 640 | <xsl:attribute name="xlink:href">
|
635 | 641 | <xsl:value-of select="@data-href"/>
|
|
672 | 678 | <xsl:value-of select="@title"/>
|
673 | 679 | </xsl:attribute>
|
674 | 680 | </xsl:if>
|
675 |
| - <xsl:if test="@id"> |
676 |
| - <xsl:attribute name="xml:id"> |
677 |
| - <xsl:value-of select="@id"/> |
678 |
| - </xsl:attribute> |
679 |
| - </xsl:if> |
| 681 | + <xsl:call-template name="conditionallyAddIdAttribute"> |
| 682 | + <xsl:with-param name="attribute" select="@id"/> |
| 683 | + </xsl:call-template> |
680 | 684 | <xsl:if test="@class">
|
681 | 685 | <xsl:attribute name="ezxhtml:class">
|
682 | 686 | <xsl:value-of select="@class"/>
|
|
721 | 725 | <xsl:value-of select="@class"/>
|
722 | 726 | </xsl:attribute>
|
723 | 727 | </xsl:if>
|
724 |
| - <xsl:if test="@id"> |
725 |
| - <xsl:attribute name="xml:id"> |
726 |
| - <xsl:value-of select="@id"/> |
727 |
| - </xsl:attribute> |
| 728 | + <xsl:if test="@data-ezelement='eztemplate'"> |
| 729 | + <xsl:call-template name="conditionallyAddIdAttribute"> |
| 730 | + <xsl:with-param name="attribute" select="@id"/> |
| 731 | + </xsl:call-template> |
728 | 732 | </xsl:if>
|
729 | 733 | <xsl:if test="contains( @style, 'text-align:' )">
|
730 | 734 | <xsl:variable name="textAlign">
|
|
0 commit comments