spotmoose
asked on
IE Client XSL
The following is a partial example of the XML data.
<resource>
<name>Doe, John</name>
<year>
<month id=”May”>
<day id=”050106”><start>Unavail able</star t><stop>Un available< /stop></da y>
<day id=”050206”><start>Unavail able</star t><stop>Un available< /stop></da y>
<day id=”050306”><start>07:00:0 0</start>< stop>15:30 :00</stop> </day>
<day id=”050406”><start>07:00:0 0</start>< stop>15:30 :00</stop> </day>
<day id=”050506”><start>07:00:0 0</start>< stop>15:30 :00</stop> </day>
<day id=”050606”><start>07:00:0 0</start>< stop>15:30 :00</stop> </day>
<day id=”050706”><start>Vacatio n</start>< stop>Vacat ion</stop> </day>
</month>
<month id="June">
</month>
</year>
</resource>
I need a transformation to make the data look like the following in table format:
Name: Doe, John
Date Start End
Monday, May 01, 2006 07:00:00 15:30:00
Sunday, May 07, 2006 Unavailable Unavailable
<resource>
<name>Doe, John</name>
<year>
<month id=”May”>
<day id=”050106”><start>Unavail
<day id=”050206”><start>Unavail
<day id=”050306”><start>07:00:0
<day id=”050406”><start>07:00:0
<day id=”050506”><start>07:00:0
<day id=”050606”><start>07:00:0
<day id=”050706”><start>Vacatio
</month>
<month id="June">
</month>
</year>
</resource>
I need a transformation to make the data look like the following in table format:
Name: Doe, John
Date Start End
Monday, May 01, 2006 07:00:00 15:30:00
Sunday, May 07, 2006 Unavailable Unavailable
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
spotmoose,
> <?xml-stylesheet type="text/css" href="test.xsl"?>
well, you get the data, tags stripped, because the XSLT is not called
you have to correct the above line to expect a XSLT instead of a CSS
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
will work
cheers
> <?xml-stylesheet type="text/css" href="test.xsl"?>
well, you get the data, tags stripped, because the XSLT is not called
you have to correct the above line to expect a XSLT instead of a CSS
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
will work
cheers
spotmoose,
I changed the last template and added a named template,
in order to normalise the Date
<xsl:template match="day">
<tr>
<td>
<xsl:call-template name="normaliseDate">
<xsl:with-param name="curDate" select="@id"/>
</xsl:call-template>
</td>
<td><xsl:value-of select="start"/></td>
<td><xsl:value-of select="stop"/></td>
</tr>
</xsl:template>
<xsl:template name="normaliseDate">
<xsl:param name="curDate"/>
<xsl:text>20</xsl:text>
<xsl:value-of select="substring($curDate , 5,2)"/>
<xsl:text>-</xsl:text>
<xsl:value-of select="substring($curDate , 1,2)"/>
<xsl:text>-</xsl:text>
<xsl:value-of select="substring($curDate , 3,2)"/>
</xsl:template>
I changed the last template and added a named template,
in order to normalise the Date
<xsl:template match="day">
<tr>
<td>
<xsl:call-template name="normaliseDate">
<xsl:with-param name="curDate" select="@id"/>
</xsl:call-template>
</td>
<td><xsl:value-of select="start"/></td>
<td><xsl:value-of select="stop"/></td>
</tr>
</xsl:template>
<xsl:template name="normaliseDate">
<xsl:param name="curDate"/>
<xsl:text>20</xsl:text>
<xsl:value-of select="substring($curDate
<xsl:text>-</xsl:text>
<xsl:value-of select="substring($curDate
<xsl:text>-</xsl:text>
<xsl:value-of select="substring($curDate
</xsl:template>
ASKER
sorry for the problem I induced
works and adjusted table to have border. Thanks. The links to the date part of the question would be appreciated.
However, if you can't find the links is there a way to make the date look like 05/01/06 will be just as good for what I need
works and adjusted table to have border. Thanks. The links to the date part of the question would be appreciated.
However, if you can't find the links is there a way to make the date look like 05/01/06 will be just as good for what I need
ASKER
Works!
I would like somthing similiar to Monday, May 01, 2006
But beggar can't be choosy!
I will close the quest and give you the points. However, if you can provide any links or simliar format let me know.
I would like somthing similiar to Monday, May 01, 2006
But beggar can't be choosy!
I will close the quest and give you the points. However, if you can provide any links or simliar format let me know.
ASKER
Great help and support. Quick and allowed me to make a mistake without hammering me.
spotmoose,
> date look like 05/01/06
change the named template into
<xsl:template name="normaliseDate">
<xsl:param name="curDate"/>
<xsl:value-of select="substring($curDate , 1,2)"/>
<xsl:text>/</xsl:text>
<xsl:value-of select="substring($curDate , 3,2)"/>
<xsl:text>/</xsl:text>
<xsl:value-of select="substring($curDate , 5,2)"/>
</xsl:template>
There is no standard functionality in XSLT1.0 to get the weekday of a certain date for example
(well you can plug in a template that does the entire calculation, with leap years and all that)
So it requires some workarounds to get there (and some are not XSLT processor independent)
if you want to see what it takes,
you can look at www.exslt.org in the dates section
exslt is a standardisation effort for xslt extensions
here is an answer I gave to an earlier question that uses a template from exslt
cheers
> date look like 05/01/06
change the named template into
<xsl:template name="normaliseDate">
<xsl:param name="curDate"/>
<xsl:value-of select="substring($curDate
<xsl:text>/</xsl:text>
<xsl:value-of select="substring($curDate
<xsl:text>/</xsl:text>
<xsl:value-of select="substring($curDate
</xsl:template>
There is no standard functionality in XSLT1.0 to get the weekday of a certain date for example
(well you can plug in a template that does the entire calculation, with leap years and all that)
So it requires some workarounds to get there (and some are not XSLT processor independent)
if you want to see what it takes,
you can look at www.exslt.org in the dates section
exslt is a standardisation effort for xslt extensions
here is an answer I gave to an earlier question that uses a template from exslt
cheers
ASKER
Thanks! I really appreciate the help.
you are welcome
it just occurs to me that I forgot to paste the URL of the question
here it is
https://www.experts-exchange.com/questions/21850319/Format-Date-in-XSL.html
cheers
it just occurs to me that I forgot to paste the URL of the question
here it is
https://www.experts-exchange.com/questions/21850319/Format-Date-in-XSL.html
cheers
ASKER
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/css" href="test.xsl"?>
<resource>
<name>Doe, John</name>
<year>
<month id="May">
<day id="050106"><start>Unavail
<day id="050206"><start>Unavail
<day id="050306"><start>07:00:0
<day id="050406"><start>07:00:0
<day id="050506"><start>07:00:0
<day id="050606"><start>07:00:0
<day id="050706"><start>Vacatio
</month>
<month id="June">
<day id="060106"><start>Unavail
<day id="060206"><start>Unavail
<day id="060306"><start>07:00:0
<day id="060406"><start>07:00:0
<day id="060506"><start>07:00:0
<day id="060606"><start>07:00:0
<day id="060706"><start>Vacatio
</month>
</year>
</resource>
I get the following (two lines of data not in a table format):
Doe, John UnavailableUnavailable UnavailableUnavailable 07:00:0015:30:00 07:00:0015:30:00 07:00:0015:30:00 07:00:0015:30:00 VacationVacation UnavailableUnavailable UnavailableUnavailable 07:00:0015:30:00 07:00:0015:30:00 07:00:0015:30:00 07:00:0015:30:00 VacationVacation