How do I concatenate HearingDate and StartTime?

Here should go questions about transforming XML with XSLT and FOP.
Posts: 53

How do I concatenate HearingDate and StartTime?

Tue Aug 12, 2014 7:51 pm

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:

Code: Select all

<Setting ID="21613643" InternalSettingID="1622304543" Date="07/21/2014">
   <StartTime>8:30 AM</StartTime>
   <EndTime>9:30 AM</EndTime>
   <CourtSessionBlock InternalCourtSessionBlockID="1614615037">
      <StartTime>8:30 AM</StartTime>
      <EndTime>9:30 AM</EndTime>
   <TimestampCreate>07/15/2014 09:27:49:607</TimestampCreate>

Here is my xslt code that is not displaying anything

Code: Select all

         <xsl:when test="/Integration/Case/Setting/StartTime[1]">
            <xsl:value-of select="StartTime"/>
            <xsl:value-of select="/Integration/Case/Hearing/Setting/CourtSessionBlock/StartTime"/>
Posts: 5226

Re: How do I concatenate HearingDate and StartTime?

Wed Aug 13, 2014 8:31 am


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]"/>

Please consider posting XSLT-specific questions on the XSLT list:

Radu Coravu
<oXygen/> XML Editor

Return to “XSLT and FOP”

Who is online

Users browsing this forum: No registered users and 1 guest