New to XML need help
Questions about XML that are not covered by the other forums should go here.
-
- Posts: 3
- Joined: Mon Jun 05, 2017 7:18 pm
New to XML need help
Hi,
I'm new here and new to xml
Basically have this xml code at the moment:
the above code saves file 20170605-0002.psdata to the specified file location.
what I would like to be able to do is instead of having a static filepath string as above, I would like to add the systemtime (current PC time) to the filename.
Can anyone please help me with writing that bit of code? Thanks
I'm new here and new to xml
Basically have this xml code at the moment:
Code: Select all
<?xml version="1.0" encoding="utf-8" standalone="yes"?><document>
<userealtime>False</userealtime>
<event category="Interaction" time="05/06/17 15:39:59.162"> Run.Pressed=False</event>
<event category="Interaction" time="05/06/17 15:40:00.060"> File.SaveAs.IO=C:\My Documents\Waveforms\20170605-0002.psdata</event>
</document>
what I would like to be able to do is instead of having a static filepath string as above, I would like to add the systemtime (current PC time) to the filename.
Can anyone please help me with writing that bit of code? Thanks
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: New to XML need help
Hi,
And how is that XML document generated? Is it manually modified? Maybe you can create the XML document on the spot before using it.
Regards,
Radu
And how is that XML document generated? Is it manually modified? Maybe you can create the XML document on the spot before using it.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 3
- Joined: Mon Jun 05, 2017 7:18 pm
Re: New to XML need help
Hello Radu,
thank you for your reply.
the XML file was auto-generated by the application (picoscope). Similar to excel you can record macros in picoscope but instead of VBA, it saves the steps executed as xml.
I would like to now modify the script generated to basically add a timestamp each time a file is saved so as not to overwrite existing files as it would do with the xml code i have provided.
thank you for your reply.
the XML file was auto-generated by the application (picoscope). Similar to excel you can record macros in picoscope but instead of VBA, it saves the steps executed as xml.
I would like to now modify the script generated to basically add a timestamp each time a file is saved so as not to overwrite existing files as it would do with the xml code i have provided.
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: New to XML need help
Hi,
Using Oxygen (or an open source XSLT processor) you can apply an XSLT stylesheet like this:
over your XML document to add the current time of day to the output file name pattern.
Regards,
Radu
Using Oxygen (or an open source XSLT processor) you can apply an XSLT stylesheet like this:
Code: Select all
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="event[contains(text(), 'File.SaveAs.IO=')]">
<!-- Copy its attributes -->
<xsl:message><xsl:value-of select="current-time()"/></xsl:message>
<event>
<xsl:copy-of select="@*"/>
<!-- And modify the save output value -->
<xsl:value-of select="substring-before(text(), '.psdata')"/>
<xsl:text>-</xsl:text>
<xsl:value-of select="format-time(current-time(), '[H][m][s]')"/>
<xsl:text>.psdata</xsl:text>
</event>
</xsl:template>
</xsl:stylesheet>
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Return to “General XML Questions”
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