XSLT - How to combine XSLT files

arturoriyadh

New Member
Is there a simple way of combining XSLT's. I am new to XSLT, and i getting the hang of how to create them and the funny ways of using them to get my desired outcome. However at the moment I am able to use one XSLT to convert my output into the desired output; BUT then straight after it i have another, and another. Each XSLT changes the output from one thing to another.For example, and these are simple XSLTs to illustrate the issue:XSLT 1:\[code\]<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:r="http://www.castiron.com/response" exclude-result-prefixes="r"> <xsl:output method="xml" indent="yes"/> <xsl:template match="/root"> <xsl:element name="imageScene7Response" xmlns="http://www.castiron.com/burberry/digitalcatalogue/response"> <xsl:element name="rcode">0</xsl:element> <xsl:element name="rmessage">success</xsl:element> <xsl:copy-of select="@*"/> <xsl:apply-templates select="payload"/> </xsl:element> </xsl:template> <xsl:template match="/root/payload"> <xsl:if test="not(productId = preceding-sibling::payload/productId)"> <xsl:element name="payload" xmlns="http://www.castiron.com/burberry/digitalcatalogue/response"> <xsl:element name="productId"> <xsl:value-of select="productId"/> </xsl:element> <xsl:for-each select="../payload[productId = current()/productId]"> <xsl:choose> <xsl:when test="type = '0' and preceding-sibling::payload/type = type and productId = preceding-sibling::payload/productId"> <xsl:element name="alternativeImages"> <xsl:value-of select="url"/> </xsl:element> </xsl:when> <xsl:when test="type = '0'"> <xsl:element name="mainImage"> <xsl:value-of select="url"/> </xsl:element> </xsl:when> <xsl:when test="type > '0' and type < '70'"> <xsl:element name="alternativeImages"> <xsl:value-of select="url"/> </xsl:element> </xsl:when> <xsl:when test="type = '70'"> <xsl:element name="video"> <xsl:value-of select="url"/> </xsl:element> </xsl:when> <xsl:when test="type = '80'"> <xsl:element name="lookbookImages"> <xsl:value-of select="url"/> </xsl:element> </xsl:when> <xsl:when test="type = 'sw'"> <xsl:element name="swatchImages"> <xsl:value-of select="url"/> </xsl:element> </xsl:when> </xsl:choose> </xsl:for-each> </xsl:element> </xsl:if> </xsl:template></xsl:stylesheet>\[/code\]Then:\[code\]<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output omit-xml-declaration="yes" indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template> <xsl:template match= "*[not(@*|*|comment()|processing-instruction()) and normalize-space()='' ]"/></xsl:stylesheet>\[/code\]Then some other logic in other XSLT.Is it as easy as putting the templates one below another in a single combined XSLT?
 
Back
Top