0

I have this xml

<?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>

Now Im trying to add another node, in the first xml which should basically have value of copied value <date> stripped to show only after hours (hh:mm:ss). I've managed to create a copy of the original xml and add the extra tag, but I'm not sure on how to extract the hour data and show in inside tags. I've tried few other workarounds but none worked to my desired output. If anyone could suggest anything or help in any way I would appreciate it.

this is my code

<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:comment> <xsl:copy-of select="substring(output/orders/order/date,11)"/> </xsl:comment>
       </hour>
   </xsl:template>

</xsl:stylesheet>
2
Contributors
1
Reply
22
Views
2 Years
Discussion Span
Last Post by xml_looser
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.