Subject: RE: [xsl] document fragments as parameters From: "Chris Bayes" <chris@xxxxxxxxxxx> Date: Sat, 24 Nov 2001 13:19:43 -0000 |
RTFM addObject Method [Script] Adds objects into a style sheet. [Script] Script Syntax objXSLProcessor.addObject(obj, namespaceURI); Parameters obj The object to pass in. namespaceURI The namespace to use inside the style sheet to identify the object. Example The following script example passes an object to the style sheet. var xsldoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.4.0"); var xmldoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.4.0"); var xsltemp = new ActiveXObject("Msxml2.XSLTemplate.4.0"); var xslproc; xsldoc.load("d:\\inetpub\\wwwroot\\sampleXSLWithObject.xml"); xsltemp.stylesheet = xsldoc.documentElement; xslproc = xsltemp.createProcessor(); xmldoc.loadXML("<level>Twelve</level>"); xslproc.input = xmldoc; xslproc.addObject(xmldoc, "urn:my-object"); xslproc.transform(); alert(xslproc.output); File Name: d:\inetpub\wwwroot\sampleXSLWithObject.xml <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:myObj="urn:my-object"> <xsl:output method="xml" indent="yes"/> <xsl:template match="/"> <xsl:element name="stage"> <xsl:value-of select="myObj:get-text()"/> </xsl:element> </xsl:template> </xsl:stylesheet> Output <?xml version="1.0" encoding="UTF-16"?> <stage> Twelve </stage> [Visual Basic] Visual Basic Syntax objXSLProcessor.addObject(obj, namespaceURI) Parameters obj The object to pass in. namespaceURI The namespace to use inside the style sheet to identify the object. Example The following Visual Basic example passes an object to the style sheet. Dim xsldoc As New Msxml2.FreeThreadedDOMDocument40 Dim xmldoc As New Msxml2.FreeThreadedDOMDocument40 Dim xsltemp As New Msxml2.XSLTemplate40 Dim xslproc As Msxml2.IXSLProcessor xsldoc.Load "d:\inetpub\wwwroot\sampleXSLWithObject.xml" Set xsltemp.stylesheet = xsldoc.documentElement Set xslproc = xsltemp.createProcessor xmldoc.loadXML "<level>Twelve</level>" xslproc.input = xmldoc xslproc.addObject xmldoc, "urn:my-object" xslproc.Transform MsgBox xslproc.output File Name: d:\inetpub\wwwroot\sampleXSLWithObject.xml <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:myObj="urn:my-object"> <xsl:output method="xml" indent="yes"/> <xsl:template match="/"> <xsl:element name="stage"> <xsl:value-of select="myObj:get-text()"/> </xsl:element> </xsl:template> </xsl:stylesheet> Output <?xml version="1.0" encoding="UTF-16"?> <stage> Twelve </stage> [C/C++] C/C++ Syntax HRESULT addObject (IDispatch* obj, BSTR namespaceURI); Parameters obj [in] The object to pass in. namespaceURI [in] The namespace that will be used inside the style sheet to identify the object. C/C++ Return Values E_FAIL if readyState is READYSTATE_INTERACTIVE. To view reference information for Visual Basic, C/C++, or Script only, click the Language Filter button in the upper-left corner of the page. Remarks Numbers are coerced to double, everything is coerced into a string, and objects return an error. The syntax get- is used to retrieve the property value exposed by the object that was passed into the style sheet. In the preceding example, the value for the property 'text' was retrieved as follows: <xsl:value-of select="myObj:get-text()"/> For example, if the object that was passed into the style sheet included a property called 'sheepcount', to retrieve the value of that property, you would use the syntax: <xsl:value-of select="myObj:get-sheepcount()"/> Ciao Chris XML/XSL Portal http://www.bayes.co.uk/xml > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of > Mattias Konradsson > Sent: 24 November 2001 11:24 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] document fragments as parameters > > > Under .NET and ordinary MSXML3.0/asp I want to pass some xml > as a parameter to my xslt stylesheet and be able to use it in > xslt for xpath tests like <xsl:if test="myxmlparam[param='test']"> > > etc. I've figured out as much as I should be using the > xsltargumentslist and probably use an node set or a node > fragment but haven't been able to find anything more on the > subject... what do I do and what's the difference between the > two? How do I do it in regular ASP? > > best regards > --- > Mattias Konradsson > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] document fragments as paramet, Mattias Konradsson | Thread | RE: [xsl] positional predicates in , Michael Kay |
RE: [xsl] getting parsed documents , Chris Bayes | Date | [xsl] dynamic grouping of tabular d, Dan Diebolt |
Month |