BizTalk Utilities CV ,   Jobs ,   Code library  
 
 
          

Page 3 of 4

Converting the XSL example details into HTML

We need to create links for each of the stylesheet examples. To do this we iterate through each stylesheet example and create a string that contains HTML links to each stylesheet.

An example of a stylesheet node is

<XSLexample id="1" desc="example1">
<xslFile>test1.xsl</xslFile>
<xslTextTitle>Example 1: the first xsl</xslTextTitle>
<xslText>Doesn't do much but its different to the other XSL's</xslText>

The code to retrieve this and put it into HTML format is:

'Initialise and clear the string that will hold the HTML for the links

xslLinksHTML=""
'Loop through each example node
for each example in XSLexamples
'Build the HREF attribute of the HTML <a> element
xslLinksHTML=xslLinksHTML & "<a href=examples.asp?id=" &exampleID & "&xsl=" & example.getAttribute("id") & ">"

'Display the name of the link. This is the 'desc' attribute of the example node

xslLinksHTML=xslLinksHTML & example.getAttribute("desc") & "</a>"
next

This will produce a string containing the HTML for the links of each stylesheet. In the case of the example XML we were using on page 1 the string will contain

<a href=examples.asp?id=2&xsl=1>example1</a><a href=examples.asp?id=2&xsl=2>example2</a>

Once we've created the links for each XSL example we need to create one to display the XML itself. This is done by adding a parameter called 'xml' to the querystring of the ASP. The value of 'xml' doesn't matter as the existance of 'xml' is all that is checked for. For the example on page 1 this will look like

<a href=examples.asp?id=2&xsl=1&xml=1>View XML </a>

This is created with

xslLinksHTML=xslLinksHTML & "<a href=examples.asp?id=" &exampleID &"&xsl=" &XSLid & "&xml=1>View XML</a>"

While we're looping through each XSL example we might as well check to see if the XSL example we are looking at is the one that we want to display. If it is then we can get the title and explanation associated with it. If we place this code within the for-each...next loop above then we can check if we're looking at the correct XSL example. If it is then we can set the variable 'message' to be a string containing the HTML for the XSL example title & explanation

'Check if the example node we are looking at is the XSL example we need
'If it is then get the explanation details

if XSLid=example.getAttribute("id") then


'Get the name of the XSL file

XSLfile=example.selectSingleNode("XSLFile").text


'Get the message title and put in bold verdana font of size 2

messageTitle="<b><font face=verdana size=2>" & example.selectSingleNode ("xslTextTitle").text & "</font></b></br>"

'Get the explanation text

messageText=example.selectSingleNode("XSLText").text

'Some explanations have HTML in them so replace the '<' & '>' characters with &lt; and &gt; respectively so that the tags will be displayed
messageText = replace(messageText,"<","&lt;")
messageText=replace(messageText,">","&gt;")

'Put the messageTitle and messageText into one variable

message=messageTitle & messageText
end if
After we've done this, we will have all of the details of the XSL example. Now we just need to get the main details of the demo. Again, we build a string containing the HTML we want to display.

'Get the demo title

headerText="<h3> & demo.selectSingleNode("Title").text & " by "
'Get the name of the author and create a mailto link
headerText=headerText & "<a href=mailto:" &demo.selectSingleNode("email").text &">"
headerText=headerText & demo.selectSingleNode("Author").text &"</a></h3>"

'Get the header text of the demo

headerText=headerText & demo.selectSingleNode("heading").text

Now that we've got all details we need from the XML we can finally apply the XSL stylesheet to the XML, which is shown on page 4

          

Page 3 of 4

 

Recent Jobs

Integration Specialist Needed - Wor
Virtualization Server Infrastructur
A great opportunity to Digital Vide
here is a greate opportunity as a S
A great opportunity as a Network En

View all Jobs (Add yours)
View all CV (Add yours)




Chicago Web Site Design
free conference call
monofilament wigs
Donna karan sunglasses
air freshener
odor remover


    Email TopXML  

Front Page Daily Stuff TopXML Forum XML blogs XML Newsgroups BizTalk Biztalk Utilities Biztalk Utilities Tutorial B2B SAP XML Microsoft .NET Dotnet System XML Soapformatter SQLXML XMLserializer XQuery PHP PHP SimpleXML PHP XML Dom PHP XML RPC PHP XSLT Java Java Java XML Xalan Microsoft ASP ASP Schemas XML SQL Server XML XMLDom XSL XSL Tutorial XSLT Stylesheets General Javascript CSS XHTML WAP