Hi:

Strange error occurring passing node as param

XSLT:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="2.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <!--   <xsl:param name="mysamplexml" as="element()" required="yes"/> -->
  <xsl:param name="mysamplexml" as="node()" required="yes"/>
  <xsl:variable name="header">
    <tr>      <th>Element</th>      <th>Description</th>    </tr>
  </xsl:variable>
  <xsl:template match="/">
    <mys>
      <xsl:copy-of select="$mysamplexml//*"/>
    </mys>
    <h>
      <xsl:copy-of select="$header//*"/>
    </h>
  </xsl:template>
</xsl:stylesheet>


JAVA:
    private static String exampleXML =
//                "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" +
                "<a>a3</a>";
            StringReader reader = new StringReader(exampleXML);
            XdmNode doc = builder.build(new StreamSource(reader));
            simpletrfm.setParameter(new QName("","mysamplexml"), doc);

I receive this exception:
java.lang.IllegalArgumentException: Unknown name code 1121
        at net.sf.saxon.om.NamePool.unknownNameCode(NamePool.java:834)
        at net.sf.saxon.om.NamePool.getDisplayName(NamePool.java:733)
        at net.sf.saxon.event.XMLEmitter.startElement(XMLEmitter.java:289)
        at net.sf.saxon.event.UncommittedSerializer.startElement(UncommittedSerializer.java:149)
        at net.sf.saxon.event.NamespaceReducer.startElement(NamespaceReducer.java:72)
        at net.sf.saxon.event.ComplexContentOutputter.startContent(ComplexContentOutputter.java:531)
...

I know mysamplexml is passed as a document node, so not sure if I should pass it differently as well?

-Paul


From: Michael Kay <mike@saxonica.com>
To: saxon-help@lists.sourceforge.net
Sent: Friday, March 2, 2012 11:08 AM
Subject: Re: [saxon] XsltTransformer and parameters

On 02/03/2012 15:58, Paul M wrote:
Thx! I think I am mixing command line jar vs java. Because it works from Java app fine...

-Paul


If you are calling from the command line, and the stylesheet expects an element node, all is not lost: you can supply a parameter in the form

Transform "?param=doc('abc.xml')/*"

where the leading "?" signals that the value of param is being supplied in the form of an XPath expression.

Michael Kay
Saxonica


From: Michael Kay <mike@saxonica.com>
To: saxon-help@lists.sourceforge.net
Sent: Wednesday, February 29, 2012 4:52 PM
Subject: Re: [saxon] XsltTransformer and parameters

On 29/02/2012 21:39, Paul M wrote:

Class XsltTransformer
has this function

public void setParameter(QName name,
                         XdmValue value)

Is it possible to pass an element? I do not follow this if it is possible.
An XdmNode is a (subclass of) XdmValue, so this method will accept an XdmNode.

I see XdmValue : XdmValue(Iterable<XdmItem> items)

But I do not see how to go from XdmNode to be used in setParameter...

Any basic examples taking  say <a>a</a> and passing it as parameter...Link to example?
If you're starting with lexical XML contained in a string, first create a StreamSource by wrapping the string in a StringReader and the StringReader in a StreamSource. Then calling DocumentBuilder.build() will convert this to an XdmNode.

Michael Kay
Saxonica

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help



------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/


_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help 


------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help