[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: [xsl] fallback to a default template in xsl processing
Subject: RE: [xsl] fallback to a default template in xsl processing From: "Daly, April" <april@xxxxxxxxxxx> Date: Fri, 25 Apr 2008 15:32:30 +0100 |
Hi, I got your suggestions to work (thanks) and while the req. to select a named template for certain matched nodes and a default template for all others is true...there is of course more :-) each xml input file representents a single object in the system. the object is table based (e.g., parent<-children<-grandchildren<-...) the default template writes an html table for each LIMS/* (table) the other templates also tranverse each LIMS/* node but the output is tailored for type of object here in lies more brute force (awkward) xpath: <xsl:template match="LIST"> <xsl:param name="ListName"> <xsl:value-of select="NAME"/> </xsl:param> <xsl:element name="table"> <xsl:element name="tbody"> <xsl:for-each select="node()"> <xsl:element name="tr"> <xsl:element name="td"> <xsl:value-of select="name()"/> </xsl:element> <xsl:element name="td"> <xsl:value-of select="."/> </xsl:element> </xsl:element> </xsl:for-each> </xsl:element> </xsl:element> <xsl:element name="table"> <xsl:element name="tbody"> <xsl:for-each select="//LIST_ENTRY[LIST=$ListName]"> <xsl:sort select="ORDER_NUMBER" data-type="number"/> <xsl:element name="tr"> <xsl:element name="td"> <xsl:value-of select="ORDER_NUMBER"/> </xsl:element> <xsl:element name="td"> <xsl:value-of select="NAME"/> </xsl:element> <xsl:element name="td"> <xsl:value-of select="VALUE"/> </xsl:element> </xsl:element> </xsl:for-each> </xsl:element> </xsl:element> </xsl:template> <xsl:template match="*"> <xsl:element name="div"> <xsl:element name="h2"> <xsl:value-of select="name()"/> </xsl:element> <xsl:element name="table"> <xsl:element name="tbody"> <xsl:element name="tr"> <xsl:element name="th">Field Name</xsl:element> <xsl:element name="th">Field Value</xsl:element> </xsl:element> <xsl:for-each select="node()"> <xsl:call-template name="lwNodeRow"/> </xsl:for-each> </xsl:element> </xsl:element> </xsl:element> </xsl:template> The first node under LIMS is always unique (i.e., the parent table), the other nodes the child tables what would be nice :-) is for each unique name( LIMS/* ) other then the LIMS/[1] to be a table with field names as columns and the rows the (child table) table records I don't know if that makes sense, but I'm in good shape with your suggestion for my presentation (many thanks!) best, april -----Original Message----- From: David Carlisle [mailto:davidc@xxxxxxxxx] Sent: Friday, April 25, 2008 10:08 AM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] fallback to a default template in xsl processing > is it ok to just keep adding to the expression? e.g., OK as in it'll work, yes. On the other hand I was just guessing what your real requirement is from the example you posted and I suspect that that is not it. Is it really the case that if the first element is SUBROUTINE (or friends) you want to silently discard all following elements, but if SUBROUTINE (or friends) occurs in any other position you want to process all elements in document order. If that is what you need, then, as you see, you can have that; but it seems a slightly strange requirement which is reflected in the slightly awkward coding of a long bunch of self::SUBROUTINE or self::LIST or ... tests. David
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] fallback to a default tem, David Carlisle | Thread | Re: [xsl] fallback to a default tem, David Carlisle |
Re: [xsl] fallback to a default tem, David Carlisle | Date | Re: [xsl] fallback to a default tem, David Carlisle |
Month |