[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Trouble With Multiple File Outputs Based on Letter
Sorry if you're seeing this twice, first attempt seems to have vanished. I have a large XML Doc with a tree something like this: <ead> <archdesc> <dsc> <co1> <did> <unittile> <title> <c02> <did> <unittitle> <title> I am trying to break this rather large doc up into multiple files based on letters of the alphabet. Each new file (a.html, b.html, c.html, etc...) will have the contents of the <title></title> if that <title> starts with the same letter that the file has as it's name. e.g. a.html has the <title>A Stitch in Time</title> The style sheet below will happily create the files for each letter, but only puts the first A <title> it comes to into each one of the files. So it's just finding a title that begins with the letter A and it then just stops, rather than putting ALL the title's that start with A into a.html, and then all the B's into b.html and so on. I'm totally stuck, not sure what I am doing wrong, or how to proceed. Currently I am running it through XT, but that's not a necessity, so I can switch processors. Thanks! ========= <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xt="http://www.jclark.com/xt" extension-element-prefixes="xt"> <xsl:template match="/"> <xsl:call-template name="out" /> </xsl:template> <xsl:template name="out"> <html> <head><title>Title</title></head> <body> <!-- this is just a list of letters to get something to loop through --> <xsl:for-each select="/ead/archdesc/other/letter"> <xsl:variable name="file" select="." /> <xt:document method="html" href="{$file}.html"> <xsl:call-template name="page"> <xsl:value-of select="$sTitle" /> </xsl:call-template> </xt:document> </xsl:for-each> </body> </html> </xsl:template> <xsl:template name="page"> <html> <head><title>The Letter <xsl:value-of select="." /></title></head> <body> <xsl:for-each select="."> <!--var decl --> <xsl:variable name="lett" select="."/> <xsl:variable name="initTitle" select="substring(//did/unittitle/title,'1','1')" /> <xsl:variable name="lett_case_mod" select="translate($lett,'abcdef','ABCDEF')" /> <xsl:variable name="Title" select="//did/unittitle/title" /> <!--param decl --> <xsl:param name="lett" select="$lett" /> <xsl:param name="sTitle" select="$Title" /> <h1><xsl:value-of select="$sTitle" /></h1> <xsl:if test="$lett_case_mod = $initTitle"> <xsl:call-template name="showbox"/> </xsl:if> </xsl:for-each> </body> </html> </xsl:template> <xsl:template name="showbox"> Show That Box Here! </xsl:template> </xsl:stylesheet> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|