We have Sterling B2B Integrator for our EDI processing. I have a need to add the date to a file name, however, I need to assign yesterday's date and have not found a good option. I'm too new to xslt to figure it out.
It is in xlst 1.0. It looks like we have a date extension - xmlns:date="http://exslt.org/dates-and-times
I have this set up in our style sheet which works to give me the date for when it's run. Any non complex suggestions on how to get this to be yesterday's date?
<xsl:variable name="CUSTOM4">
<xsl:value-of select="date:format-date(date:date(),'yyyyMMdd')"/>
</xsl:variable>
I found this link to help your question.I think this is the one what you need to get privious day.
http://www.xsltfunctions.com/xsl/functx_previous-day.html
Good Luck !
You might have better luck computing the date using a BP then injecting it as a parameter to the XSLT
Here is a BP fragment:
<operation name="PreviousDay">
<participant name="TimestampUtilService"/>
<output message="TimestampUtilServiceArgs">
<assign to="." from="*"></assign>
<assign to="action">add</assign>
<assign to="baseTime">now</assign>
<assign to="format">yyyyMMdd</assign>
<assign to="offsetTime">-1</assign>
<assign to="scale">day</assign>
</output>
<input message="inmsg">
<assign to="." from="*"></assign>
</input>
</operation>
Related
I want to compare two dates in XSLT (1.0). Here I have mentioned hard coded dates
<xsl:variable name="DATE1" select="ms:format-date(16-FEB-19, 'dd-MMM-yy')" />
<xsl:variable name="DATE2" select="ms:format-date(01-MAY-19, 'dd-MMM-yy')" />
<xsl:if test="$DATE1 $lt; $DATE2">
</xsl:if>
I tried above but not getting proper result.
It looks like you're using some kind of extension function ms:format-date to format the dates. If you can format them as pure numeric YYYYMMDD then you can compare them as numbers. XSLT 1.0 does not offer a "<" operator for strings, let alone for dates.
Do think about moving forward to a later XSLT version (available from third parties) rather than asking the StackOverflow community to help you use a 20-year old version of the language.
I have the below xsl tag
<RectypeLegType>
<xsl:value-of select="../#id" />
</RectypeLegType>
and there can be two possible out come values of this as shown below..
1) <RectypeLegType>fixedLeg_612822</RectypeLegType>
2)<RectypeLegType>floatingLeg_194743</RectypeLegType>
but i want this value to be dispalyed as
<RectypeLegType>fixedLeg</RectypeLegType>
<RectypeLegType>floatingLeg</RectypeLegType>
now please advise how can i achieve this possible outcome i need to do cheanges in my please advise what changes need to be done
Assuming the underscore will always exist in the id attribute:
<RectypeLegType>
<xsl:value-of select="substring-before(../#id, '_')" />
</RectypeLegType>
I have a xslt code for getting the date from the database.the code is working correctly and I got the output ,but the problem is the date is not in correct format.here is the result.
output: 2013-05-07T11:27:46.7+02:00
my code is
<xsl:variable name="lastchange" select="shop:ExecStoredProcedure('kt_Lastchange',concat('#account:',$accid,',#itemnumber:',id))"></xsl:variable>
<textarea>
<xsl:value-of select ="$lastchange"/>
</textarea>
anyone can help for getting the correctly format of date?
If you are using
XSLT 1.0 version, use EXSLT - date:format-date date extension
XSLT 2.0 version, use built-in: Formatting Dates and Times date extension
Code
<xsl:variable name="dt" as="xs:dateTime" select="xs:dateTime('2012-10-21T22:10:15')"/>
<xsl:value-of select="format-dateTime($dt, '[Y0001]/[M01]/[D01]')"/>
I am trying to create a mapping between two different elements(Element1 & Element2) from source schema to the same record on Destination Schema along with an element in it as shown in the following format.
<coverages>
//If Element1(Source Schema element) has data
<coverage>
<CoverageTypeCd>Data1</CoverageTypeCd>
</coverage>
//If Element2(Source Schema element) has data
<coverage>
<CoverageTypeCd>Data2</CoverageTypeCd>
</coverage>
</coverages>
I am now trying to check the presence of value on Elements(Source Schema) and then trying to feed it to the scripting functoid. I don’t know how I should produce the entire
<coverage> node and still send the respective <coverageTypeCd> of that record as shown above. I believe it should be done with Inline XSLT. I really need someone’s help on this.
Thanks in advance.
Please let me know if you need additional details on something.
Update
Hi folks, I found the answer myself. I used Inline XSLT Call template as Script Type and it did the job. I applied this script for different elements on Source Schema to map the Coverage record
<xsl:template name="CoverageTemplate1">
<xsl:param name="Element1" />
<xsl:element name="Coverage">
<xsl:element name="CoverageTypeCd">
<xsl:value-of select="$Element1" />
</xsl:element>
</xsl:element>
</xsl:template>
Thanks
I found the answer myself. I used "Inline XSLT Call template" as Script Type and it did the job. I applied this script for different elements on Source Schema to map the Coverage record
<xsl:template name="CoverageTemplate1">
<xsl:param name="Element1" />
<xsl:element name="Coverage">
<xsl:element name="CoverageTypeCd"><xsl:value-of
select="$Element1" /></xsl:element>
</xsl:element>
</xsl:template>
Thanks
We have in input an XML like following:
<R>
<MT N="folder" V="Folder1\Subfolder1" />
<MT N="folder" V="Folder2xx\Subfolder1" />
<MT N="folder" V="Folder3yyyy\Subfolder1" />
<MT N="folder" V="Folder4zzzz\Subfolder1" />
</R>
In our XSLT that performs the display, the entry:
<xsl:value-of select="MT[#N='folder']/#V"/>
displays:
Folder1\Subfolder1 Folder2xx\Subfolder1 Folder3yyyy\Subfolder1 Folder4zzzz\Subfolder1
What we need to achieve is to select the unique entry who starts with a pre-defined configurable list of strings, e.g. if our pre-defined list is
Folder2xx, Folder18ppp, Folder212aaa
I would like to display as output only
Folder2xx\Subfolder1
The optimal thing would be even:
Folder2xx\Subfolder1 (linked 3 times)
but I would really appreciate help on the selection of the unique element.
That is unfortunately too complex for my knowledge on XSLT, can someone please help?
Our system supports XSLT 2.0 and XPATH 2.0
thanks a lot!
Mario
Use:
MT[#N='folder']
/#V[substring-before(.,'\')
=
('Folder2xx', 'Folder18ppp', 'Folder212aaa')
]