[XSLT] IIS, VBScript による XSLT 適用 : してログ

[XSLT] IIS, VBScript による XSLT 適用

XSLT 20121231

Windows 2000 Server の IIS4 を使って、サーバーサイド XSLT 適用を行うサンプルです。適当なWebサイト上に下記ファイルを作り、aspをリクエストしてください。

public_office.xml

<?xml version="1.0" encoding="shift_jis" ?>
<prefecture>
  <city>
    <name>○○さん</name>
    <address>××市□□町</address>
    <url>http://www.example.jp/</url>
  </city>
</prefecture>

public_office.xsl

<?xml version="1.0" encoding="shift_jis" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" encoding="shift_jis" omit-xml-declaration="yes"/>

<xsl:template match="/">
  <xsl:apply-templates select="prefecture"/>
</xsl:template>

<xsl:template match="prefecture">
  <xsl:apply-templates select="city"/>
</xsl:template>

<xsl:template match="city">
  <xsl:value-of select="name"/>
</xsl:template>

</xsl:stylesheet>

public_office.asp

<%

Set objXML = Server.CreateObject("Microsoft.XMLDOM")
Set objXSL = Server.CreateObject("Microsoft.XMLDOM")

objXSL.async = false
objXSL.load Server.MapPath("public_office.xsl")

objXML.async = false
objXML.load Server.MapPath("public_office.xml")

Response.Write (objXML.documentElement.transformNode (objXSL.documentElement))

%>
0 件のコメント
名前:
コメント: