Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Here is a XML snippet:

<div class="headingZoom">
  <xsl:text>Congregation Meeting Schedule for </xsl:text>  
  <xsl:value-of select="MeetingWorkBook/Meeting[1]/MeetingDate/@MonthFull"/>
  <xsl:text> </xsl:text>
  <xsl:value-of select="MeetingWorkBook/Meeting[1]/MeetingDate/@Year"/>

  <xsl:text> - </xsl:text>

  <xsl:value-of select="MeetingWorkBook/Meeting[last()]/MeetingDate/@MonthFull"/>
  <xsl:text> </xsl:text>
  <xsl:value-of select="MeetingWorkBook/Meeting[last()]/MeetingDate/@Year"/>

  <xsl:value-of select="MeetingWorkBook/Meeting[last()]/SpecialEvent/Date/@MonthFull"/>
  <xsl:text> </xsl:text>
  <xsl:value-of select="MeetingWorkBook/Meeting[last()]/SpecialEvent/Date/@Year"/>
</div>

The problem is that the last element will be one or the other:

  • This one:
<xsl:value-of select="MeetingWorkBook/Meeting[last()]/MeetingDate/@MonthFull"/>
<xsl:text> </xsl:text>
<xsl:value-of select="MeetingWorkBook/Meeting[last()]/MeetingDate/@Year"/>
  • Or this one:
<xsl:value-of select="MeetingWorkBook/Meeting[last()]/SpecialEvent/Date/@MonthFull"/>
<xsl:text> </xsl:text>
<xsl:value-of select="MeetingWorkBook/Meeting[last()]/SpecialEvent/Date/@Year"/>

How can I do that with XSLT-1?


Infact, upon reflection, even this bit needs to apply the same logic where I display the data for Meeting[1]. It too could be one or the other type of element.

I should point out that it would never have both in teh relevant nodes, just one or the other.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
836 views
Welcome To Ask or Share your Answers For Others

1 Answer

<xsl:value-of select="MeetingWorkBook/Meeting[last()]//@MonthFull"/>
<xsl:text> </xsl:text>
<xsl:value-of select="MeetingWorkBook/Meeting[last()]//@Year"/>

Please note the double slash.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...