ADOS Developer's Site - XML Stadium |
1. XMLファイル(XMLインスタンス)を用意する。
東北.xml
<?xml version="1.0"?> <table xmlns="urn:test:1.1"> <row> <col1>青森県</col1> <col2>岩手県</col2> <col3>秋田県</col3> </row> <row> <col1>山形県</col1> <col2>宮城県</col2> <col3>福島県</col3> </row> </table>
2. コマンドプロンプトで、Relaxer を使用して .xsl ファイルを作成する。
relaxer -xslt 東北.xml
3. XSLT変換のための .xsl ファイルの雛形が、カレントディレクトリに作成される。
東北.xsl
<?xml version='1.0'?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes" method="xml"/> <xsl:template match="col2"> <col2> <xsl:apply-templates/> </col2> </xsl:template> <xsl:template match="col3"> <col3> <xsl:apply-templates/> </col3> </xsl:template> <xsl:template match="col1"> <col1> <xsl:apply-templates/> </col1> </xsl:template> <xsl:template match="row[col1 and col2 and col3]"> <row> <xsl:apply-templates/> </row> </xsl:template> <xsl:template match="table[row]"> <table> <xsl:apply-templates/> </table> </xsl:template> </xsl:stylesheet>
4. 雛形の .xsl ファイルを基に編集し、目的とするXSLT変換処理を記述する。
Copyright 2005-2008. ADOS Co., Ltd. All Rights Reserved. |