[xsl] Pass XML document (*not* file path!) as parameter to XSLT

Subject: [xsl] Pass XML document (*not* file path!) as parameter to XSLT
From: "david bessire" <david_bessire@xxxxxxxxxxx>
Date: Fri, 18 May 2007 16:56:57 +0000
i found the solution to the problem discussed in my previous posting with the same subject.

i was able to pass the dynamically-generated org.dom4j.Document XML object as a parameter to the XSLT in Java code by doing the following:

1. convert the org.dom4j.Document to an org.w3c.dom.Document
2. get an org.w3c.dom.NodeList from the org.w3c.dom.Document
3. pass the NodeList using javax.xml.transform.Transformer setParameter method
4. make minor changes to the XSLT, since the NodeList isn't the full XML structure
of the original org.dom4j.Document object.

The verbatim code follows:

// create org.dom4j.Document permDoc ...
org.w3c.dom.Document d = new org.dom4j.io.DOMWriter().write(permDoc);
org.w3c.dom.NodeList nl = d.getDocumentElement().getChildNodes();
transformer.setParameter("permsroles", nl);

where "permsroles" is the XSLT parameter name references in the transform.


Like the way Microsoft Office Outlook works? Youll love Windows Live Hotmail. http://imagine-windowslive.com/hotmail/?locale=en-us&ocid=TXT_TAGHM_migration_HM_mini_outlook_0507

Current Thread