Return To Web Portfolio >

XML With ASP: XSL Source

Samples of XSL used to transform the XML data into HTML and WML (wireless) forms.


<?xml version="1.0"?>
<xsl:stylesheet
    default-space="preserve"
    indent-result="yes"
    xmlns:xsl="http://www.w3.org/TR/WD-xsl"
    xmlns="http://www.w3.org/TR/REC-html40" 
    result-ns="">

    <xsl:template match="*" priority="-1">
        <xsl:apply-templates />
    </xsl:template>

    <xsl:template match="text()">
        <xsl:value-of/>
    </xsl:template>
   
    <xsl:template match="/">
        <HTML>
            <HEAD>
                <TITLE><xsl:value-of select="/page/headelements/title" /></TITLE>
            </HEAD>
            <BODY>
            <xsl:apply-templates select="/page/body/bodysettings/bodysetting" />

            </BODY>
        </HTML>
    </xsl:template>

    <xsl:template match="bodysetting">
            <xsl:for-each select="/page/body/bodysettings/bodysetting">
                <xsl:if test="@number[.= /page/action]">
                    <xsl:for-each select="@*">
                        <xsl:if test=".[$not$ context()[0]]">
                            <xsl:attribute><xsl:value-of /></xsl:attribute>
                        </xsl:if>
                    </xsl:for-each>
                </xsl:if>
            </xsl:for-each>
            <xsl:apply-templates />
    </xsl:template>

</xsl:stylesheet>

Sample of the XSL used to transform the XML data into WML (wireless) form:


<?xml version="1.0"?>
<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/TR/WD-xsl"
    xmlns="http://www.wapforum.org/DTD/wml_1.1.xml" 
    result-ns="">

    <xsl:template match="*" priority="-1">
        <xsl:apply-templates />
    </xsl:template>

    <xsl:template match="text()">
        <xsl:value-of/>
    </xsl:template>
   
    <xsl:template match="/">

        <wml> 
         
            <template>
                <do label="Home" type="prev">
                    <go href="/index.asp?action=wap"/>
                </do>
            </template>

         <card id="main" title="Main Page">
              <p align="center"><small>
                    <table columns="2">
                        <tr>
                            <td><strong><xsl:value-of select="/page/body/pagetitle" /></strong></td>
                        </tr>
                    </table>
              </small></p>
         </card> 

        </wml> 

    </xsl:template>

</xsl:stylesheet>


Return To Web Portfolio >