Generate today's date in output
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 13
- Joined: Mon Dec 18, 2017 10:52 pm
Generate today's date in output
Does Oxygen or DITA have a field or similar that can be inserted in the DITA code in order to show today's date in the output when a transform runs? I have code similar to the following in a content file, and want to auto-populate the date, based on the date when the transform runs: <p>Update Date: <DATE GOES HERE></p>
-
- Site Admin
- Posts: 275
- Joined: Thu Dec 24, 2009 11:21 am
Re: Generate today's date in output
Hello,
There is no out of the box setting that would allow you to insert the current date or time in the generated output.
However, for the WebHelp Responsive output, you can achieve this behavior by contributing a custom XSLT extension stylesheet.
You can use the following example as starting point: https://www.oxygenxml.com/doc/versions/ ... hp1_phg_dx
You can find the sample files for the above example on GitHub (see the "Generation Date & Time" template): https://github.com/oxygenxml/oxygen-pub ... te-samples
Regards,
Alin
There is no out of the box setting that would allow you to insert the current date or time in the generated output.
However, for the WebHelp Responsive output, you can achieve this behavior by contributing a custom XSLT extension stylesheet.
You can use the following example as starting point: https://www.oxygenxml.com/doc/versions/ ... hp1_phg_dx
You can find the sample files for the above example on GitHub (see the "Generation Date & Time" template): https://github.com/oxygenxml/oxygen-pub ... te-samples
Regards,
Alin
Alin Balasa
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 72
- Joined: Tue Oct 21, 2014 10:01 pm
Re: Generate today's date in output
We use this method for obtaining the current year for our copyrights page:
This page might be of help as well to build the publication date that you desire:
https://www.w3schools.com/js/js_date_methods.asp
Code: Select all
<xsl:param name="YEAR" select="year-from-dateTime(current-dateTime())"/>
https://www.w3schools.com/js/js_date_methods.asp
-
- Posts: 13
- Joined: Mon Dec 18, 2017 10:52 pm
Re: Generate today's date in output
Thanks for the suggestions! I am generating PDF output, and new to XSL. Similar to the YEAR example that you provided, I found the format below online for an MM/DD/YY date, but it appears that you cannot simply paste this into the DITA; the transform fails. Can anyone tell me how to add this code in a way that generates the date in the output? Does the DITA code have to call the variable somehow, after the variable is defined?
HERE IS THE CODE THAT CAUSES MY TRANSFORM TO FAIL:
<p>Update Date: <xsl:variable name="bc.currentDate"
select="format-date(current-date(), '[M01]/[D01]/[Y0001]')"/></p>
HERE IS THE CODE THAT CAUSES MY TRANSFORM TO FAIL:
<p>Update Date: <xsl:variable name="bc.currentDate"
select="format-date(current-date(), '[M01]/[D01]/[Y0001]')"/></p>
-
- Site Admin
- Posts: 275
- Joined: Thu Dec 24, 2009 11:21 am
Re: Generate today's date in output
Hello,
You cannot use XSLT fragments directly in the DITA sources. If you want to customize the PDF output you can have a look at this topic in our User Manual:
https://www.oxygenxml.com/doc/versions/ ... ation.html
You can also read more about this subject in the DITA-OT 2.x documentation:
http://www.dita-ot.org/dev/topics/pdf-c ... ation.html
Regards,
Alin
You cannot use XSLT fragments directly in the DITA sources. If you want to customize the PDF output you can have a look at this topic in our User Manual:
https://www.oxygenxml.com/doc/versions/ ... ation.html
You can also read more about this subject in the DITA-OT 2.x documentation:
http://www.dita-ot.org/dev/topics/pdf-c ... ation.html
Regards,
Alin
Alin Balasa
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
Return to “DITA (Editing and Publishing DITA Content)”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service