How do I concatenate HearingDate and StartTime?
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 62
- Joined: Thu Jun 26, 2014 9:00 pm
How do I concatenate HearingDate and StartTime?
How do I get this result:
<ext:HearingDateTime>07/21/2014 8:30 AM</ext:HearingDateTime>
I have xml that have two StartTime and a HearingDate. The two StartTime are the same but one is near the top and the other one is a child of CourtSessionBlock.
The first StartTime is not always there which means sometimes the only available StartTime is the child of CourtSessionBlock.
For this reason, I need to first check if there is StartTime near the top of xml document. If it is there, I will use that StartTime concatenated with HearingDate. Otherwise if it's not there or when the only StartTime is the child of CourtSessionBlock, I will use that one. I have tried using <xsl:if> and <xsl:choose> but I am not getting anything displayed for the <ext:HearingDateTime/>. Please help.
Here is my xml code:
Here is my xslt code that is not displaying anything
<ext:HearingDateTime>07/21/2014 8:30 AM</ext:HearingDateTime>
I have xml that have two StartTime and a HearingDate. The two StartTime are the same but one is near the top and the other one is a child of CourtSessionBlock.
The first StartTime is not always there which means sometimes the only available StartTime is the child of CourtSessionBlock.
For this reason, I need to first check if there is StartTime near the top of xml document. If it is there, I will use that StartTime concatenated with HearingDate. Otherwise if it's not there or when the only StartTime is the child of CourtSessionBlock, I will use that one. I have tried using <xsl:if> and <xsl:choose> but I am not getting anything displayed for the <ext:HearingDateTime/>. Please help.
Here is my xml code:
Code: Select all
<Setting ID="21613643" InternalSettingID="1622304543" Date="07/21/2014">
<HearingDate>07/21/2014</HearingDate>
<StartTime>8:30 AM</StartTime>
<EndTime>9:30 AM</EndTime>
<CourtSessionBlock InternalCourtSessionBlockID="1614615037">
<StartTime>8:30 AM</StartTime>
<EndTime>9:30 AM</EndTime>
</CourtSessionBlock>
<TimestampCreate>07/15/2014 09:27:49:607</TimestampCreate>
</Setting>
Code: Select all
<ext:HearingDateTime>
<xsl:choose>
<xsl:when test="/Integration/Case/Setting/StartTime[1]">
<xsl:value-of select="StartTime"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="/Integration/Case/Hearing/Setting/CourtSessionBlock/StartTime"/>
</xsl:otherwise>
</xsl:choose>
</ext:HearingDateTime>
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: How do I concatenate HearingDate and StartTime?
Hi,
In an XSLT stylesheet an xsl:when element does not change the context of the current matched element to be the one in the test attribute expression.
So your XSLT code should be something like:
Please consider posting XSLT-specific questions on the XSLT list:
http://www.mulberrytech.com/xsl/xsl-list/
Regards,
Radu
In an XSLT stylesheet an xsl:when element does not change the context of the current matched element to be the one in the test attribute expression.
So your XSLT code should be something like:
Code: Select all
<xsl:when test="/Integration/Case/Setting/StartTime[1]">
<xsl:value-of select="/Integration/Case/Setting/StartTime[1]"/>
</xsl:when>
http://www.mulberrytech.com/xsl/xsl-list/
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
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