각 문서가 책의 한 장인 여러 XML 문서가 있습니다. 이 모든 파일은 <book>
이 루트 요소로 추가 된 하나의 DOMDocument로 병합됩니다. (장 = 1, 즉 default.php?.)위치로 매개 변수 값 사용
<book>
<chapter title="This is the first chapter">
<section title="This is the first section">
<paragraph title="This is the first paragraph">This is the paragraph content</paragraph>
</section>
</chapter>
<chapter title="This is the second chapter">
<section title="This is the first section">
<paragraph title="This is the first paragraph">This is the paragraph content</paragraph>
</section>
</chapter>
</book>
나는 성공적으로 내가 쿼리 문자열에 링크 장을 선택할 수있는 목차를 만들고있어 :
있는 DOMDocument는 다음과 같은 구조를 가져옵니다. 챕터를 열려고하면 param "chapter"가 쿼리 문자열로 설정됩니다.
쿼리 스트링과 동일한 장을 성공적으로 표시하려면 어떻게합니까? param에서 위치를 설정하는 데 문제가 발생합니다. "정의되지 않은 변수"오류가 발생합니다. 그러나 가치의 사용에 오류가 없습니다. "? default.php 장 1 ="
<xsl:param name="chapter" />
<xsl:template match="//chapter[$chapter]">
<html>
<head>
<title><xsl:value-of select="$chapter"/> - <xsl:value-of select="@title"/></title>
</head>
<body>
<h1>
Chapter <xsl:value-of select="$chapter"/> <xsl:value-of select="@title"/>
</h1>
<xsl:apply-templates />
</body>
</html>
</xsl:template>
그럼, 내가 원하는 사용자가 방문은 그가이 같은 유일한 1 장을 얻을 때이다 :
<html>
<head>
<title>Chapter 1 - This is chapter 1</title>
</head>
<body>
<h1>Chapter 1 - This is chapter 1</h1>
blablablablablablabla
</body>
</html>
안부, 피터. 나는 당신이 성취하려고하는 것을 이해하지 못합니다. 기대하는 목표 XML을 게시 하시겠습니까? –
Peter
결과로 원하는대로 내 질문을 업데이트했습니다. 난 단지 querystring을 기반으로 1 장을 보여주고 싶다. – janlindso