.net - XSLT transformation datetime to date format -


I'm trying to change the date format yyyy-MM-dd to a date format, because I use xsd I am here. XE Tool XS: Date data type is automatically converted into a datetime datatype because there is no type in it. Net framework that matches the type xs: date completely.

But I can not work it

   

XML

  & lt; Articles & gt; & Lt; Articles & gt; & Lt; Articleid & gt; 48,992 & lt; / Articleid & gt; & Lt; Deliverydateasked & gt; 2009-01-29 & lt; / Deliverydateasked & gt; & Lt; / Article & gt; & Lt; Articles & gt; & Lt; Articleid & gt; 48,993 & lt; / Articleid & gt; & Lt; Deliverydateasked & gt; 2009-01-30 & lt; / Deliverydateasked & gt; & Lt; / Article & gt; & Lt; / Article & gt;  

Currently I'm using this XSLT

  & lt; Xsl: stylesheet xmlns: xsl = "http://www.w3.org/1999/xsl/transform" version = "1.0" & gt; & Lt; Xsl: template match = "/" & gt; & Lt; Articles & gt; & Lt; Xsl: Apply-Select Template = "Articles" & gt; & Lt; / XSL: implemented-templates & gt; & Lt; / Article & gt; & Lt; / XSL: Templates & gt; & Lt; Xsl: Template Name = "Format Date" & gt; & Lt; Xsl: Ultimate Name = "DateTime" /> & Lt; Xsl: variable name = "date" & gt; & Lt; Xsl: select value = "substring-before ($ datetime, 't')" /> & Lt; / XSL: variable & gt; & Lt; Xsl: if test = "string-length ($ date)! = 10" & gt; & Lt; Xsl: Select Value = "$ DateTime" /> & Lt; / XSL: If & gt; & Lt; Xsl: if test = "string-length ($ date) = 10" & gt; & Lt; Xsl: Select the value = "$ date" /> & Lt; / XSL: If & gt; & Lt; / XSL: Templates & gt; & Lt; Xsl: template match = "article" & gt; & Lt; Xsl: call-template name = "format date" & gt; & Lt; With xsl: -name = "Date Time" = "Delivery Dataed" / & gt; & Lt; / XSL: Call-templates & gt; & Lt; / XSL: Templates & gt;  

Does any good xslt know changes?

Thank you in advance

The output result of my code is

   Indeed, it looks right about me - sometimes a simple substring is good enough.  

However, if you are in .NET land and you really need additional functionality, then edit NET


: OIC, you've got an original application - Try it for ideological problem templates (see copy and original template match):

   & Lt; Xsl: variable name = "date" & gt; & Lt; Xsl: select value = "substring-before ($ datetime, 't')" /> & Lt; / XSL: variable & gt; & Lt; Xsl: if test = "string-length ($ date)! = 10" & gt; & Lt; Xsl: Select Value = "$ DateTime" /> & Lt; / XSL: If & gt; & Lt; Xsl: if test = "string-length ($ date) = 10" & gt; & Lt; Xsl: Select the value = "$ date" /> & Lt; / XSL: If & gt; & Lt; / XSL: Templates & gt; & Lt; / XSL: stylesheet & gt;  

The templates are a hard concept to learn, it may be better to start with the simplest each , and / or it seems that you Can with some XSLT tutorials / books


Comments