xml - Add tag <hour> that will contain time hh:mm from date -
i have 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>
i need extract time date of every order , put in new tag after date. i've managed create tag
<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>
but doesn't work, cant' show time in new tag.
can me please?
br
current context element <date>
already, can use .
instead of output/orders/order/date
here :
<xsl:value-of select="substring(.,12,5)"/>
Comments
Post a Comment