[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: How to cope with the complexity of an XSLT program
Hi Roger, Thousands!!? I get nervous when there's dozens of templates. :) Thanks for posting your favorite set of complexity-reducing tricks. I had one stylesheet where I needed to inline some elements with @idref references, then reorganize the resulting content. I tried doing everything in one pass with clever use of <xsl:apply-templates> and <xsl:next-match>, but I always seemed to mishandle some corner case. I eventually gave in and implemented multiple passes: <!-- TOP-LEVEL PASS - apply passes 1 through 4 to document --> <xsl:template match="/"> <xsl:variable name="pass1-results" as="document-node()"> <xsl:apply-templates select="/" mode="pass1"/> </xsl:variable> <xsl:variable name="pass2-results" as="document-node()"> <xsl:apply-templates select="$pass1-results" mode="pass2"/> </xsl:variable> <xsl:variable name="pass3-results" as="document-node()"> <xsl:apply-templates select="$pass2-results" mode="pass3"/> </xsl:variable> <xsl:variable name="pass4-results" as="document-node()"> <xsl:apply-templates select="$pass3-results" mode="pass4"/> </xsl:variable> <xsl:sequence select="$pass4-results"/> </xsl:template> That solved the problem and avoided problematic template interactions, but it made me feel defeated because I resorted to a linear way of solving the problem. If anyone is curious, more details about the problem are available at https://blog.oxygenxml.com/topics/preprocessing_ditaot_project_files.html and the XSLT file itself is at https://blog.oxygenxml.com/topics/preprocessing_ditaot_project_files/preproce ss_project_file.xsl - Chris
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|