Uploaded image for project: 'XalanJ2'
  1. XalanJ2
  2. XALANJ-1101

The function value-of throws a NullPointer exception when element is null.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Resolution: Incomplete
    • 2.4Dx
    • None
    • None
    • Operating System: Other
      Platform: All
    • 10956

    Description

      Run the following XML:

      <?xml version="1.0" encoding="UTF-8"?>
      <componentinfo>
      <component id="2" name="" type="outfitting">
      <currentversion id="2" lastmodified="Jul 18, 2002 11:11:14 AM" modifiedby="Juan F
      Arjona" name="" version="0.0"/>
      <versions/>
      <data expanded="true" expandid="6">
      <outfitting expanded="true" expandid="5" version="0.0">
      <isapdata expanded="true" expandid="4">
      <outfittingworkbook expanded="true" expandid="3">
      <outfittingweights expanded="true" expandid="1">
      <strakes>0.0</strakes>
      <risersupports>0.0</risersupports>
      <fairleadsupports>0.0</fairleadsupports>
      <fairings>0.0</fairings>
      <chainjacksupports>0.0</chainjacksupports>
      <chainlocker>0.0</chainlocker>
      <winchfoundation>0.0</winchfoundation>
      <topsidesinterface>0.0</topsidesinterface>
      <trusshardtankinterface>0.0</trusshardtankinterface>
      <trusskeeltankinterface>0.0</trusskeeltankinterface>
      <jtubes>0.0</jtubes>
      <riserguidetubes>0.0</riserguidetubes>
      <miscellaneousequipment>0.0</miscellaneousequipment>
      <electrical>0.0</electrical>
      <hatchesandladders>0.0</hatchesandladders>
      <boatlanding>0.0</boatlanding>
      <fairleadandbendingshoe>0.0</fairleadandbendingshoe>
      <chaininboardoffairleads>0.0</chaininboardoffairleads>
      <tailchain>0.0</tailchain>
      <chainjacksandsheaves>0.0</chainjacksandsheaves>
      <hpu>0.0</hpu>
      <winches>0.0</winches>
      <piping>0.0</piping>
      <ballastpumps>0.0</ballastpumps>
      <caissons>0.0</caissons>
      <liquidinpipingsystems>0.0</liquidinpipingsystems>
      <anodes>0.0</anodes>
      <painting>0.0</painting>
      <marinegrowth>0.0</marinegrowth>
      <othera>0.0</othera>
      <otherb>0.0</otherb>
      <otherc>0.0</otherc>
      <otherd>0.0</otherd>
      <totaloutfittingweight>0.0</totaloutfittingweight>
      <outfittingkg>0.0</outfittingkg>
      </outfittingweights>
      <outfittinginput expanded="true" expandid="2">
      <hulltype/>
      <diameter>0.0</diameter>
      <freeboard>0.0</freeboard>
      <hardtankdepth>0.0</hardtankdepth>
      <softtankheight>0.0</softtankheight>
      <midsectionheight>0.0</midsectionheight>
      <lengthcw>0.0</lengthcw>
      <widthcw>0.0</widthcw>
      <topsidenwells>0</topsidenwells>
      <topsidevcg>0.0</topsidevcg>
      <topsidetotalweight>0.0</topsidetotalweight>
      <hardtanksteelweight>0.0</hardtanksteelweight>
      <midsectionsteelweight>0.0</midsectionsteelweight>
      <softtanksteelweight>0.0</softtanksteelweight>
      <numlines>0</numlines>
      <mooringfairleaddepth>0.0</mooringfairleaddepth>
      <mooringchainweight>0.0</mooringchainweight>
      </outfittinginput>
      </outfittingworkbook>
      </isapdata>
      </outfitting>
      </data>
      </component>
      <options allowexpand="true" edition="false" expandcommand="component_expand"
      operation="Viewing" showheader="false"/>
      </componentinfo>

      through the XSL:

      <?xml version="1.0" encoding="UTF-8"?>
      <!--
      $Id: showcomponent.xsl,v 1.13 2002/07/12 00:01:59 jfarjona Exp $
      Document : componentinfo.xsl
      Expected XML: See file componentinfo.xsd
      Created on : June 18, 2002
      Author : Juan F. Arjona
      Comment
      This stylesheet transforms the XML of a component into its presentation in
      the webpage.
      It produces a <div> tag containing the data for the component.

      -->
      <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:fo="http://www.w3.org/1999/XSL/Format"
      xmlns:lxslt="http://xml.apache.org/xslt" xmlns:akerext="akerext"
      extension-element-prefixes="akerext">
      <lxslt:component prefix="akerext" elements="uniquelog" functions="parentcount
      getmaxdepth">
      <lxslt:script lang="javaclass" src="com.aker.xsl.extensions"/>
      </lxslt:component>
      <xsl:output method="html" version="1.0" encoding="UTF-8"
      omit-xml-declaration="no" standalone="no" indent="no"/>
      <xsl:param name="maxdepth">
      <xsl:value-of select="number(akerext:getmaxdepth)"/>
      </xsl:param>
      <xsl:param name="edition">
      <xsl:value-of select="/componentinfo/options/@edition"/>
      </xsl:param>
      <xsl:template name="printtds">
      <xsl:if test=".. != /componentinfo/component/data/*[1]">
      <td width="20" bgcolor="DDDDDD">
      <xsl:text disable-output-escaping="yes"><![CDATA[ ]]></xsl:text>
      </td>
      <xsl:for-each select="../">
      <xsl:call-template name="printtds"/>
      </xsl:for-each>
      </xsl:if>
      </xsl:template>
      <xsl:template name="printxml">
      <xsl:for-each select="*">
      <xsl:variable name="chnum">
      <xsl:value-of select="count"/>
      </xsl:variable>
      <xsl:comment>Now in printxml, count is: <xsl:value-of select="$chnum"/></xsl:comment>
      <xsl:variable name="depth">
      <xsl:value-of select="akerext:parentcount(node())"/>
      </xsl:variable>
      <xsl:choose>
      <xsl:when test="$chnum >= 1">
      <tr>
      <xsl:call-template name="printtds"/>
      <td colspan="2" class="normalBold" valign="top" width="180" bgcolor="DDDDDD">
      <xsl:attribute name="colspan"><xsl:value-of select="number($maxdepth) - number($depth)
      + number(5)"/></xsl:attribute>
      <xsl:choose>
      <xsl:when test="/componentinfo/options/@allowexpand = 'true'">
      <a class="normalLink">
      <xsl:attribute name="href">?<xsl:value-of select="/componentinfo/options/ @expandcommand"/>=<xsl:value-of
      select="@expandid"/></xsl:attribute>
      <xsl:choose>
      <xsl:when test="@expanded = 'true'">-</xsl:when>
      <xsl:otherwise>+</xsl:otherwise>
      </xsl:choose>
      <xsl:value-of select="name()"/>
      </a>
      </xsl:when>
      <xsl:otherwise>
      <span class="normalLink">
      <xsl:value-of select="name()"/>
      </span>
      </xsl:otherwise>
      </xsl:choose>
      </td>
      </tr>
      <xsl:choose>
      <xsl:when test="/componentinfo/options/@allowexpand = 'true'">
      <xsl:if test="@expanded = 'true'">
      <xsl:call-template name="printxml"/>
      </xsl:if>
      </xsl:when>
      <xsl:otherwise>
      <xsl:call-template name="printxml"/>
      </xsl:otherwise>
      </xsl:choose>
      </xsl:when>
      <xsl:when test="$chnum = 0">
      <tr>
      <xsl:call-template name="printtds"/>
      <td colspan="2" class="normalBold" valign="top" width="180" bgcolor="DDDDDD">
      <xsl:value-of select="name()"/>
      </td>
      <td class="normal" bgcolor="DDDDDD">
      <xsl:attribute name="colspan"><xsl:value-of select="number($maxdepth) - number($depth)
      + number(3)"/></xsl:attribute>
      Value: <span class="red10normal">
      <xsl:choose>
      <xsl:when test="($edition = 'true')">
      <input type="text" size="10">
      <xsl:attribute name="name">DTA_<xsl:value-of select="../@expandid"/>_<xsl:value-of
      select="position()"/></xsl:attribute>
      <xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
      </input>
      <xsl:if test="@uom">
      <input type="text" size="5">
      <xsl:attribute name="name"><xsl:value-of select="../@expandid"/><xsl:value-of
      select="name()"/>uom</xsl:attribute>
      <xsl:attribute name="value"><xsl:value-of select="@uom"/></xsl:attribute>
      </input>
      </xsl:if>
      </xsl:when>
      <xsl:otherwise>
      <xsl:value-of select="node()/."/>
      <xsl:value-of select="@uom"/>
      </xsl:otherwise>
      </xsl:choose>
      </span>
      </td>
      </tr>
      </xsl:when>
      </xsl:choose>
      </xsl:for-each>
      </xsl:template>
      <xsl:template match="/">
      <xsl:comment>Edition is: <xsl:value-of select="$edition"/>
      </xsl:comment>
      <div ID="data" style="position: static; visibility: 'visible'; z-index:2;
      width:535px; height:420px; overflow-y:auto;">
      <table border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEEEE" width="550">
      <xsl:for-each select="/componentinfo/component">
      <xsl:if test="/componentinfo/options/@showheader = 'true'">
      <tr>
      <td class="normal" valign="top" bgcolor="#CCCCCC">
      <xsl:attribute name="colspan"><xsl:value-of select="number($maxdepth)+4"/></xsl:attribute>
      <table border="0" cellspacing="0" cellpadding="0">
      <tr valign="top">
      <td width="180" class="normal" valign="top">
      <xsl:value-of select="/componentinfo/options/@operation"/>
      <br/>
      <span class="red10normal">
      <!-- Shows the first element of the data tree -->
      <xsl:value-of select="name(./data/*[1])"/>
      </span>
      <br/>
      <a href="componentsmain.jsp?editvalues=true" class="leftLinks">update</a>
      </td>
      <td width="250" class="normal" valign="top">
      Version: <span class="red10normal">
      <xsl:value-of select="version[1]/@version"/>
      </span>
      <br/>Modified on:<span class="red12normal">
      <xsl:value-of select="version[1]/@lastmodified"/>
      </span>
      <br/>By:<span class="red12normal">
      <xsl:value-of select="version[1]/@modifiedby"/>
      </span>
      </td>
      </tr>
      </table>
      </td>
      </tr>
      </xsl:if>
      <xsl:comment>
      Count is: <xsl:value-of select="count(./data/*)"/>
      name is: <xsl:value-of select="name(./data/*)"/>
      </xsl:comment>
      <xsl:for-each select="./data">
      <xsl:call-template name="printxml"/>
      </xsl:for-each>
      </xsl:for-each>
      </table>
      </div>
      </xsl:template>
      </xsl:stylesheet>

      Using XALAN-J 2.4.D1. Throws a NullPointer exception because the node HullType
      is empty, will work if you put something on that node.

      Attachments

        Activity

          People

            Unassigned Unassigned
            jfarjona@jfarjona.com Juan F. Arjona
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: