[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: Complex XSL Application (I think)
Subject: RE: Complex XSL Application (I think) From: Mark Birbeck <Mark.Birbeck@xxxxxxxxxxxxx> Date: Wed, 24 Feb 1999 12:36:54 -0000 |
[Mark Birbeck] Wendy wrote: > Mark Birbeck wrote: > 2. If you have server-side scripting then another method would be to > generate the XSL dynamically - the browser won't know any different. > > This sounds related to what im trying to do. > You can assume I have server side scripting > Could anyone expand on this and explain how i might acheive the > following > > I need to get the Service Number from the user (Browser) > Pass this value to the server > Create the XSL to produce an XML file with just that employees > information > Pass this new XML file to the browser XSL for rendering in the > browser. [Mark Birbeck] I think I'm missing something Wendy. It seems to me that the XSL should always be the same - you just want a stylesheet that renders an employee's information as HTML (and start with a wild card, not the name of your employee document, so that the same stylesheet can display more than one employee if need be). From how you've described it the dynamic stuff should be on the XML side. A simple query on your database using the 'service number', and then converting the returned data to an XML document should be fine. I don't want to accuse you doing something you're not - so don't take offence here(!) - but you wouldn't be trying to run the query from the XSL side, would you? In other words you're not taking a massive XML document and then finding the employee with an XSL filter? Had to ask! The 'dynamic XSL' stuff I was talking about was for things like the search order that you referred to. The following function could go in an ASP file on the server, or be in a page running on the browser. It takes either a URL to an XML source in sXML, or a path to an ADs object. In your system just replace the latter with your database query, and replace XMLExport() with a function that does the query and converts it to XML. I'm sure you have a similar function, but the reason I'm spelling it out is to draw attention to the fact that the source for the 'file' as used by the DOM, can be any URL, which means we can do things like "stylesheets/employee.asp?order=1" and "stylesheets/employee.asp?order=2" employee.asp would your current XSL file, but there'd be a small bit of script in there to decide what order to display the results in. (Might be as simple as testing 'order' and writing a minus instead of a plus at the key point.) If TransformXML was in the browser page then these different pages would be cached locally, so switching between the different views of the same XML data would be pretty fast. Here's the function: Function TransformXML(bAttributes, sADsPath, sXSL, sXML) ' ' Function only really needs one of sADsPath and sXML. We could just test for a URI ' On Error Resume Next Dim slXML Dim sResult ' ' Create an instance of the parser ' Dim oData : set oData = Server.CreateObject("Microsoft.XMLDOM") If Err <> 0 Then sResult = L_FailedToCreateXMLDOM Else If bAttributes <> 1 Then bAttributes = 0 End If ' ' Load the XML into the parser ' oData.async = False If sADsPath <> "" Then ' ' If we have a pointer to an ADSI object then we extract the object as ' XML as our source for the parser ' slXML = XMLExport(False, False, sADsPath, bAttributes) oData.loadXML(slXML) Else ' ' Otherwise we have a URL ' oData.load(sXML) End If If (oData.parseError.errorCode <> 0) Then sResult = ReportError(oData.parseError) Else ' ' Create another parser instance, and load the stylesheet into it ' Dim oStyle : set oStyle = Server.CreateObject("Microsoft.XMLDOM") If Err <> 0 Then sResult = L_FailedToCreateXSLDOM Else oStyle.async = False oStyle.load("http://yourserver/" & sXSL) if (oStyle.parseError.errorCode <> 0) Then sResult = ReportError(style.parseError) else ' ' Transform the XML on the basis of the stylesheet ' sResult = oData.transformNode(oStyle) If Err Then sResult = "<font face=Verdana size=2><font size=4>XSL Runtime Error</font>" _ & "<P><B>" + err.description + "</B></P></font>" End If End If End If End If End If Set oData = Nothing Set oStyle = Nothing TransformXML = sResult End Function Regards, Mark XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Complex XSL Application (I thin, Guy_Murphy | Thread | Re: Complex XSL Application (I thin, Wendy Cameron |
XLink and XSL..., Guy_Murphy | Date | Re: XLink and XSL..., Simon St.Laurent |
Month |