Loading ...
Sorry, an error occurred while loading the content.

Re: Conditional Statement with XSL FO

Expand Messages
  • odekij61
    ... To do this you use XSLT to choose what to put when. So use the choose when command. It s just like a Case statement in other programming languages
    Message 1 of 2 , Oct 24, 2003
    • 0 Attachment
      --- In XSL-FO@yahoogroups.com, "uyiosa" <uyiosa@y...> wrote:
      > I am creating an XSL FO document and I am running into problem.
      > Please help!
      > This is a sample of the XML source
      >
      > <Book>
      > <History>
      > <AB></AB>
      > <BC></BC>
      > <CD></CD>
      > </History>
      > </Book>
      >
      > If the value of AB is 1, the document should display
      >
      > <fo:block font-size="12pt" font-family="Times Roman" font-
      > weight="normal">
      > Story
      > </fo:block>
      > <fo:block font-size="12pt" font-family="Times Roman" font-
      > weight="normal">
      > Magazine
      > </fo:block>
      > <fo:block font-size="12pt" font-family="Times Roman" font-
      > weight="normal">
      > Newspaper
      > </fo:block>
      >
      > In a simple language, this is what I wanted to do,
      > If AB = 1
      > Display message in (Story, Magazine and Newspaper)
      > Else if BC = 1
      > Display message in (Story, Magazine and Newspaper)
      > Else if CD = 1
      > Display message in (Story, Magazine and Newspaper)
      >
      > Please help me code this in XSL FO.
      >
      > Thanks,
      > Uyi


      To do this you use XSLT to choose what to put when. So use
      the "choose" "when" command. It's just like a Case statement in other
      programming languages with a default clause.
      example:
      <xsl:choose>
      <xsl:when test="something = 1">
      Display message 1 in (Story, Magazine and Newspaper)
      </xsl:when>
      <xsl:when test="something = 2">
      Display message 2 in (Story, Magazine and Newspaper)
      </xsl:when>
      <xsl:otherwise>
      Display message 3 in (Story, Magazine and Newspaper)
      </xsl:otherwise>
      </xsl:choose>

      Just replace "something" with your element or attribute you're
      checking. And replace "Display message X in (Story, Magazine and
      Newspaper)" with your XSL-FO code.
      Good luck!
      Jeremy O.
    Your message has been successfully submitted and would be delivered to recipients shortly.