[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Column Heads and Column Data problem ??


Subject: Re: [xsl] Column Heads and Column Data problem ??
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 20 Aug 2003 11:35:58 -0400

Dipesh,

I am afraid I don't have time at this point to dig into your problem.

I did, however, run your sample input through the stylesheet I offered a couple of days ago. After a bug fix (broken XPath) and adjustment for your element names, this is the output I got (line breaks added for legibility):

[start]
Computer,ALTIRISTEST_CPQ,Name,Domain,Altkey1,Altkey2,Client_Agent,Agent Name,Product Version,Build Number,Install Path,Inventory_Results,Collection Time,File Count,Total Size,Version


,,,,,,,Altiris eXpress NS Client,5.5.0.517,517,C:\Program Files\Altiris\eXpress\NS
Client,,,,,


,,,,,,,Altiris eXpress Inventory Solution,5.5.0.424,424,C:\Program Files\Altiris\eXpress\NS

Client\Software Delivery\Software Packages\{01B54EB5-3679-4C73-9E10-E169D5A5EC59},,,,,

,,,,,,,,,,,,1/9/2003 3:06:56 AM,3,139271,5: 5: 0: 423
[end]

This isn't the output you've asked for, of course (it answers the problem statement of a couple of days ago), *but* ... it is close enough to suggest to me the solution I offered is on the right track, and that you can modify its approach and get what you want out of it.

So ... what follows isn't an entire solution -- but if you figure how how it does what it does, you should have some hints on how to proceed. (Note on process: the XPath bug I had to fix to get this to work is an indication of the risks of trying to apply entire solutions provided on the list. Sometimes we do this, as the most expedient approach to our goal of addressing a posted problem, but as Mike Kay said yesterday, it's not really the best way to help you solve your problem. Rather, you have to dig in to what we provide -- whether it be code, or merely hints -- and *understand* how it applies, or why it's buggy.)

Briefly stated, what the stylesheet does is collect all unique values of @NAME attributes and output, for each record, the values corresponding to the entire set of NAMES, delimited by commas:

<xsl:output method="text"/>

<xsl:variable name="name-set" select="//@NAME[not(.=preceding::*/@NAME)]"/>

<xsl:template match="/">
  <xsl:for-each select="$name-set">
    <xsl:value-of select="."/>
    <xsl:if test="not(position()=last())">,</xsl:if>
  </xsl:for-each>
  <xsl:text>&#xA;</xsl:text><!-- line feed for legibility -->

  <xsl:apply-templates select="//OBJECT"/>
  <!-- this apply-templates could be written to be more efficient,
       but I'm too lazy -->
</xsl:template>

<xsl:template match="OBJECT">
  <!-- we bind our context node to a variable so we can get
       to it inside the for-each -->
  <xsl:variable name="this-row" select="."/>
  <!-- Now we put out whatever value we have for each node in our name set -->
  <xsl:for-each select="$name-set">
    <xsl:value-of select="$this-row/ATTRIBUTE[@NAME=current()]"/>
    <xsl:if test="not(position()=last())">,</xsl:if>
  </xsl:for-each>
  <xsl:text>&#xA;</xsl:text><!-- line feed for legibility -->
</xsl:template>

Good luck,
Wendell

At 11:36 PM 8/19/2003, you wrote:
Input
======

<?xml version="1.0" encoding="UTF-8"?>
<AEXDATAEXTRACT DTD_VERSION="2.2" EXTRACT_START_DATETIME="1/9/2003 4:49:39 PM"
EXTRACT_TYPE="FULL" EXTRACT_COLLECTION="">
<RESOURCE_TYPE GUID="{493435f7-3b17-4c4c-b07f-c23e7ab7781f}" NAME="Computer"
DESCRIPTION="Asset Type definition for Computer" SOURCE="Asset"
CREATED_DATE="7/16/2002 5:22:23 PM" MODIFIED_DATE="9/23/2002 2:17:48 PM"
DELETED="0">
<RESOURCE GUID="{C116FCBF-5B94-4F15-BF95-5795DBD384CD}" NAME="ALTIRISTEST_CPQ"
SOURCE="" SITE_CODE="756win" DOMAIN="FIDD" SYSTEM_TYPE="Win32"
OS_NAME="Microsoft Windows XP" OS_TYPE="Professional" OS_VERSION="5.1"
OS_REVISION="Service Pack 1" LAST_LOGON_USER="" LAST_LOGON_DOMAIN="">
<INVENTORY>
<ASSET>
<IDENTIFICATION>
<ATTRIBUTE NAME="Name">ALTIRISTEST_CPQ</ATTRIBUTE>
<ATTRIBUTE NAME="Domain">FIDDOMRTLSLC</ATTRIBUTE>
<ATTRIBUTE NAME="Altkey1" NULL="FALSE" />
<ATTRIBUTE NAME="Altkey2">00-02-A5-1A-67-A6</ATTRIBUTE>
</IDENTIFICATION>


<CLASS NAME="Client_Agent">
<OBJECT>
<ATTRIBUTE NAME="Agent Name">Altiris eXpress NS Client</ATTRIBUTE>
<ATTRIBUTE NAME="Product Version">5.5.0.517</ATTRIBUTE>
<ATTRIBUTE NAME="Build Number">517</ATTRIBUTE>
<ATTRIBUTE NAME="Install Path">C:\Program Files\Altiris\eXpress\NS
Client</ATTRIBUTE>
</OBJECT>
<OBJECT>
<ATTRIBUTE NAME="Agent Name">Altiris eXpress Inventory Solution</ATTRIBUTE>
<ATTRIBUTE NAME="Product Version">5.5.0.424</ATTRIBUTE>
<ATTRIBUTE NAME="Build Number">424</ATTRIBUTE>
<ATTRIBUTE NAME="Install Path">C:\Program Files\Altiris\eXpress\NS
Client\Software Delivery\Software
Packages\{01B54EB5-3679-4C73-9E10-E169D5A5EC59}</ATTRIBUTE>
</OBJECT>
</CLASS>
<CLASS NAME="Inventory_Results">
<OBJECT>
<ATTRIBUTE NAME="Collection Time">1/9/2003 3:06:56 AM</ATTRIBUTE>
<ATTRIBUTE NAME="File Count">3</ATTRIBUTE>
<ATTRIBUTE NAME="Total Size">139271</ATTRIBUTE>
<ATTRIBUTE NAME="Version">5: 5: 0: 423</ATTRIBUTE>
</OBJECT>
</CLASS>
<ASSET>
<INVENTORY>
</RESOURCE>
</RESOURCE_TYPE>
</AEXDATAEXTRACT>

===================================================================


Expected Output --------------- ---------------

DTD_VERSION,EXTRACT_START_DATETIME,EXTRACT_TYPE,EXTRACT_COLLECTION,ParentID,GU
ID,NAME,DESCRIPTION,SOURCE,CREATED_DATE,MODIFIED_DATE,DELETED,ParentID,GUID,NA
MESOURCE,SITE_CODE,DOMAIN,SYSTEM_TYPE,OS_NAME,OS_TYPE,OS_VERSION,OS_REVISION,L
AST_LOGON_USER,LAST_LOGON_DOMAIN,ParentID,SelfID(Inventory),ParentID(Inventory
),SelfID(Asset),TableName,ParentID(Assetid), SelfID(idForTable1 i.e.
Identification),Name,Domain,Altkey1,Altkey2,ParentID(Asset node is
parent),SelfID(idForTable2),Agent Name,Product Version,Build Number,Install
Path,ParentID(Asset node id),SelfID(Self id for table3),Collection Time,File
Count,Total Size,Version


2.2,1/9/2003,4:49:39 PM,FULL,,ParentID,{493435f7-3b17-4c4c-b07f-c23e7ab7781f},Computer,Asset Type definition for Computer,Asset, 7/16/2002 5:22:23 PM,9/23/2002 2:17:48 PM,0,ParentId,{C116FCBF-5B94-4F15-BF95-5795DBD384CD},ALTIRISTEST_CPQ,,756win,F IDD,Win32,Microsoft Windows XP,Professional,5.1,Service Pack 1,,,ParentID,InventoryID(selfId),ParentID(Inventory ID),AssetID(selfid),TableName(Identification),ALTIRISTEST_CPQ,FIDDOMRTLSLC,,00 -02-A5-1A-67-A6

,,,,,,,,,,,,,,,,,,,,,,,,,,,,(Inventory
ID),AssetID(selfid),TableName(ClientAgent),parentID(AssetID),TableID(obtained
using generateid()),Altiris eXpress NS Client,5.5.0.517,517,C:\Program
Files\Altiris\eXpress\NS Client
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Altiris eXpress Inventory
Solution,5.5.0.424,424,C:\Program Files\Altiris\eXpress\NS Client\Software
Delivery\Software Packages\{01B54EB5-3679-4C73-9E10-E169D5A5EC59}
,,,,,,,,,,,,,,,,,,,,,,,,,,,,(Inventory
ID),AssetID(selfid),TableName(Inventory_Results),,,,,,ParentID(AsseId),TableID
,1/9/2003 3:06:56 AM,3,139271,5: 5: 0: 423

and so on....


======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list




Current Thread
Keywords