안녕하세요~ 매번 도움은 되질 않고 귀찮게 질문만 올리네요 ^^;;
본론으로 들어가서, 이렇게 .xml 파일이 있고, .xslt 파일이 있습니다. 당연히 .xslt 파일에서 .xml 파일에 관련 정보를 불러 와서 결과를 나타내게
하려고 합니다.
1. 그냥 update 만 클릭시 모든 .xml 파일을 테이블로 나타내기.
2. 특정 Route 번호를 입력시 (예를들어 16) 16번 노선만 나타내기.
이 두가지를 하려고 합니다. 첫번째는 결과가 나타내는데 두번째 문제가 어렵네요 ㅠㅜ
template 안에 if 문을 써야 한다고 하는데 어디다가 넣어야 할지 감이 안옵니다.
그리고 나오는 결과 값들을 내림차순으로 결과를 나타 내려고 합니다.
<xsl:apply-templates>
<xsl:sort select="@number" order="ascending" data-type="number"/>
</xsl:apply-templates> <-- 어디다가 집어 넣어야 할까요...
감사합니다!!
<---- XML ---->
<allstops>
<stop number="2504" name="Main & Bainard EB">
<location>
<latitude>42.91033567</latitude>
<longitude>-81.29671483</longitude>
</location>
<routes>28</routes>
</stop>
<stop number="20" name="Adelaide & Ada NB">
<location>
<latitude>42.9742886</latitude>
<longitude>-81.2252341</longitude>
</location>
<routes>16</routes>
</stop>
<stop number="22" name="Adelaide & Central Ave NB">
<location>
<latitude>42.9945666</latitude>
<longitude>-81.2343441</longitude>
</location>
<routes>16</routes>
</stop>
<stop number="24" name="Adelaide & Cheapside St NB">
<location>
<latitude>43.0064704</latitude>
<longitude>-81.2401808</longitude>
</location>
<routes>16</routes>
</stop>
<stop number="27" name="Adelaide & Dundas St NB">
<location>
<latitude>42.9892141</latitude>
<longitude>-81.2316861</longitude>
</location>
<routes>16</routes>
</stop>
<stop number="33" name="Adelaide & Glenora Dr NB">
<location>
<latitude>43.0290169</latitude>
<longitude>-81.2516038</longitude>
</location>
<routes>16</routes>
</stop>
<stop number="34" name="Adelaide & Grosvenor St NB">
<location>
<latitude>43.0043373</latitude>
<longitude>-81.2391718</longitude>
</location>
<routes>16</routes>
</stop>
<stop number="37" name="Adelaide & Hill St NB">
<location>
<latitude>42.9798268</latitude>
<longitude>-81.2276077</longitude>
</location>
<routes>16</routes>
</stop>
<stop number="39" name="Adelaide & Huron St 1 NB">
<location>
<latitude>43.0126055</latitude>
<longitude>-81.2434425</longitude>
</location>
<routes>01, 16, 27, 32</routes>
</stop>
<stop number="41" name="Adelaide & Huron St 2 NB">
<location>
<latitude>43.0139707</latitude>
<longitude>-81.2441378</longitude>
</location>
<routes>01, 16, 27, 32</routes>
</stop>
<--- XSLT --->
<?xml version="1.0" encoding="utf-8"?>
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<h1>
<font face="Verdana">
All LTC Stops
<xsl:value-of select="count(@number)"/> stops found
</font>
</h1>
<table style="width:720px" border="3">
<tr>
<th>
<font face="Verdana" size="4">Stop #</font>
</th>
<th>
<font face="Verdana" size="4">Stop Name</font>
</th>
<th>
<font face="Verdana" size="4">Latitude</font>
</th>
<th>
<font face="Verdana" size="4">Longitude</font>
</th>
<th>
<font face="Verdana" size="4">Routes</font>
</th>
</tr>
<xsl:apply-templates select="//stop" />
<!-- <xsl:apply-templates>
<xsl:sort select="@number" order="ascending" data-type="number"/>
</xsl:apply-templates> -->
</table>
</xsl:template>
<xsl:template match="stop">
<xsl:element name="tr">
<xsl:element name="td">
<xsl:value-of select="@number"/>
</xsl:element>
<xsl:element name="td">
<xsl:value-of select="@name"/>
</xsl:element>
<xsl:element name="td">
<xsl:value-of select="location/latitude"/>
</xsl:element>
<xsl:element name="td">
<xsl:value-of select="location/longitude"/>
</xsl:element>
<xsl:element name="td">
<xsl:value-of select="routes"/>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>