Have a look here: http://marc.info/?l=xalan-j-users&m=116982111306829&w=2
> -----Original Message----- > From: Gaurav Suri [mailto:[EMAIL PROTECTED] > Sent: Sunday, May 20, 2007 10:48 PM > To: xalan-j-users@xml.apache.org > Subject: Passing XML as input parameter to XSLT Transformer > > > Hi, > > I am trying to pass XML as an input parameter the JAVA trannsformer but > am > getting the following error : > > Exception stack is: > 1. Invalid conversion from 'org.apache.xerces.dom.DeferredElementImpl' > to > 'node- > set'. (java.lang.RuntimeException) > com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary:-1 > (http://java.sun.com/j2se/1.5.0/docs/api/java/lang/RuntimeException.htm > l) > > > Root Exception stack trace: > java.lang.RuntimeException: Invalid conversion from > 'org.apache.xerces.dom.DeferredElementImpl' to 'node-set'. > at > com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary.runTimeE > rror(Unknown Source) > at > com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary.runTimeE > rror(Unknown Source) > > > Input XML : > > <?xml version="1.0" encoding="UTF-8"?> > <order> > <clientId>CLT001</clientId> > <orderId>ORD001</orderId> > <bill>12.5</bill> > <deliveryDate>2006-01-11</deliveryDate> > <location>001</location> > </order> > > > Input Parameter to the stylesheet (also an XML) : > > <?xml version="1.0" encoding="UTF-8"?> > <locations> > <location> > <name>001</name> > <value>Bangalore</value> > </location> > <location> > <name>002</name> > <value>Dellhi</value> > </location> > </locations> > > > Stylesheet: > > <?xml version="1.0" encoding="ISO-8859-1"?> > <?altova_samplexml C:\Documents and > Settings\gaurav_suri\Desktop\Input.xml?> > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > <xsl:output method="xml" indent="yes" encoding="ISO-8859-1" > standalone="yes"/> > <xsl:template match="*"> > <client> > <xsl:value-of select="clientId"/> > </client> > <ordernumber> > <xsl:value-of select="orderId"/> > </ordernumber> > <deliverydate> > <xsl:value-of select="deliveryDate"/> > </deliverydate> > <bill> > <xsl:value-of select="bill"/> > </bill> > <area> > <xsl:value-of > select="$ORM/locations/location[name=001]/value"/> > </area> > </xsl:template> > </xsl:stylesheet> > > > Code Snippet : > > Source sourceDoc = getXmlSource(src); > if (sourceDoc == null) return null; > > ResultHolder holder = getResultHolder(returnClass); > if (holder == null) holder = > getResultHolder(src.getClass()); > > DefaultErrorListener errorListener = new > DefaultErrorListener(this); > Transformer transformer = null; > Object result; > try > { > transformer = > (Transformer)transformerPool.borrowObject(); > > transformer.setErrorListener(errorListener); > transformer.setOutputProperty(OutputKeys.ENCODING, > encoding); > > //set transformation parameters > if (transformParameters != null){ > for(Entry<String,Object> parameter : > transformParameters.entrySet()){ > transformer.setParameter(parameter.getKey(), > evaluateTransformParameter(parameter.getKey(),parameter.getValue())); > } > } > > transformer.transform(sourceDoc, holder.getResult()); > result = holder.getResultObject(); > > //where evaluateTransformParameter method returns a document built as > follows : > > > DocumentBuilderFactory documentbuilderfactory = > DocumentBuilderFactory.newInstance(); > InputSource inputsource = new InputSource(new StringReader(s)); > org.w3c.dom.Document document = > documentbuilderfactory.newDocumentBuilder().parse(inputsource); > return document; > > //s being the input XML parameter as string. > > > Any pointers for correction.. > > Regards > Gaurav > -- > View this message in context: http://www.nabble.com/Passing-XML-as- > input-parameter-to-XSLT-Transformer-tf3788406.html#a10713473 > Sent from the Xalan - J - Users mailing list archive at Nabble.com.