I have a requirement that I need to pass a
string that will be converted to a nested element parameter. But when I tried to pass the same it gives error as "Cannot convert a string to a nodelist".
XSLT:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:param name="employees"/>
<xsl:param name="ISBN"/>
<xsl:template match="/">
<xsl:for-each select="$employees">
<xsl:sort select="$ISBN"/>
<xsl:value-of select="$ISBN" />
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
XML:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="sort_CFJ.xsl"?>
<employees>
<employee hireDate="04/23/1999">
<title ISBN="15" author="David Rogers">
An Introduction to NURBS: With Historical Perspective</title>
<last>Hill</last>
<first>Phil</first>
<salary>100000</salary>
</employee>
<employee hireDate="09/01/1998">
<title ISBN="17" author="Gerald Farin">
NURBS: From Projective Geometry to Practical Use</title>
<last>Herbert</last>
<first>Johnny</first>
<salary>95000</salary>
</employee>
</employees>
From Main Program :
TransformerFactory tfactory = TransformerFactory.newInstance();
Transformer transformer = tfactory.newTransformer(new StreamSource(xslID));
transformer.setParameter("employees", "employees/employee");
transformer.setParameter("ISBN", "title/@ISBN");
transformer.transform(new StreamSource(new File(sourceID)),new StreamResult(System.out));
Please let us know how can I pass parameter in the situation. I tried with "#employees/employee" still it didnt work.