Link to home
Start Free TrialLog in
Avatar of emsenthil
emsenthil

asked on

How to pass a Document object as a parameter to XSLT

I am executing a XSLT from Java using this code ::

        DocumentBuilder builder;
        InputStream defInputStream = this.getClass().getClassLoader().getResourceAsStream("definitionsdb.xml");
        Document definitionsDB = builder.parse(defInputStream);

            Source xslSource = new StreamSource(inputXMLFile);
            Result xmlResult = new StreamResult(xmlOutputFileWriter);
            xmlTransformer.setParameter("inputFile", definitionsDB);
            xmlTransformer.transform(xslSource, xmlResult);

As you can see, apart from the StreamSource input xml file, I am sending another XML file as a parameter to the XSLT.

I receive the file in XSLT using the <xsl:param name="inputFile"/>

But then, I am not able to use the variable as a normal nodeset variable... like $inputFile/Definition/node1 ...

Any solution, on how to solve it?
ASKER CERTIFIED SOLUTION
Avatar of BigRat
BigRat
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial