如何在每个显示 [xslt 1.0] 的 select 元素后面放置一个分隔符?
How to put a delimiter behind every value-of select element that is being displayed [xslt 1.0]?
因此在匹配“AttributeList”的最后一个模板中,我需要显示其中的内容,以分隔符“,”分隔。不幸的是,我尝试的一切都不起作用;标记化,字符串函数,...
由于我在 1.0 版上。分隔符不起作用。我需要帮助!
XML:
`
<Name>Hotel Lemax</Name>
<NumberOfStars>5</NumberOfStars>
<PhotoList>
<Photo>
<Url>http://demotest.itravelsoftware.com/fotografije_itravel/7/717_636077307841478526.jpg</Url>
</Photo>
<Photo>
<Url>http://demotest.itravelsoftware.com/fotografije_itravel/7/715_636077306767263022.jpg</Url>
</Photo>
<Photo>
<Url>http://demotest.itravelsoftware.com/fotografije_itravel/7/714_636077303419440444.jpg</Url>
</Photo>
<Photo>
<Url>http://demotest.itravelsoftware.com/fotografije_itravel/7/539_636064349608545756.jpg</Url>
</Photo>
</PhotoList>
<RoomList>
<Room>
<Name>Double room</Name>
<Price>100 EUR</Price>
<AttributeList>
<Attribute>
<Name>Deluxe</Name>
</Attribute>
<Attribute>
<Name>Half board</Name>
</Attribute>
</AttributeList>
</Room>
<Room>
<Name>Triple room</Name>
<Price>200 EUR</Price>
<AttributeList>
<Attribute>
<Name>Deluxe</Name>
</Attribute>
<Attribute>
<Name>Full board</Name>
</Attribute>
<Attribute>
<Name>Jacuzzi</Name>
</Attribute>
</AttributeList>
</Room>
</RoomList>
`
XSLT:
<?xml version="1.0" encoding="utf-8"?>
<xsl:template match="/">
<html>
<head>
<title>
<xsl:value-of select="Hotel/Name"/>
</title>
</head>
<body>
<h1>
<xsl:value-of select="Hotel/Name"/>
</h1>
<h2> Number of stars:
<xsl:value-of select="Hotel/NumberOfStars"/>
</h2>
<div>
First photo: <br/>
<xsl:apply-templates select="//Photo[1]"/>
</div>
<div>
Other photos: <br/>
<xsl:call-template name="Lista"/>
<xsl:call-template name="Lista"/>
<xsl:call-template name="Lista"/>
</div>
<div>
Rooms:
<br/><br/>
<xsl:apply-templates select="//Room"/>
</div>
</body>
</html>
</xsl:template>
<xsl:template match="//Photo">
<img src="{.}" style="width: 100px; height: 100px;"></img>
</xsl:template>
<xsl:template name="Lista">
<xsl:value-of select="/PhotoList"/>
<img src="{.}" style="width: 100px; height: 100px; padding: 0 20px;"></img>
</xsl:template>
<xsl:template match="//Room">
<xsl:apply-templates select="Name"/>
<xsl:apply-templates select="Price"/>
<xsl:apply-templates select="AttributeList"/>
</xsl:template>
<xsl:template match="Name">
<b>Name:</b> <b><xsl:value-of select="."/></b> <br/><br/>
</xsl:template>
<xsl:template match="Price">
Price:<xsl:value-of select="."/>
<br/>
</xsl:template>
<xsl:template match="AttributeList">
Attributes:
<xsl:for-each select=".">
<xsl:value-of select="."/>
</xsl:for-each>
<br/><br/>
</xsl:template>
输出为:
属性:豪华半食宿
...
属性: Deluxe Full board Jacuzzi
我想要的输出是:
属性:豪华房、半食宿
...
属性: 豪华房, 全食宿, 按摩浴缸
尝试改变这个:
<xsl:template match="AttributeList">
Attributes:
<xsl:for-each select=".">
<xsl:value-of select="."/>
</xsl:for-each>
<br/><br/>
</xsl:template>
至:
<xsl:template match="AttributeList">
Attributes:
<xsl:for-each select="Attribute">
<xsl:value-of select="Name"/>
<xsl:if test="position()!=last()">, </xsl:if>
</xsl:for-each>
<br/><br/>
</xsl:template>
因此在匹配“AttributeList”的最后一个模板中,我需要显示其中的内容,以分隔符“,”分隔。不幸的是,我尝试的一切都不起作用;标记化,字符串函数,... 由于我在 1.0 版上。分隔符不起作用。我需要帮助!
XML: `
<Name>Hotel Lemax</Name>
<NumberOfStars>5</NumberOfStars>
<PhotoList>
<Photo>
<Url>http://demotest.itravelsoftware.com/fotografije_itravel/7/717_636077307841478526.jpg</Url>
</Photo>
<Photo>
<Url>http://demotest.itravelsoftware.com/fotografije_itravel/7/715_636077306767263022.jpg</Url>
</Photo>
<Photo>
<Url>http://demotest.itravelsoftware.com/fotografije_itravel/7/714_636077303419440444.jpg</Url>
</Photo>
<Photo>
<Url>http://demotest.itravelsoftware.com/fotografije_itravel/7/539_636064349608545756.jpg</Url>
</Photo>
</PhotoList>
<RoomList>
<Room>
<Name>Double room</Name>
<Price>100 EUR</Price>
<AttributeList>
<Attribute>
<Name>Deluxe</Name>
</Attribute>
<Attribute>
<Name>Half board</Name>
</Attribute>
</AttributeList>
</Room>
<Room>
<Name>Triple room</Name>
<Price>200 EUR</Price>
<AttributeList>
<Attribute>
<Name>Deluxe</Name>
</Attribute>
<Attribute>
<Name>Full board</Name>
</Attribute>
<Attribute>
<Name>Jacuzzi</Name>
</Attribute>
</AttributeList>
</Room>
</RoomList>
`
XSLT:
<?xml version="1.0" encoding="utf-8"?>
<xsl:template match="/">
<html>
<head>
<title>
<xsl:value-of select="Hotel/Name"/>
</title>
</head>
<body>
<h1>
<xsl:value-of select="Hotel/Name"/>
</h1>
<h2> Number of stars:
<xsl:value-of select="Hotel/NumberOfStars"/>
</h2>
<div>
First photo: <br/>
<xsl:apply-templates select="//Photo[1]"/>
</div>
<div>
Other photos: <br/>
<xsl:call-template name="Lista"/>
<xsl:call-template name="Lista"/>
<xsl:call-template name="Lista"/>
</div>
<div>
Rooms:
<br/><br/>
<xsl:apply-templates select="//Room"/>
</div>
</body>
</html>
</xsl:template>
<xsl:template match="//Photo">
<img src="{.}" style="width: 100px; height: 100px;"></img>
</xsl:template>
<xsl:template name="Lista">
<xsl:value-of select="/PhotoList"/>
<img src="{.}" style="width: 100px; height: 100px; padding: 0 20px;"></img>
</xsl:template>
<xsl:template match="//Room">
<xsl:apply-templates select="Name"/>
<xsl:apply-templates select="Price"/>
<xsl:apply-templates select="AttributeList"/>
</xsl:template>
<xsl:template match="Name">
<b>Name:</b> <b><xsl:value-of select="."/></b> <br/><br/>
</xsl:template>
<xsl:template match="Price">
Price:<xsl:value-of select="."/>
<br/>
</xsl:template>
<xsl:template match="AttributeList">
Attributes:
<xsl:for-each select=".">
<xsl:value-of select="."/>
</xsl:for-each>
<br/><br/>
</xsl:template>
输出为:
属性:豪华半食宿 ... 属性: Deluxe Full board Jacuzzi
我想要的输出是:
属性:豪华房、半食宿 ... 属性: 豪华房, 全食宿, 按摩浴缸
尝试改变这个:
<xsl:template match="AttributeList">
Attributes:
<xsl:for-each select=".">
<xsl:value-of select="."/>
</xsl:for-each>
<br/><br/>
</xsl:template>
至:
<xsl:template match="AttributeList">
Attributes:
<xsl:for-each select="Attribute">
<xsl:value-of select="Name"/>
<xsl:if test="position()!=last()">, </xsl:if>
</xsl:for-each>
<br/><br/>
</xsl:template>