Reputation: 58
I have an XSL that is meant to create a copy of an XML but with a few attributes added to certain elements in the XML. The XSL calls a Java function that returns a list (java.util.List) of objects of type CInfo which is currently a very simple class defined as follows:
public class CInfo {
public int getNewVal() {
return 12345;
}
}
I am now facing a problem with the following snippet in the XSL:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:list="java.util.List"
xmlns:saxon="http://saxon.sf.net/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
...
...>
...
<xsl:variable name="infoList"
select="up:computeUpdates($updator)"/>
<xsl:for-each select="$infoList">
<xsl:variable name="cinfo" select="."/>
<xsl:variable name="newVal" select="ci:getNewVal($cinfo)"/>
...
...
</xsl:for-each>
computeUpdates(), which I verified is indeed being called by XSL, returns a list containing just one instance of type CInfo. The problem occurs at xsl:for-each which gives the following error:
Error on line 89
XPTY0019: Required item type of first operand of '/' is node(); supplied value has item
type java:com.mproj.mpkg.CInfo
at xsl:for-each (#76)
processing "com.mproj.mpkg.."
at xsl:apply-templates (#48)
Somehow the XSL doesn't seem to be able to iterate over infoList. Strangely, an existing XSL in the codebase that I am working on has a very similar for-each and is able to iterate over a list of Java objects of another class (similar to CInfo though) and doesn't seem to give any problem. Am I missing something? What is the standard procedure to make an XSLT iterate over a list of Java objects? Any examples that can help me here? I tried searching the web for examples of such looping and possible solutions to the mentioned problem but have been unsuccessful so far.
Upvotes: 0
Views: 2912
Reputation: 163549
You haven't shown us line 89, where the error arises. My guess is that it probably contains an expression of the form
$infoList/XXXXX
which is failing because (as the error message explains) the lh operand of "/" must be a sequence of nodes.
Upvotes: 1