Subject: [xsl] Column Heads and Column Data problem ?? From: Dipesh Khakhkhar <dkhakhkh@xxxxxxxxxxxxxxx> Date: Tue, 19 Aug 2003 23:36:25 -0400 |
Hi , Still I am finding difficult to put column header and data according to column header in my output. Here once again i am rephrasing my problem. This is actually i m trying to do. I have arrange my email like first input then expected output then interpretation and the current xsl which I have written. I am having input like (Shorteninng it) 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.... Note: ==== All the things in the bracket are just for understanding since it is very very complicated to explain (for me atleast :)) Interpretation: =============== Depending on the input i have get the output dynamically. I am able to get the output without column header. But after putting the column header conditions and the type of output i am expecting i am trying hard to get it. My xml has many tables corresponding to the database where this data will be feed. In the above output i have mentioned about ParentId and SelfId. This is am generating using generate-id() function. This i am able to do well and its working as required. Creating Primary key and Foreign key as required in the database. Here withing inventory tag i have mentioned about asset tag, which also contains different tags. Each Object tag within Class tag corresponds to the row in the database for the table identified either by tag named "class" (i.e. name is given in the attribute of class tag) or by tag named identification. Like asset tag within inventory tag there are 3 other tags and for that i thought to write seperate xsl for each. As of now i have written the xsl to get data only which i m pasting below. Since as i have discussed I am writting a control file to read the text file generated from the data. This control file is mapping data to the DB. Now since there can be situation like few column names will appear in one table at one place in the same xml and few won't. So depending on this i have to get the data and map it. Thats why i am creating the column header with each table having maximum columns in the whole xml. Depending on my column header i will create control file dynamically and if i do this then there won't be any chance to mismatch data in the xml and that in the DB. Current xsl: ============ <?xml version="1.0" encoding="ISO-8859-1" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"> <xsl:output encoding="ISO-8859-1"/> <xsl:param name = "uniqbatchid"> </xsl:param> <xsl:template match="/"> <xsl:for-each select="/AEXDATAEXTRACT"> <xsl:text> </xsl:text> <xsl:value-of select="$uniqbatchid"/>`<xsl:value-of select="@DTD_VERSION"/>`<xsl:value-of select="@EXTRACT_START_DATETIME"/>`<xsl:value-of select="@EXTRACT_TYPE"/>`<xsl:value-of select="@UPDATE_SINCE_DATETIME"/><xsl:apply-templates select="RESOURCE_TYPE"/> </xsl:for-each> </xsl:template> <xsl:template match="RESOURCE_TYPE">`<xsl:value-of select="@GUID"/>`<xsl:value-of select="$uniqbatchid"/>`<xsl:value-of select="@NAME"/>`<xsl:value-of select="@DESCRIPTION"/>`<xsl:value-of select="@SOURCE"/>`<xsl:value-of select="@CREATED_DATE"/>`<xsl:value-of select="@MODIFIED_DATE"/>`<xsl:value-of select="@DELETED"/> <xsl:apply-templates select="RESOURCE"/> <xsl:if test="not (position()=last())"> <xsl:text> `````</xsl:text> </xsl:if> </xsl:template> <xsl:template match="RESOURCE">`<xsl:value-of select="@GUID"/>`<xsl:value-of select="//AEXDATAEXTRACT//RESOURCE_TYPE//@GUID"/>`<xsl:value-of select="@NAME"/>`<xsl:value-of select="@SOURCE"/>`<xsl:value-of select="@SITE_CODE"/>`<xsl:value-of select="@DOMAIN"/>`<xsl:value-of select="@SYSTEM_TYPE"/>`<xsl:value-of select="@OS_NAME"/>`<xsl:value-of select="@OS_TYPE"/>`<xsl:value-of select="@OS_VERSION"/>`<xsl:value-of select="@OS_REVISION"/>`<xsl:value-of select="@LAST_LOGON_USER"/>`<xsl:value-of select="@LAST_LOGON_DOMAIN"/> <xsl:apply-templates select="INVENTORY"/> <xsl:if test="not (position()=last())"> <xsl:text> ````````````</xsl:text> </xsl:if> </xsl:template> <xsl:template match="INVENTORY">`<xsl:value-of select="generate-id(.)"/>`<xsl:value-of select="..//@GUID"/><xsl:apply-templates select="ASSET"/></xsl:template> <xsl:template match="ASSET">`<xsl:value-of select="generate-id(.)"/>`<xsl:value-of select="generate-id(..)"/> <xsl:apply-templates select="IDENTIFICATION"/> <xsl:apply-templates select="cLASS"/> </xsl:template> <xsl:template match="IDENTIFICATION">`IDENTIFICATION`<xsl:value-of select="generate-id(.)"/>`<xsl:value-of select="generate-id(..)"/><xsl:for-each select="ATTRIBUTE">`<xsl:value-of select="."/></xsl:for-each> </xsl:template> <xsl:template match="CLASS"> <xsl:choose> <xsl:when test="normalize-space(@NAME)='Client_Agent'">`<xsl:value-of select="@NAME"/>``````6<xsl:for-each select="OBJECT">`<xsl:value-of select="generate-id(.)"/>`<xsl:value-of select="generate-id(../..)"/><xsl:for-each select="ATTRIBUTE">`<xsl:value-of select="."/></xsl:for-each> <xsl:if test="not (position()=last())"> <xsl:text> ````````````````````````````````````</xsl:text> </xsl:if> </xsl:for-each> </xsl:when> <xsl:when test="normalize-space(@NAME)='Inventory_Results'"><xsl:text> </xsl:text>```````````````````````<xsl:value-of select="generate-id(..)"/>`<xsl:value-of select="generate-id(../..)"/>`<xsl:value-of select="@NAME"/>``````````<xsl:for-each select="OBJECT">`<xsl:value-of select="generate-id(.)"/>`<xsl:value-of select="generate-id(../..)"/><xsl:for-each select="ATTRIBUTE">`<xsl:value-of select="."/></xsl:for-each> <xsl:if test="not (position()=last())"> <xsl:text> ````````````````````````````````````````</xsl:text> </xsl:if> </xsl:for-each> </xsl:when> <xsl:when test="normalize-space(@NAME)='User_General_Details'"><xsl:text> </xsl:text>```````````````````````<xsl:value-of select="generate-id(..)"/>`<xsl:value-of select="generate-id(../..)"/>`<xsl:value-of select="@NAME"/>`````````````````````<xsl:for-each select="OBJECT">`<xsl:value-of select="generate-id(.)"/>`<xsl:value-of select="generate-id(../..)"/><xsl:for-each select="ATTRIBUTE">`<xsl:value-of select="."/></xsl:for-each> <xsl:if test="not (position()=last())"> <xsl:text> ```````````````````````````````````````````````````</xsl:text> </xsl:if> </xsl:for-each> </xsl:when> </xsl:choose> </xsl:template> </xsl:stylesheet> --------------------------------------------------------------------- I have used ` as my seperator here. I am passig a parameter which will be date of processing as an input to this xsl file. I am trying to get the output. But till now i am not able to get the desired output as mentioned above. Any help would be highly appreciated. I hope i am not bothering gurus out here. Eagerly waiting for your reply. Regards, Dipesh XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] TRANSFORM WITH SOME XML, Brook Ellingwood | Thread | Re: [xsl] Column Heads and Column D, Wendell Piez |
Re: [xsl] TRANSFORM WITH SOME XML, Brook Ellingwood | Date | RE: [xsl] newbie question about str, Jarno . Elovirta |
Month |