Jump to content
Sign in to follow this  
Amyla

extract hour from dateand put it in a new tag

Recommended Posts

Hi all,

I need help with this xml file:

<?xml version="1.0" encoding="ISO-8859-1"?>
<output>
<orders>
<order>
<id>1</id>
<number>10002</number>
<type>Loading</type>
<date>2013-01-01T02:30:00</date>
</order>
<order>
<id>2</id>
<number>10003</number>
<type>Loading</type>
<date>2013-01-01T010:30:00</date>
</order>
<order>
<id>3</id>
<number>10004</number>
<type>Loaded</type>
<date>2013-01-01T12:30:00</date>
</order>
</orders>
<quantities>
<quantity>
<id_order>1</id_order>
<unit>KG</unit>
<value>1000</value>
</quantity>
<quantity>
<id_order>1</id_order>
<unit>PAL</unit>
<value>3</value>
</quantity>
<quantity>
<id_order>1</id_order>
<unit>M3</unit>
<value>1.5</value>
</quantity>
<quantity>
<id_order>2</id_order>
<unit>KG</unit>
<value>2000</value>
</quantity>
<quantity>
<id_order>2</id_order>
<unit>PAL</unit>
<value>4</value>
</quantity>
<quantity>
<id_order>3</id_order>
<unit>KG</unit>
<value>5000</value>
</quantity>
</quantities>
</output>
i need to add an extra tag <hour> after >date> nd in this new tg put te value of time (hh:mm) find in date.
I've managed to do this (but it only create the tag and don't put th hours in it)
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="date">
<xsl:copy-of select="."/>
<hour>
<xsl:value-of select="substring(output/orders/order/date,12,5)"/>
</hour>
</xsl:template>
</xsl:stylesheet>
please help me

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...