Class XsltUtils


  • public class XsltUtils
    extends java.lang.Object
    This class provides a range of static XSLT utility methods. Currently, this class has the following methods:-

    1. serialize - This method returns string of the specified node set.
    Author:
    Ikasan Development Team
    • Constructor Summary

      Constructors 
      Constructor Description
      XsltUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String serialize​(org.w3c.dom.NodeList nodeset)
      Returns string by serializing the specified node set.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • XsltUtils

        public XsltUtils()
    • Method Detail

      • serialize

        public static java.lang.String serialize​(org.w3c.dom.NodeList nodeset)
                                          throws javax.xml.transform.TransformerFactoryConfigurationError,
                                                 javax.xml.transform.TransformerException
        Returns string by serializing the specified node set.
         # =============================================
         #    Stylesheet for serialize()
         # =============================================
         <xsl:stylesheet
           xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
           xmlns:xalan="http://xml.apache.org/xslt"
           xmlns:utils="xalan://com.mizuho.cmi.london.core.shared.xalan.utils.XsltUtils"
           version="1.0"
           exclude-result-prefixes="xalan utils">
        
         <xsl:output method="xml" encoding="UTF-8"
              cdata-section-elements="item" indent="yes" xalan:indent-amount="2"/>
        
         <xsl:template match="/">
           <xsl:element name="root">
             <xsl:for-each select="/root/data">
               <xsl:element name="item">
                 <xsl:value-of select="utils:serialize(.)"/>
               </xsl:element>
             </xsl:for-each>
           </xsl:element>
         </xsl:template>
        
        Parameters:
        nodeset - is the node set to be serialized.
        Returns:
        the string.
        Throws:
        javax.xml.transform.TransformerFactoryConfigurationError - if an error creating Transformer occurs.
        javax.xml.transform.TransformerException - if an error while serializing nodeset occurs.