[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: fallback to a default template in xsl processing
Thanks! - your suggestion have helped a great deal! while I still have much to learn about xsl I think it is great. I'm giving a talk on tuesday at a conference for the application/industry I work as a consultant. Reporting has been done with crystal reports and I'm introducing xml->html via xsl approach with xml output generated from the system. I have working examples from previous implementations but I'm trying to clean them up for presentation. I really appreciate your help! best, april -----Original Message----- From: David Carlisle [mailto:davidc@xxxxxxxxx] Sent: Friday, April 25, 2008 10:46 AM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: fallback to a default template in xsl processing <xsl:param name="ListName"> <xsl:value-of select="NAME"/> </xsl:param> 99 times out of 1000 when you use xsl:param or xsl:variable in thsi form it's more efficient and more flexible to write <xsl:param name="ListName" select="NAME"/> which defines $ListName to be the thing selected by NAME rather tahn a result tree fragment with a root node and child text node with string value the string value of the thing selected by NAME. <xsl:element name="table"> <xsl:element name="tbody"> I don't know why people use xsl:element so much, personally i would always write that as <table> <tbody> which is easier to read. (It probably makes no difference at all to the XSLT system though, so it is just personal preference) <xsl:for-each select="node()"> you are steping through all nodes here including white space used for indentation, comments and anything else. Except for eleemnts they woon't have a name() so <xsl:element name="td"> <xsl:value-of select="name()"/> </xsl:element> will be empty. I suspect that you only want to iterate through elements, in which case change node() to *. > The first node under LIMS is always unique (i.e., the parent table), > the other nodes the child tables so rather than the long xpath with the self:: tests I suggested had before, just do <xsl:apply-templates select="*[1]" mode="parent"/> then match on your parents, eg <xsl:template match="SUBROUTINE" mode="parent"> something about subroutine, now handle the children <xsl:apply-templates select="following-sibling::*" mode="child"/> </xsl:template> > I don't know if that makes sense you lost me around there, the list guidelines do suggest posting a complete (small) input file and a complete (small) required result and a complete (small) stylesheet attempt. It's OK posting 2 or 3 (or even 10) line fragments of XSL as people can see what they do, but beyond that it's just noise and you need to post complete well formed documents so people can actually run and/or modify the code. David
|
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
|