On 22 Dec 2004 at 8:59, [EMAIL PROTECTED] wrote:
> > 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 Thanks Dave, but I'm afraid it's not quite helpful to me. In my case the XML document containing variable number of xslt parameters never exists as a file (my fault, in I've written 'XML _file_', but should have 'XML _document_', sorry). It's generated by one application as an XML, and then passed via tcp socket to another application which performs XSL transformation, then returns results (in the form of XML document on tcp as well) to the first one. So I can't pass URL of an XML _file_ as a parameter because no such a _file_ exists. Of course I could save this XML as a temporary file and then use it's URL (as you have explained) but it's not a convenient solution for me. So I would be grateful for further help. -- Greetings Jarek Lubczynski There are 10 kinds of people: Those who understand binary and those who don't
