[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Number of scans required ??

Subject: Re: Number of scans required ??
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 14 Aug 2003 15:58:35 +0100
count 1

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>&#10;</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>&#10;</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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.