게시판 즐겨찾기
편집
드래그 앤 드롭으로
즐겨찾기 아이콘 위치 수정이 가능합니다.
XSLT 불러 오기 관련 질문 합니다!!
게시물ID : programmer_20158짧은주소 복사하기
작성자 : Benny
추천 : 0
조회수 : 285회
댓글수 : 0개
등록시간 : 2017/04/02 06:53:11
옵션
  • 창작글
  • 베스트금지
  • 베오베금지
  • 본인삭제금지
  • 외부펌금지
안녕하세요~ 매번 도움은 되질 않고 귀찮게 질문만 올리네요 ^^;;

본론으로 들어가서, 이렇게 .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 &amp; Bainard EB">
    <location>
      <latitude>42.91033567</latitude>
      <longitude>-81.29671483</longitude>
    </location>
    <routes>28</routes>
  </stop>
  <stop number="20" name="Adelaide &amp; Ada NB">
    <location>
      <latitude>42.9742886</latitude>
      <longitude>-81.2252341</longitude>
    </location>
    <routes>16</routes>
  </stop>
  <stop number="22" name="Adelaide &amp; Central Ave NB">
    <location>
      <latitude>42.9945666</latitude>
      <longitude>-81.2343441</longitude>
    </location>
    <routes>16</routes>
  </stop>
  <stop number="24" name="Adelaide &amp; Cheapside St NB">
    <location>
      <latitude>43.0064704</latitude>
      <longitude>-81.2401808</longitude>
    </location>
    <routes>16</routes>
  </stop>
  <stop number="27" name="Adelaide &amp; Dundas St NB">
    <location>
      <latitude>42.9892141</latitude>
      <longitude>-81.2316861</longitude>
    </location>
    <routes>16</routes>
  </stop>
  <stop number="33" name="Adelaide &amp; Glenora Dr NB">
    <location>
      <latitude>43.0290169</latitude>
      <longitude>-81.2516038</longitude>
    </location>
    <routes>16</routes>
  </stop>
  <stop number="34" name="Adelaide &amp; Grosvenor St NB">
    <location>
      <latitude>43.0043373</latitude>
      <longitude>-81.2391718</longitude>
    </location>
    <routes>16</routes>
  </stop>
  <stop number="37" name="Adelaide &amp; Hill St NB">
    <location>
      <latitude>42.9798268</latitude>
      <longitude>-81.2276077</longitude>
    </location>
    <routes>16</routes>
  </stop>
  <stop number="39" name="Adelaide &amp; 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 &amp; 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"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    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>

전체 추천리스트 보기
새로운 댓글이 없습니다.
새로운 댓글 확인하기
글쓰기
◀뒤로가기
PC버전
맨위로▲
공지 운영 자료창고 청소년보호