I've had a hard time finding good ways of taking a time format and easily determining if it's valid then producing a resulting element that has some formatting using XSLT 1.0.
Given the following xml:
<root>
<srcTime>2300</srcTime>
</root>
It would be great to produce the resulting xml:
<root>
<dstTime>23:00</dstTime>
</root>
However, if the source xml contains an invalid 24 hour time format, the resulting dstTime element should be blank.
For example, when the invalid source xml is the following:
<root>
<srcTime>NOON</srcTime>
</root>
The resulting xml should be:
<root>
<dstTime></dstTime>
</root>
The question is, what's the best XSLT 1.0 fragment that could be written to produce the desired results? The hope would be to keep it quite simple and not have to parse the every piece of the time (i.e. pattern matching would be sweet if possible).