> Before I ask a question, please let me explain the problem.
> I'd like to send to stylesheet variable number of parameters, which
would be then
> resolved by proper stylesheet. For example I have a number of parameters
defined in
> XML file (can be _any_ number of parameters):
> <Params>
> <Param nm="t1" vl="11"/>
> <Param nm="t2" vl="22"/>
> </Params>
> I want to transform xml document in a manner which depends on above
parameter list
> There is a simple way to do this in Java. First I must parse the above
doument into
> org.w3c.dom.Element object, and then pass this object as a 'value'
parameter in method
> setParameter( String name, Object value)
> of class
> javax.xml.transform.Transformer.
> And my problem is how to do it using Xalan C++. I _must_ do it in the
same (or similar)
> way as in java solution described above. I've found class
XalanTransformer
> (xalanc/XalanTransformer/XalanTransformer.hpp) has got only two
instances of method
> setStylesheetParam - first using constchar*, and second one using
XalanDOMString& as
> parameters. And that's all. I have found that XSLTEngineImpl object is
used as XSLT
> processor and it has a method defined below
> XSLTEngineImpl::setStylesheetParam(
> const XalanDOMString& key,
> XObjectPtr value);
> which prototype seems to look like it could be useful to resolve my
problem. But I am
> not sure this is the proper solution. Moreover, usage of this method
requires
> XalanTransformer module to be rewritten. But this method is called
nowhere in Xalan
> source code, tests or examples, so I have no idea how to convert (or
assign, whatever)
> any object having part of XML document (for example XalanElement*) to
XObjectPtr and
> if it will work. Maybe there's another way of solving my problem, which
I can see now.
> Can anybody help me?
By the far the most portable and cleanest solution is to pass the URL of
the document that contains the data, then let the document() function load
it:
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:param name="paramsURI" select="''") />
<xsl:variable name="params" select="document($paramsURL)" />
<xsl:template match="/">
<xsl:copy-of select="$params/Params/[EMAIL PROTECTED]'t1']" />
</xsl:template>
</xsl:stylesheet>
This assume you're going to use XPath to search the parameters. If that's
not what you're doing, this solution may not be appropriate.
Dave