2017-02-08 7 views
0

xslファイルを使用してXMLを読み込んでページを作成しています。私が持っている私のページの上部にある:私はHTMLを開いたときに、私のページの上部に<xsl:template match = "// step [@ ID = 'xxx']">情報はページの上部にどのように表示されますか?

XSLT

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
<xsl:template match="//step[@ID='CCRI001']"> 

<html> 
<head> 
<title>Help - <xsl:value-of select="infoItems"/></title> 
<link rel="stylesheet" href="" type="text/css" /> 

<script language="JavaScript" for="window" event="onload"> 
function resizeWindow() 
{ 
top.resizeTo(500,300) 
} 

</script> 

</head> 
<body> 
<p><b>Functional Owner: </b><xsl:value-of select="title" /></p> 
<p><b>Number of Items: </b><xsl:value-of select="infoItems" /></p> 
<p><b>Point 1: </b><xsl:value-of select="information1" /></p> 
<p><b>Point 2: </b><xsl:value-of select="information2" /></p> 
</body> 
</html> 
</xsl:template> 
</xsl:stylesheet> 

XML

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<xml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <alerts> 
     <step ID="CCRA001"> 
      <title>ho</title> 
      <infoItems>4</infoItems> 
      <information1>z</information1> 
      <information2>y</information2> 
      <information3>x</information3> 
      <information4>w</information4> 
     </step> 
     <step ID="CCRI001"> 
      <title>hi</title> 
      <infoItems>4</infoItems> 
      <information1>a</information1> 
      <information2>b</information2> 
      <information3>c</information3> 
      <information4>d</information4> 
     </step> 
    </alerts> 
</xml> 

、私は、値の参照しますXMLから正しいxsl:template match = "// step [@ ID = 'CCRI001']"(こんにちは4 abcd)です。なぜそれが表示されているのかわかりません。

どのような考えですか?

ありがとうございます。

+0

XMLと小さな完全なXSLTを含む再現可能な例を投稿してください。[mcve]を参照してください。 –

+0

こんにちは。私はより多くの情報を追加しました。ありがとうございました。あなたのお手伝いをしていただきありがとうございます。 – brentfraser

答えて

0

あなたが見ているのは、build-in template rulesが一致するテンプレートを持たないノード(主に最初のstepとその子孫)に適用された結果です。

ではなく、試してみてください://でマッチパターンを開始することは無意味であることを

XSLT 1.0

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

<xsl:template match="/xml"> 
<html> 
<head> 
<title>Help - <xsl:value-of select="infoItems"/></title> 
<link rel="stylesheet" href="" type="text/css" /> 
<script language="JavaScript" for="window" event="onload"> 
function resizeWindow() 
{ 
top.resizeTo(500,300) 
} 
</script> 
</head> 
<body> 
<xsl:apply-templates select="alerts/step[@ID='CCRI001']"/> 
</body> 
</html> 
</xsl:template> 

<xsl:template match="step"> 
<p><b>Functional Owner: </b><xsl:value-of select="title" /></p> 
<p><b>Number of Items: </b><xsl:value-of select="infoItems" /></p> 
<p><b>Point 1: </b><xsl:value-of select="information1" /></p> 
<p><b>Point 2: </b><xsl:value-of select="information2" /></p> 
</xsl:template> 

</xsl:stylesheet> 

注意を。

+0

それは完璧だったし、それは非常にうまくいっている。ありがとう。 – brentfraser

関連する問題