1
<Scheduled>
 <xsl:value-of select="//RequestParameters/Identifier/DepartureDate">
 </xsl:value-of>
 </Scheduled> 

In this xslt code iam getting a last character as 'z' in "//RequestParameters/Identifier/DepartureDate" i want to remove z and please help on this.

shiva tatikonda
  • 91
  • 2
  • 4
  • 14

2 Answers2

3

If the value of //RequestParameters/Identifier/DepartureDate contains 'z' only at the end, you can use substring-before function.

<xsl:value-of select="substring-before(//RequestParameters/Identifier/DepartureDate, 'z')">

edit:

If you want to get the first 10 characters of the value, you can use substring function.

<xsl:value-of select="substring(//RequestParameters/Identifier/DepartureDate, 1, 10)">
snak
  • 6,483
  • 3
  • 23
  • 33
  • thanks snak. Here DepartureDate is of type date for eg value is 2011-10-16T09:40:00.000Z but i need in output(preserve) only ten characters i.e 2011-10-16.Could you please help on this? – shiva tatikonda Feb 28 '13 at 06:14
  • You can use substring function for the purpose. Updated the answer. – snak Feb 28 '13 at 06:42
0

In general, you may want to convert an element value in ISO 8601 date format to another format by adding a javascript function to your xslt, and call that function in your Xpath expression. For instance, when you have added a (javascript) function convertToDate that extracts the date part of the input value in the format yyyymmdd, the Xpath expression

convertToDate (//RequestParameters/Identifier/DepartureDate)

will result in a value

20111016

assuming there is only one DepartureDate element in the input, having value

2011-10-16T09:40:00.000Z
Maestro13
  • 3,656
  • 8
  • 42
  • 72