First time posting and am very new to working with XML and XSL.
I've spent two days on this board and others looking for my answer. I see posts similar to mine, but not exact. My apologies if this is redundant.
I have an XML document output to me from a 3rd party application on a daily basis. I need to display on a webpage two pieces of information from it: LoginName and LastBackupDate.
I am able to do this via an XSL that I wrote. However, the LastBackupDate is in epoch format. I need to convert it to human readable Date/Time (mm-dd-yyyy hh:mm:ss).
Is it possible to convert this "on the fly" via an XSL stylesheet?
If so, can somebody assist? I've tried so many variations of what I've found here and on several other websites that I'm now at a loss...
What is definitely making this more difficult for me is the format of the XML file - it is mostly attributes. Most every example I find uses elements.
Here is my XML (company1.xml):
<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="company1.xsl" ?>
<Users>
<User LoginName="server1" Owner="company1" UserId="server1#24545" Alias="server1" UserType="PAID" ClientType="ERM" Quota="536870912000" Timezone="GMT+01:00 (CEST)" Language="en" DataFile="191277" DataSize="120105299488" RetainFile="1195" RetainSize="49220308" EnableMSSQL="Y" EnableMSExchange="N" MsExchangeQuota="0" EnableOracle="N" EnableLotusNotes="N" EnableLotusDomino="N" EnableMySQL="N" EnableInFileDelta="Y" EnableShadowCopy="Y" EnableExchangeMailbox="N" ExchangeMailboxQuota="0" EnableNASClient="N" EnableDeltaMerge="N" EnableMsVm="N" MsVmQuota="0" EnableVMware="N" VMwareQuota="0" Bandwidth="0" Notes="" Status="ENABLE" RegistrationDate="1222175386552" SuspendPaidUser="N" SuspendPaidUserDate="20110221" LastBackupDate="1421247632689" EnableCDP="Y" EnableShadowProtectBareMetal="Y" EnableWinServer2008BareMetal="Y" Hostname="backup.company1.com">
<Contact Name="Spain Reception" Email="spain.reception@company1.com" />
</User>
<User LoginName="server2" Owner="company1" UserId="server2#24545" Alias="server2" UserType="PAID" ClientType="ERM" Quota="536870912000" Timezone="GMT-06:00 (CDT)" Language="en" DataFile="123920" DataSize="69665584875" RetainFile="0" RetainSize="0" EnableMSSQL="Y" EnableMSExchange="N" MsExchangeQuota="0" EnableOracle="N" EnableLotusNotes="N" EnableLotusDomino="N" EnableMySQL="N" EnableInFileDelta="Y" EnableShadowCopy="Y" EnableExchangeMailbox="N" ExchangeMailboxQuota="0" EnableNASClient="N" EnableDeltaMerge="N" EnableMsVm="N" MsVmQuota="0" EnableVMware="N" VMwareQuota="0" Bandwidth="0" Notes="" Status="ENABLE" RegistrationDate="1212767489088" SuspendPaidUser="N" SuspendPaidUserDate="20141223" LastBackupDate="1361926839272" EnableCDP="Y" EnableShadowProtectBareMetal="Y" EnableWinServer2008BareMetal="Y" Hostname="backup.company1.com">
<Contact Name="server2" Email="IT.systemadministrators@company.com" />
</User>
</Users>
Here is my XSL (company1.xsl):
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://ift.tt/tCZ8VR">
<xsl:template match="/">
<html>
<body>
<h3>COMPANY1 Last Backup Date</h3>
<table border="1">
<tr bgcolor="#9acd32">
<th>LoginName</th>
<th>Epoch LastBackupDate</th>
<th>Human dateTime</th>
</tr>
<xsl:for-each select="//User">
<tr>
<td>
<xsl:value-of select="@LoginName" />
</td>
<td>
<xsl:value-of select="@LastBackupDate" />
</td>
<td>
<xsl:value-of select='xs:dateTime("1970-01-01T00:00:00") @LastBackupDate * xs:dayTimeDuration("PT0.001S")'/>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
No comments:
Post a Comment