<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
File: Default.aspx.vb
Imports System.IO
Imports System.Xml
Imports System.Xml.XPath
Imports System.Xml.Xsl
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles Me.Load
Response.ContentType = "text/xml"
Dim xsltFile As String = Path.Combine(Request.PhysicalApplicationPath, _
"Data.xsl")
Dim xmlFile As String = Path.Combine(Request.PhysicalApplicationPath, "Data.xml")
Dim xslt As New XslCompiledTransform() 'Pass in true to enable XSLT Debugging
xslt.Load(xsltFile)
Dim doc As New XPathDocument(xmlFile)
xslt.Transform(doc, New XmlTextWriter(Response.Output))
End Sub
End Class
File: Data.xml
<?xml version='1.0'?>
<bookstore xmlns="http://example.books.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<book genre="A"
publicationdate="1981"
ISBN="1-11111-11-0">
<title>title 1</title>
<author>
<first-name>A</first-name>
<last-name>B</last-name>
</author>
<price>8</price>
</book>
<book genre="B"
publicationdate="1999"
ISBN="0-222-22222-2">
<title>title 2</title>
<author>
<first-name>C</first-name>
<last-name>D</last-name>
</author>
<price>11.99</price>
</book>
</bookstore>
File: Data.xsl
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<xsl:element name="Authors">
<xsl:apply-templates select="//book"/>
</xsl:element>
</xsl:template>
<xsl:template match="book">
<xsl:element name="Author">
<xsl:value-of select="author/first-name"/>
<xsl:text> </xsl:text>
<xsl:value-of select="author/last-name"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>