| By Bruce Armstrong | Article Rating: |
|
| June 9, 2007 11:00 AM EDT | Reads: |
11,352 |
If there were no matching records in the XML file, another test is made on the "startrow" argument that was passed into the stylesheet, which indicates whether this was the first page of results or an attempt to display a later page. If it was the first page of results, a message is simply returned indicating that there were no matching records. If it was a later page of results, the "links" template is called to display links to prior result pages, and then the message is provided to indicate that there are no further results.
Next comes the "rows" template used to display the rows. It starts off simply enough, generating a table to display the result sets. However, then we encounter a xsl:variable called "msgid" that's actually the result of a call to a JavaScript function embedded in the XSLT file. That variable is then used to generate the hyperlink that will be used from the results page to call the display page. The remainder of the template is simple formatting of the remainder of the table, including the specification of the font color to use for the line that contains the group, message data, and author.
After that is the "links" template used to display the links to other pages in the result set. Once again we count the number of "search_row" tags in the XML and assign that to a variable called "count." Then we generate a link to the first page of the report using the arguments passed into the stylesheet and setting the "startrow" to 1 (as if the user was doing a new search).
If the startrow for this result page is greater than 1 we determine the number of pages prior to this page by dividing the number of rows in the total result set (another stylesheet argument) by the current startrow. We then do another xsl:call-template tag to invoke another embedded stylesheet ("createlinks"). This time we also use a set of xsl:with-param tags to pass arguments to that stylesheet, including the total number of prior pages we just calculated. Finally, if the count is greater than 0, we then check to see whether we've hit the last page of the results. If not, we generate a "Next" page link.
Then we come to the "createlinks" template. Once again there are a couple of xsl:param tags to accept the incoming arguments. We then check to see whether the "currentpage" argument (which was originally passed in as 1 when it was called from the main template) is less than or equal to the total number of pages. You'll see why in a minute. Next we calculate what the starting row number would be for that page and assign it to a xsl:variable called "newstart." That variable is then used to generate a link for that page number.
Here comes the tricky part. We then hit an xsl:call-template and a set of xsl:with-param tags. What's being called though is this same "createlinks" template. That is the "createlinks" template calls itself recursively incrementing the "currentpage" argument by 1 on each pass, until it's performed the operation a "totalpages" number of times.
Finally we hit a msxsl:script tag. This is our embedded JavaScript function. The problem we need to address is that the message ID that we're using to refer to begins and ends with, and can sometimes include, characters that can't be used literally in a URL (i.e., in the links we're generating). What we're doing here is calling the JavaScript encodeURI function to encode the messageID so it can be used in a URL. Actually, I strip the first and last characters off of the message ID first (that's why there's a sub-string call on the argument as it's being passed into the encodeURI function) and those are added back on in the display method of my PowerBuilder component. The remaining argument is automatically decoded by ASP.Net when it passed it into the Web Service.
Conclusions
That's it. As you can see, it's very
easy to create ASP.NET Web Services using PowerBuilder 11. It's also
very easy to use XSLT to transform the results from such services into
HTML pages using ASP.NET. Finally, you've also seen how it's possible
to generate somewhat more sophisticated results using some more
advanced features of XSLT.
Published June 9, 2007 Reads 11,352
Copyright © 2007 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Bruce Armstrong
Bruce Armstrong is a development lead with Integrated Data Services (www.get-integrated.com). A charter member of TeamSybase, he has been using PowerBuilder since version 1.0.B. He was a contributing author to SYS-CON's PowerBuilder 4.0 Secrets of the Masters and the editor of SAMs' PowerBuilder 9: Advanced Client/Server Development.
- Why SOA Needs Cloud Computing - Part 1
- Cloud Expo and The End of Tech Recession
- The Transition to Cloud Computing: What Does It Mean For You?
- A Rules Engine Built in PowerBuilder
- Sybase Named “Silver Sponsor” of iPhone Developer Summit
- How PowerBuilder Got Its Groove Back
- The Cloud Has Cross-Border Ambitions
- Ulitzer Named "New Media" Partner of Greatly Anticipated iStrategy Event in Berlin
- Risks and Enterprise Mobility?
- Steps for Success in Enterprise Mobility?
- Are Mobile Luddites Resisting Mobility?
- Hot Event in Santa Clara Becomes Cool with the iPhone
- The Difference Between Web Hosting and Cloud Computing
- Sybase CTO to Speak at 4th International Cloud Computing Expo
- Why SOA Needs Cloud Computing - Part 1
- Cloud Expo and The End of Tech Recession
- The Transition to Cloud Computing: What Does It Mean For You?
- Five Reasons to Choose a Private Cloud
- Seeding The Cloud: The Future of Data Management
- The Threat Behind the Firewall
- Economy Drives Adoption of Virtual Lab Technology
- Tips for Efficient PaaS Application Design
- A Rules Engine Built in PowerBuilder
- Sybase Named “Silver Sponsor” of iPhone Developer Summit
- Where Are RIA Technologies Headed in 2008?
- PowerBuilder History - How Did It Evolve?
- The Top 250 Players in the Cloud Computing Ecosystem
- Custom Common Dialogs Using SetWindowsHookEx
- DDDW Tips and Tricks
- OLE - Extending the Capabilities of PowerBuilder
- DataWindow.NET How To: Data Entry Form
- Book Excerpt: Sybase Adaptive Server Anywhere
- Sybase ASE 12.5 Performance and Tuning
- Working with SOA & Web Services in PowerBuilder
- Office 2003 Toolbar: A New Look For Your Old PowerBuilder App
- Dynamically Creating DataWindow Objects
































