Altova Mailing List Archives
>microsoft.public.xsl Archive Home
>Thread Prev - How can I convert an XML file to a simple .txt fle?
>Thread Next - Re: How can I convert an XML file to a simple .txt fle?
Re: How can I convert an XML file to a simple .txt fle?
Date: 2/4/2010 9:24:00 AM
I don't understand what you are not abble to do, is it to convert the date, tou count the lines? Why do you have the test about the dueback? Is it to define if a VTMedia has to be in the result? I think that you are on the right way. To convert the date to your output format, you have to use the substring-before and substring-after to extract the month, the day and the year, and after to use the choose/when to convert your month from letters to numbers. To count the line you can use the count function with a criteria for example ; count(VTMedia[@dueback > 0]) I hope to help you Marc Le 04/02/2010 00:58, Bill a Ã©crit : > Hi, > > I've been playing around with using an XSL file to try and reformat this XML > file to plain text but thus far my efforts have been fruitless and was hoping > someone could give me a hand. I'm told what I am trying to do is simple but > I'm not much of a programmer :) > > So far I got it to export the data like this in InternetExplorer: > > StartHeaderText~D~999999~IronMountain~EndHeaderText > > > Barcode > OR1387L3 > Return Date > Jan 20 2015 6:59PM > Barcode > OR1363L3 > Return Date > Feb 3 2011 6:00PM > > But I need the data to dump to a txt and look like this, to maintain > compatibility with our vendor: > > StartHeaderText~D~999999~IronMountain~EndHeaderText > OR1387 XX --- > 01202015 > OR1363 XX --- > 02032011 > StartFooterText~D~999999~IronMountain~2~EndFooterText > > (The 2 in the above line signifies how many items were listed, and also the > L3 was removed from the OR1363/OR1387) > > Here's the XSL file I put together: > > <?xml version="1.0" encoding="UTF-8"?> > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > <xsl:template match="/"> > <BR/> > > StartHeaderText~D~999999~IronMountain~EndHeaderText<BR/> > > <BR/> > <xsl:for-each select="GXReportData/VaultTrackingTable/VTMedia"><BR/> > <xsl:text>Barcode > </xsl:text><BR/> > <xsl:value-of select="@barCode"/><BR/> > <xsl:text>Return Date > </xsl:text><BR/> > <xsl:choose> > <xsl:when test="@dueback< 0">Never</xsl:when> > <xsl:when test="@dueback=0">Now</xsl:when> > <xsl:otherwise><xsl:value-of select="@duebackTime"/></xsl:otherwise> > </xsl:choose> > </xsl:for-each> > <BR/> > </xsl:template> > </xsl:stylesheet> > > > And here's what the XML looks like (you'll notice there's much more data in > here then I actually need for my TXT file): > > <?xml version='1.0' encoding='utf-8' ?> > <?xml-stylesheet type="text/xsl" > href="./GalaxyReport_VaultTrackingReport_5252_1265237690.xsl"?> > <GXReportData> > <GXReportTitle>Vault Tracking Report - IronMountain</GXReportTitle> > <GXReportTime>Report 8.0.0(BUILD68) generated on 02/03/2010 14:54:49 > </GXReportTime> > <GXReportCCID>CommCell ID: F9999</GXReportCCID> > <GXReportCSName>CommCell: Commvaultsvr</GXReportCSName> > <GXReportCriteria> > <GXReportOption>Source Libraries:All</GXReportOption> > <GXReportOption>Source Media Repositories:All</GXReportOption> > <GXReportOption>Destination Libraries:All</GXReportOption> > <GXReportOption>Destination Media Repositories:All</GXReportOption> > <GXReportOption>Source Locations:All</GXReportOption> > <GXReportOption>Tracking Policies:All</GXReportOption> > <GXReportOption>Report Copy Location:C:\IronMountain</GXReportOption> > <GXReportOption>Locale:English</GXReportOption> > <GXReportOption>Time Zone:</GXReportOption> > <GXReportOption>View from:</GXReportOption> > <GXReportOption>View to:</GXReportOption> > </GXReportCriteria> > <VaultTrackingTable><VTMedia barCode="OR1387L3" actionId="0" library="IBM > 3576-MTL 2" policy="Weekly Exports to Iron Mountain" policyId="1" > dueback="1421780348" duebackTime="Jan 20 2015 6:59PM" user="N/A" jobId="0" > current="IBM 3576-MTL 2 slot 17" container="N/A" source="IBM 3576-MTL 2" > destination="IronMountain" startTime="0" startTimeStr="" endTime="0" > endTimeStr="" jobStatus="0" SP="SP_F_Drive (Staging)(Commvaultsvr)" > copy="WriteToTape"><VTMediaSide side="1" status="1" lastRead="Jan 22 2010 > 8:13AM " lastWrite="" totalData="24806"/></VTMedia><VTMedia > barCode="OR1363L3" actionId="0" library="IBM 3576-MTL 2" policy="Weekly > Exports to Iron Mountain" policyId="1" dueback="1296756010" duebackTime="Feb > 3 2011 6:00PM" user="N/A" jobId="0" current="IBM 3576-MTL 2 slot 18" > container="N/A" source="IBM 3576-MTL 2" destination="IronMountain" > startTime="0" startTimeStr="" endTime="0" endTimeStr="" jobStatus="0" > SP="CommServeDR(CommvaultMsvr)" copy="Primary"><VTMediaSide side="1" > status="1" lastRead="Feb 3 2010 6:02PM " lastWrite="" > totalData="1966"/></VTMedia></VaultTrackingTable> > </GXReportData> > > It's certainly possible I'm going about this in completely the wrong way, so > I'm open to suggestions. > > Thanks for your help! > >