Subject: Re: [xsl] Number of scans required ?? From: David Carlisle <davidc@xxxxxxxxx> Date: Thu, 14 Aug 2003 15:58:35 +0100 |
Ah an earlier message of yours made the example clearer, OK this version first finds the longest row anywhere and then outputs all cells from all rows in the order of that longest row, filling out with blanks as needed (if some shorter rows may have columns that do not appear in the longest row, you have to work a bit harder) input <Root> <Tables> <TABLE NAME="Client_Agent"> <ROW> <COLUMN NAME="Agent Name">eXpress NS Client</COLUMN> <COLUMN NAME="Product Version">5.5.0.517</COLUMN> <COLUMN NAME="Build Number">517</COLUMN> </ROW> <ROW> <COLUMN NAME="Agent Name">eXpress Inventory Solution</COLUMN> <COLUMN NAME="Product Version">5.5.0.424</COLUMN> <COLUMN NAME="Build Number">424</COLUMN> </ROW> </TABLE> <TABLE NAME="Client_Agent"> <ROW> <COLUMN NAME="Agent Name">eXpress NS Client</COLUMN> <COLUMN NAME="Install Path">C:\Program Files\ABC\eXpress\NS Client\Software Delivery\Software Packages\{01B54EB5-3679-4C73-9E10-E169D5EA8C59}</COLUMN> <COLUMN NAME="Product Version">5.5.0.519</COLUMN> <COLUMN NAME="Build Number">519</COLUMN> </ROW> <ROW> <COLUMN NAME="Agent Name">eXpress Inventory Solution</COLUMN> <COLUMN NAME="Install Path">C:\Program Files\ABC\eXpress\NS Client\Software Delivery\Software Packages\{01B54EB5-4579-4C73-9E10-E169D5DA9E59}</COLUMN> <COLUMN NAME="Product Version">5.5.0.428</COLUMN> <COLUMN NAME="Build Number">428</COLUMN> </ROW> </TABLE> </Tables> </Root> xsl <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="text"/> <xsl:key name="x" match="TABLE" use="count(ROW[1]/COLUMN)"/> <xsl:variable name="l" select="(//TABLE[not(key('x',1+count(ROW[1]/COLUMN)))])[1]/ROW[1]"/> <xsl:template match="/"> <xsl:for-each select="$l/COLUMN/@NAME"> <xsl:value-of select="."/> <xsl:if test="position()!=last()">,</xsl:if> </xsl:for-each> <xsl:text> </xsl:text> <xsl:apply-templates select="//TABLE"/> </xsl:template> <xsl:template match="TABLE"> <xsl:for-each select="ROW"> <xsl:variable name="r" select="."/> <xsl:for-each select="$l/COLUMN"> <xsl:value-of select="normalize-space($r/COLUMN[@NAME=current()/@NAME])"/> <xsl:if test="position()!=last()">,</xsl:if> </xsl:for-each> <xsl:text> </xsl:text> </xsl:for-each> </xsl:template> </xsl:stylesheet> result Agent Name,Install Path,Product Version,Build Number eXpress NS Client,,5.5.0.517,517 eXpress Inventory Solution,,5.5.0.424,424 eXpress NS Client,C:\Program Files\ABC\eXpress\NS Client\Software Delivery\Software Packages\{01B54EB5-3679-4C73-9E10-E169D5EA8C59},5.5.0.519,519 eXpress Inventory Solution,C:\Program Files\ABC\eXpress\NS Client\Software Delivery\Software Packages\{01B54EB5-4579-4C73-9E10-E169D5DA9E59},5.5.0.428,428 David ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Number of scans required , David Carlisle | Thread | RE: [xsl] Number of scans required , Dipesh Khakhkhar |
RE: [xsl] CDATA within a CDATA, Michael Kay | Date | [xsl] Quotation marks within quotat, Daniel McOrmond |
Month |