[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: links for elements in xslt
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Bret > Sent: 17 January 2004 05:05 > Subject: links for elements in xslt > I have .net page which gets input from the user . I > had to convert that input to xml and send it to the > 3rd party database and get the output in xml . I > transform that xml to html using XSL file by using > Load and Transform methods in .NET This is a typical ASP scenario. > My XSL is similar to this . > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > <xsl:template match="/"> > <html> > <body> > <xsl:for-each select="record"> > <table> > <tr> > <td><xsl:value-of select="person-name"/></td> > <td><xsl:value-of select="person-city"/></td> > </tr> > </xsl:for-each> > </table> > </body> > </html> > </xsl:template> > </xsl:stylesheet> > This is has been done so far . Now I do want to > provide a links to all these elements(i.e > Person-name,Person-City..) so that when the user hits > the link, the link spawn's another search to the xml > database and returns the result .I Was wondering how You might have to reconfigure your thinking of what XSLT can do; xslt is not an event driven environment or scripting language, that is after the transform the XSLT processor is no longer engaged....this doesn't mean you cant achieve a solution. Its more a question of how you intend to invoke the XSLT processor, and where you want logic to occur. Consider the following snippet, amended from your original xslt; <td><a href="dosomemoreprocessing.asp?person-name={person-name}"><xsl:value-of select="person-name"/></a></td> Note I have used curly brackets {} which is shorthand (avt) for placing the value of the element person-name element. Using HTTP GET ( that is passing var within the url ), you pass the variable person-name to another asp that performs another transform, that performs the query and applies some xslt processing the the resultant xml. You may find that its easier to have a generic ASP xslt processing page, then just leave it to xslt to 'do the thinking'. This will undoubtably be something you have done previously.... Additionally, by using xsl:param you can instruct the XSLT processor to pass a parameter to your XSLT from the ASP page. That way you can let ASP page be your 'controller', as set within a Model View Controller, and let you XSLT provide the 'View', as well as updating the 'Model'. It struck me that this sample chapter might assist; http://www.perfectxml.com/wp/readchap.asp?CurBook=3 > would i do that . Do i have to call etxernal objects > from XSL to call the the search . When u say 'external objects', I understand it as 'do I have to call another ASP page for initiating some other XSLT process'...which the answer to is yes. XSLT main purpose in life is to transform xml into another form of xml; or in a larger sense transforming data into another form of data....many people view it as a programming language perhaps because a lot of what programming languages do is marshal data from one form to another. In general, be careful where you place your application logic, in the ASP or the XSLT....( though I don't work with ASP ), in general place logic in XSLT if its more generally applicable, as you may find yourself using the XSLT in another programming context; embed application specific logic within the ASP. This is a rule of thumb that has served me well over the years. > Any thoughts appreciated .NET, whilst not incompatible with xslt per say, comes along with a particular framework and approach here are a few sites which may assist you; http://www.dpawson.co.uk http://www.topxml.com/ another good site which describes the MSXML approach ( microsoft's XSLT processor which is used in .NET ) go here http://www.perfectxml.com/msxmlxslt.asp. Good luck, Jim Fuller XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|