2012-05-10 4 views
1

이 XML 파일이 있습니다. 이 단일 XML 파일을 사용하여 각각의 노드가있는 여러 개별 페이지로 분할하고 링크를 통해 탐색 할 수 있습니까? 누군가 나에게 출발점을 줄 수 있습니까?XSLT를 사용하여 여러 HTML 페이지를 생성하는 방법은 무엇입니까?

XML 파일

<Colors> 
    <Color> 
     <description> 
      <p>This page is red.</p> 
     </description> 
    </Color> 
    <Color> 
     <description> 
      <p>This page is blue.</p> 
     </description> 
    </Color> 
    <Color> 
     <description> 
      <p>This page is green.</p> 
     </description> 
    </Color> 
<Colors> 

출력 :

<html> 
    <head></head> 
    <body> 
    This page is red. 
    </body> 
</html> 


<html> 
    <head></head> 
    <body> 
    This page is blue. 
    </body> 
</html> 


<html> 
    <head></head> 
    <body> 
    This page is green. 
    </body> 
</html> 
+0

하나의 큰 파일에 별도의 출력 파일 또는 여러 개의 ''태그 만 생성 하시겠습니까? – Tomalak

+0

별도의 출력 파일이라고 생각합니다. 버튼이나 하이퍼 링크로 각 페이지를 탐색 할 수 있습니다. –

답변

2

XSLT 1.0 또는 2.0?

나는 1.0에서 다중 출력 키워드가 없다는 것을 두려워합니다. 외부에서 뭔가를해야합니다. 파라미터와 XSLT :

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 

    <xsl:output indent="yes" method="html" /> 

    <xsl:param name="n" select="1"/> 

    <xsl:template match="Color"> 
    <xsl:value-of select="."/> 
    </xsl:template> 

    <xsl:template match="/Colors"> 
    <html> 
     <head></head> 
     <body> 
     <xsl:apply-templates select="Color[$n]"/> 
     </body> 
    </html> 
    </xsl:template> 

</xsl:stylesheet> 

및 파라미터 반복적 다른 값을 호출 (n 위의 예는 = Color 소자의 수는 사용 - 1, 2, 3 등)

XSLT 2.0을 참조하십시오. this 예제

+0

버튼이나 하이퍼 링크를 추가하여 각 개별 페이지에 액세스하려면 어떻게해야합니까? –

+0

각 페이지는 하이퍼 링크에서 사용할 수있는 고정 된 이름 (예 :'colorXXX.html')이있는 HTML 파일입니다. 동일한 매개 변수를 사용하여 동일한 XSLT를 만들 수도 있지만이 하이퍼 링크도 생성해야하지만 올바른 매개 변수를 사용하여 다른 곳에서 호출해야합니다. – MiMo

2

xsl:result-document 단일 스타일에서 출력 여러 파일을 처리하기 위해 사용될 수있다.

관련 문제