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

XSL transformation question

Expand Messages
  • Jim
    Hi all, I would like to turn XML content into XSL-FO. A sample of the XML is below. I want to transform this XML into XSL-FO that describes Hello World in
    Message 1 of 1 , Mar 27, 2003
      Hi all,

      I would like to turn XML content into XSL-FO. A sample of the XML is
      below. I want to transform this XML into XSL-FO that describes Hello
      World in bold and italic. How can I accomplish the transformation?


      <DOCUMENT>
      <CONTENT>
      <STYLE>
      <FONT-BOLD/>
      <FONT-ITALIC/>
      </SYYLE>
      <TEXT>
      Hello World
      </TEXT>
      </CONTENT>
      </DOCUMENT>


      Initial work:

      It is easy to transform nested XML descriptions into inline FO
      elements. For example:

      <DOCUMENT>
      <CONTENT>
      <TEXT>
      <BOLD>
      Hello World
      </BOLD>
      </TEXT>
      </CONTENT>
      </DOCUMENT>


      Part of the XSL style sheet can defined as:

      <xsl:template match="TEXT">
      <fo:block>
      <xsl:apply-templates />
      </fo:block>
      </xsl:template>

      <xsl:template match="BOLD">
      <fo:inline font-weight="bold">
      <xsl:apply-templates />
      </fo:inline>
      </xsl:template>


      This matches a text element in the XML and applies a block. Within
      the block the child elements are processed via the apply templates
      call. The bold template is called because of this, which adds an
      inline fo element to identify bold text. Within the bold fo element
      apply templates is called which will write out the text, Hello
      World. This is recursive, and each end tag is applied accordingly.

      This type of logic applied to the actual XML document will not work
      because using recursion to write out inline fo tags will not write
      out the text Hello World within those tags. Hello World is found
      after the formatting tags!

      I think some sort of function needs to be written at the CONTENT
      template level. But I am not sure on how to proceed.

      What do you think about this scenario? How can I solve this?



      Thanks,
      Jim
    Your message has been successfully submitted and would be delivered to recipients shortly.