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?
emsenthilAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BigRatCommented:
XSLT (as a standard) only allows reference to document via file names, which it resolves and loads. I know of no method of passing the transformer a node-set in a document object. This of course makes it difficult to include XML or XSL source which one has in a string.

The only suggestion I can make is to load an xml string containing two nodes containing the relevant parts :-

    <root>
        <part id="1">....contents of the first file</part>
        <part id="2">....contents of the second file</part>
        .... and so on...
    </root>

At least with this method one doesn't need files to hold the data, it can come from strings.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.