Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 29th, 2006, 05:41 PM
Authorized User
 
Join Date: Mar 2006
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default pass DOM to XSL as parameter

Hi All,
I want to pass DOM as parameter to my XSL.Problem i am getting is node-set conversion.
Cann't i achieve the same functionality of xsl document function in my java code.
I am using eclipse to run my xsl code.Not sure about the XSLT processor.
transformer.setParameter("contents",doc);
my xsl is

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="contents"/>
  <xsl:template match="/">
    <xsl:element name="newRoot">
      <xsl:copy-of select="$contents/employee/name"/>
    </xsl:element>
  </xsl:template>
</xsl:stylesheet>
 
Old March 29th, 2006, 06:20 PM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Passing of parameters to XSLT depends on the processor you're using - it's not necessarily the same even for two processors supporting the JAXP API. You don't say whether the code you show work or not, or if it doesn't, how it fails, and in your setParameter example you don't say what "doc" is - so you're not making it very easy for anyone to help you.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old March 30th, 2006, 02:17 PM
Authorized User
 
Join Date: Mar 2006
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                DocumentBuilder builder = factory.newDocumentBuilder();
                File temp=new File("as.xml");
                Document doc = builder.parse(temp);
                TransformerFactory tFactory =
                    TransformerFactory.newInstance();
                    Transformer transformer =
                    tFactory.newTransformer(
                    new StreamSource("check.xsl"));

                   transformer.setParameter("contents",doc);

                    transformer.transform(
                    new StreamSource("temp.xml"),
                    new StreamResult(new FileOutputStream(
                    "testasd.xml")));
i am using w3c dom object and xsl code is in the previous posting.
Gettting error as--
Invalid conversion from 'org.apache.xerces.dom.DeferredDocumentImpl' to 'node-set'.'

Please help me in finding the solution.My objective is to pass DOM as parameter to XSL.I am using jdk 1.4

Let me know if you need any other details.


 
Old March 30th, 2006, 05:22 PM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Looks as if you are using Xalan. I don't think there are any Xalan specialists here so you're best off asking on a Xalan list.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference




Similar Threads
Thread Thread Starter Forum Replies Last Post
Pass xsl:param to xsl:if bonekrusher XSLT 5 September 6th, 2007 04:37 PM
Pass link values as xsl:parameter to php5 then xsl pauljr8 XSLT 1 July 2nd, 2007 10:32 PM
Pass a parameter from java servlet to xsl anithapeeris XSLT 3 June 20th, 2007 01:57 AM
XSL Parameter xsl:param Harinath Chikoti XSLT 1 May 6th, 2005 03:15 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.