xsl-list
[Top] [All Lists]

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

2007-05-18 09:57:24

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.

-db

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


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>