Re: data source as parameter?

Martin Honnen <[email protected]>
Newsgroups gmane.comp.mozilla.devel.layout.xslt
Organization Liberty Development
Message-ID <[email protected]>
kitchen wrote:


> One thing I tried, is loading up a couple of data sources and
> transforming them into the same stylesheet.  Basically, what I did,
> which feels very hack-ish, but firefox let me do it... is I set one of
> the data sources as a parameter to the stylesheet, then transformed the
> other data source with the document.
> 
> Here's the 'proof of concept' code I wrote to see if it was even
> possible:
> http://edge.scriptkitchen.com:81/~kitchen/xsl/cute3/cutetest.html (I
> was feeling 'cute' for some reason...)
> 
> Now, my question is:  Is this legit?  Am I supposed to be able to do
> this?  I tried it in Opera (9.02) and saw that it worked there as well,
> so I can only assume so.. but I wanted to get an answer straight from
> the horse's mouth, so to speak.

Data source is a rather general term, it is not clear from that term 
what you are asking about. That code with all the JavaScript files and 
libraries is a bit convoluted to understand what you are doing, I guess 
you are passing in a DOM node (e.g. XML DOM document) as a parameter to 
the stylesheet to further process it in the stylesheet as a node set. 
Firefox 1.5 and later (but not Firefox 1.0) support that, yes, as does 
Opera 9. MSXML 3 (and later), the XSLT processors you can use with IE, 
also allows XML DOM nodes as parameters passed in. Firefox 1.5 and later 
and Opera 9 also allow you to pass in an XPathResult 
(<http://www.w3.org/TR/DOM-Level-3-XPath/xpath.html#XPathResult>) you 
would get using the W3C DOM Level 3 XPath API those browsers support.

There is no general requirement however in the XSLT specification to 
support such parameter types. And in your example you seem to load an 
XML file (e.g. cutecompanies.xml) with script, you can also do that 
within XSLT with the document function XSLT provides (e.g.
   <xsl:for-each 
select="document('cutecompanies.xml')/data/companies/company">
). The document function is a requirement to be supported by any XSLT 
processor to allow loading of XML. Note sure Opera 9.0 currently does.

-- 

	Martin Honnen
	http://JavaScript.FAQTs.com/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.