0
votes

At my XSLT 1.0 document I have the following element that contains a String representation of date:

Product/CreateDate =  2017-06

I need to format this String into the following String: 06/2017

Please show how it can be done with XSLT 1.0

UPDATED

This is my current XSLT structure:

<xsl:value-of select="translate(Product/CreateDate, '-', '/')" />
<xsl:if test="not(Product/CreateDate) or (Product/CreateDate='')">
    &#8212;
</xsl:if>

right now it prints: 2017/06 but I need to print 06/2017 instead

1
Where exactly are you stuck with this? -- P.S. Please provide a minimal reproducible example. As it is, it's hard to tell if your input is <CreateDate>2017-06</CreateDate> or <elem>Product/CreateDate = 2017-06</elem>. Likewise for the output. - michael.hor257k
@michael.hor257k I have updated my question with current XSLT - alexanoid

1 Answers

1
votes

Try:

<xsl:value-of select="substring-after(Product/CreateDate, '-')" />  
<xsl:text>/</xsl:text>  
<xsl:value-of select="substring-before(Product/CreateDate, '-')" /> 

Or:

<xsl:value-of select="substring(Product/CreateDate, 6)" />  
<xsl:text>/</xsl:text>  
<xsl:value-of select="substring(Product/CreateDate, 1, 4)" />