View RSS Feed

My Java Tips

  1. XSLT processing in Java

    by , 11-28-2011 at 07:25 PM (My Java Tips)
    XSLT (Extensible Stylesheet Language Transformations) is used to transform XML files into other formats like HTML format. There are many XSLT processors (libraries) available to be used in Java for XSLT transformation. These libraries can be used from a Java application like JSP/Servlet to read a XML file and to transform it into a HTML.


    An XSLT processor takes two inputs: an XML file and an XSLT stylesheet.

    For this post, I have chosen Xalan-Java library for the transformation. ...
    Tags: html, xalan-java, xml, xslt Add / Edit Tags
    Categories
    XML
  2. XSLT Conditions

    by , 05-25-2011 at 10:30 AM (My Java Tips)
    Consider the scenario: You have xml data and you need to filter some data out. You may do that in Java but its open a good idea to keep the logic separate in XSLT filters.

    if-then-else condition is done the following way in XSLT:

    Java Code:
    <xsl:choose>
      <xsl:when test="...">
        ...
      </xsl:when>
      <xsl:when test="...">
        ...
      </xsl:when>
      <xsl:otherwise>
    ...
    Tags: xslt Add / Edit Tags
    Categories
    XML