Xslt -> Appending to a attribute

Hello everyone,

I have a list of images that need to be appended to the existing attribute in an xslt template. I am trying to output XHTML. The body tag may already contain some function in the onLoad attribute, so it would be best to just append the images to be preloaded. To get an idea, please see the code below

<body onLoad=“somefunc();”>

<xsl:for-each select=“JS/preload_images”>
<xsl:variable name=“val2” select=“concat(…or something like that…)”/>
</xsl:for-each>
<xsl:variable name=“attr” select=“concat(.,‘,’)”/>
</body>

Any help will be appreciated.

Thanks

  • Metter

Try something like this instead:


<xsl:template match="body">
<body>
 <xsl:attribute name="onLoad">
 <!--the line below will grab what you have in
 the current onLoad attribute and copy it-->
 <xsl:value-of select="@onLoad" />
 <!--
  add whatever you need to here,
  like the loop you have in your other code sample.
  This will be appended to the onLoad attribute.
  -->
 </xsl:attribute>
</body>
</xsl:template>

Great, Let me try this. Thanks for your help and time. I really appreciate it :slight_smile: