javascript - xslt creation for html tags using for each -


i trying create xslt html tags consists of links, images , text.. tried creating using w3schools not create it... can guys tell me how create it.. providing code below...

my h, p , img tag repeatable need put in each... can tell me how it...

<?xml version="1.0" encoding="iso-8859-1"?> <!-- edited xmlspy® --> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:template match="/">   <html>   <body>         <xsl:for-each select="section/article/div">        </xsl:for-each>     </table>   </body>   </html> </xsl:template> 

try template:

<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform"     version="1.0">      <xsl:key name="kimg" match="img" use="@src"/>      <xsl:key name="kh" match="h1" use="concat(@class, '+', .)"/>      <xsl:key name="kp" match="p" use="."/>      <xsl:template match="/">         <duplicates>             <xsl:for-each select="//img[generate-id()=generate-id(key('kimg',@src)[2])]">                 <duplicate-images>                     <xsl:copy-of select="key('kimg',@src)"/>                 </duplicate-images>             </xsl:for-each>             <xsl:for-each select="//h1[generate-id()=generate-id(key('kh',concat(@class, '+', .))[2])]">                 <duplicate-h1>                     <xsl:copy-of select="key('kh',concat(@class, '+', .))"/>                 </duplicate-h1>             </xsl:for-each>             <xsl:for-each select="//p[generate-id()=generate-id(key('kp',.)[2])]">                 <duplicate-paragraphs>                     <xsl:copy-of select="key('kp',.)"/>                 </duplicate-paragraphs>             </xsl:for-each>         </duplicates>     </xsl:template>  </xsl:stylesheet> 

with jsfiddle input, outputs:

<?xml version="1.0" encoding="utf-8"?> <duplicates>     <duplicate-images>         <img src="/images/shop-landing/solutions.jpg"></img>         <img src="/images/shop-landing/solutions.jpg"></img>     </duplicate-images>     <duplicate-h1>         <h1 class="shop-features__subtitle">attract customers</h1>         <h1 class="shop-features__subtitle">attract customers</h1>     </duplicate-h1>     <duplicate-paragraphs>         <p> find new ways spread word.<br></br> expand reach right<br></br>             advice , tools keep<br></br> ahead of pack.<br></br>             <a href="" class="button button--hero mini-configurator__button">buy now</a>         </p>         <p> find new ways spread word.<br></br> expand reach right<br></br>             advice , tools keep<br></br> ahead of pack.<br></br>             <a href="" class="button button--hero mini-configurator__button">buy now</a>         </p>     </duplicate-paragraphs> </duplicates> 

adapted how output duplicate elements using xslt?


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -