我有一个xpath集合来搜索第一个和第二个标题,但第二个出现为空白,即时猜测这一定很容易,但是我试着改变路径名很多次,我不能改变似乎解决了这个问题,然后我用了一个每个找出是否我的XML文件不正确,但我的循环似乎很容易找到。x路径不算第二个元素
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:foo="blogschema.xsd"
exclude-result-prefixes="foo">
<xsl:output method ="html" indent ="no"/>
<xsl:template match="/">
<html>
<link rel ="stylesheet" type="text/css" href="blogStyle.css"/>
<body>
<ul class="menu">
<li><a href="#" class ="Part 1"><xsl:value-of select="//foo:Heading[1]"/> </a></li>
<li><a href="#" class ="Part 2"><xsl:value-of select="//foo:Heading[2]"/></a></li>
</ul>
<div id="heading">
<xsl:for-each select="//foo:Entry">
<!--<xsl:sort select="Heading"/> -->
<div class ="topNavigation"><a href="#home"><h3><xsl:value-of select="foo:Heading"/></h3></a></div>
</xsl:for-each>
<div class ="panes">
</div>
</div>
<div id ="blogpicture">
<div class="picture">
<div id="headerTitle"><h2><xsl:value-of select="//foo:Title"/></h2></div>
</div>
</div>
</body>
</html>
</xsl:template>
</xsl:transform>
IM试图得到一个菜单,但现在让所有的IM是菜单的第1部分,在for循环,我可以得到部分2.A替代的方法是坚持使用循环,因为我“M循环的循环过程中以某种方式改变类(incrment类ID) 我的博客
<Entry>
<Heading id="101">Part 1</Heading>
<body>
<text>something interesting</text>
<pictures>pictures in the body</pictures>
<videos>Videos in the body</videos>
</body>
<labels>Seperate labels with commas</labels>
<date> 20121119</date>
<location>The location the blog was published</location>
</Entry>
<Entry>
<Heading id="102">Part 2</Heading>
<body>
<text>something</text>
<pictures>pictures in the body</pictures>
<videos>Videos in the body</videos>
</body>
<labels>Seperate labels with commas</labels>
<date> 2012-11-26Z</date>
<location>The location the blog was published</location>
</Entry>
<author>me</author>
我希望这样做有一定意义 当前进入菜单的输出im是第1部分,然后是“”我想要第2部分的位置。然而,在xsl中的每个循环都带有第1部分和第2部分的标题
你能格式化你的代码,使其更具可读性吗? –