如何删除在打破链接的“Location”元素后添加的空格? IE: “/位置toxxx.aspx” XML删除xsl中的空白
- <Root>
<Schema>
<Field Type="Text" DisplayName="Location" Required="FALSE" MaxLength="255" Name="Location" />
<Field Type="Currency" DisplayName="Price one way-saloon" Required="FALSE" Decimals="0" LCID="2057" Name="Price_x0020_one_x0020_way" />
<Field Type="Currency" DisplayName="Price return-saloon" Required="FALSE" Decimals="0" LCID="2057" Name="Price_x0020_return" />
<Field ReadOnly="TRUE" Type="Computed" Name="LinkTitle" DisplayName="Location id" />
<Field Type="Currency" DisplayName="Price one way-estate" Required="FALSE" Decimals="0" LCID="2057" Name="Price_x0020_one_x0020_way_x002d_" />
<Field Type="Currency" DisplayName="Price return-estate" Required="FALSE" Decimals="0" LCID="2057" Name="Price_x0020_return_x002d_estate" />
<Field Type="Currency" DisplayName="Price one way-MPV" Required="FALSE" Decimals="0" LCID="2057" Name="Price_x0020_one_x0020_way_x002d_0" />
<Field Type="Currency" DisplayName="Price return-MPV" Required="FALSE" Decimals="0" LCID="2057" Name="Price_x0020_return_x002d_MPV" />
<Field Type="Currency" DisplayName="Price one way-MPV+" Required="FALSE" Decimals="0" LCID="2057" Name="Price_x0020_one_x0020_way_x002d_1" />
<Field Type="Currency" DisplayName="Price return-MPV+" Required="FALSE" Decimals="0" LCID="2057" Name="Price_x0020_return_x002d_MPV_x00" />
</Schema>
<Data ItemCount="1">
<Row Location="" Price_x0020_one_x0020_way="" Price_x0020_return="" LinkTitle="" Price_x0020_one_x0020_way_x002d_="" Price_x0020_return_x002d_estate="" Price_x0020_one_x0020_way_x002d_0="" Price_x0020_return_x002d_MPV="" Price_x0020_one_x0020_way_x002d_1="" Price_x0020_return_x002d_MPV_x00="" />
</Data>
</Root>
XSL
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" />
<xsl:template match="/">
<div id="locations">
<ul id ="navbar" class="MSC_PrimaryNavFrame">
<li><a href="#"><b>Going to Heathrow?<br />Find your fare fast!</b></a>
<ul class="locations">
<xsl:for-each select="//Data/Row">
<li><a><xsl:attribute name ="href"><xsl:value-of select="@Location"/>_toheathrow.aspx</xsl:attribute>
<xsl:value-of select = "@Location" />
</a>
</li>
</xsl:for-each>
</ul>
</li>
</ul>
</div></xsl:template>
</xsl:stylesheet>
很抱歉,如果我没有贴码正确,如果我留在换行符它删除部分。
好问题,+1。查看我对三种不同XSLT 1的回答。0解决方案和第四个仅在XSLT 2.0中可用的解决方案。我建议在可能的情况下始终使用AVT。 – 2011-06-14 02:17:41
不好的问题-1!您发布的代码不会添加您抱怨的空白。我得到的印象是你的真实代码是不同的,并且在“toHeathrow”字符串旁边有空白 - 但你已经让我猜测了。 – 2011-06-14 07:55:24
@Michael Kay:我认为@matt在编写代码时遇到困难。当我读到这个问题时,在“toHeathrow.aspx”之后有一个回车符和空格 - 可能是我自己的IDE重新格式化的结果。 – 2011-06-14 12:50:19