我们有在XSL中创建的新闻稿,这允许编辑者标记文章,然后自动生成新闻稿。这是一个相对强大的系统。
我是XSL的新手,我正在努力让简报在outlook中正确显示(在网络浏览器中看起来很好,但我很确定我知道为什么会出现这些问题。
我理解通讯的各种填充问题,但我发现很难关闭表 - 是一个简单的表。我真的不确定是否有人可以帮我解决这个问题但是我们走了:
我突出了唯一有问题的代码。在粗体部分的末尾添加</table>
根本不会编译 - 它会强制我使用</xsl:template>
和</xsl:stylesheet>
关闭。这意味着斜体代码由模式&#34; top-story&#34;但这只发生在电子邮件客户端而不是浏览器中。
完整的代码太长了,不能在这里发布(长939行),所以我创建了一个简化的版本(跳跃,没有太多的语法错误)
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp " ">
<!ENTITY copy "©">
<!ENTITY reg "®">
<!ENTITY trade "™">
<!ENTITY mdash "—">
<!ENTITY ldquo "“">
<!ENTITY rdquo "”">
<!ENTITY pound "£">
<!ENTITY yen "¥">
<!ENTITY euro "€">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="iso-8859-1"/>
<!-- Load Utilities XSL -->
<xsl:include href = "$xslPath/x156.xsl"/>
<xsl:template match="/">
<xsl:choose>
<xsl:when test="search-results/size > 0">
<xsl:apply-templates select="search-results/items" />
</xsl:when>
<xsl:otherwise>
<p>There are no articles linked to this newsletter.</p>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="items">
<xsl:variable name="prem1_img">
<xsl:value-of select="document('http://www.khl-banner.com/email/world-demolition.asp')/banners/wd/banner[@slot='prem-1']/image"/>
</xsl:variable>
<xsl:variable name="prem1_link">
<xsl:value-of select="document('http://www.khl-banner.com/email/world-demolition.asp')/banners/wd/banner[@slot='prem-1']/link"/>
</xsl:variable>
<xsl:variable name="prem2_img">
<xsl:value-of select="document('http://www.khl-banner.com/email/world-demolition.asp')/banners/wd/banner[@slot='prem-2']/image"/>
</xsl:variable>
<xsl:variable name="prem2_link">
<xsl:value-of select="document('http://www.khl-banner.com/email/world-demolition.asp')/banners/wd/banner[@slot='prem-2']/link"/>
</xsl:variable>
<xsl:variable name="prem3_img">
<xsl:value-of select="document('http://www.khl-banner.com/email/world-demolition.asp')/banners/wd/banner[@slot='prem-3']/image"/>
</xsl:variable>
<xsl:variable name="prem3_link">
<xsl:value-of select="document('http://www.khl-banner.com/email/world-demolition.asp')/banners/wd/banner[@slot='prem-3']/link"/>
</xsl:variable>
<table width="770" height="25" border="0" cellpadding="0" cellspacing="0" bgcolor="#BD2125">
<tr>
<td width="10">
<img src="http://www.khl.com/other_files/newsletters/WD-new/spacer-red.gif" alt="" width="10" height="20" />
</td>
<td height="25" valign="middle" class="heading">TOP STORY »</td>
</tr>
</table>
<br></br>
**<table width="770">
<xsl:if test="data-item/item-links/item-link[@id=641]/items/item/@id=$current_item_id">
<tr>
<xsl:apply-templates select="data-item[item-links/item-link[@id=641]/items/item/@id=$current_item_id]" mode="top-story"/>
</tr>
</xsl:if>**
*<table width="760" height="40" border="0" cellpadding="0" cellspacing="0" bgcolor="#111D25">
<br></br>
<tbody>
<tr>
<td width="10">
<img src="http://www.khl.com/other_files/newsletters/WD-new/spacer-111d25.gif"/>
</td>
<td height="40" valign="middle" class="heading">DEMOLITION AND RECYCLING INTERNATIONAL NEWSLETTER »</td>
<td width="40" align="center" valign="middle" bgcolor="#36609F" class="heading">
<a href="https://en-gb.facebook.com/KHLGroup%E2%80%8E"></a>
<a href="https://www.facebook.com/DemolitionandRecyclingInternational?ref=hl">
<img src="http://www.khl.com/other_files/newsletters/WD-new/social-icon-facebook.gif"/>
</a>
<a href="http://www.facebook.com/pages/Demolition-Recycling-International/129306127144056"></a>
</td>
<td width="10" valign="middle" class="heading"> </td>
<td width="40" align="center" valign="middle" bgcolor="#2CAAE1" class="heading">
<a href="https://twitter.com/KHLConstruction%E2%80%8E"></a>
<a href="http://www.twitter.com/KHL_DRI">
<img src="http://www.khl.com/other_files/newsletters/WD-new/social-icon-twitter.gif"/>
</a>
<a href="http://www.twitter.com/KHL_DRI"></a>
</td>
<td width="10" valign="middle" class="heading"> </td>
<td width="40" align="center" valign="middle" bgcolor="#0A6C9B" class="heading">
<a href="http://www.linkedin.com/company/khl-group%E2%80%8E"></a>
<a href="http://www.linkedin.com/groups?gid=3546771&trk=my_groups-b-grp-v">
<img src="http://www.khl.com/other_files/newsletters/WD-new/social-icon-linkedin.gif"/>
</a>
<a href="http://www.linkedin.com/groups/World-Demolition-Summit-2011-3983919?trk=myg_ugrp_ovr"></a>
</td>
<td width="10" valign="middle" class="heading"> </td>
<td width="40" align="center" valign="middle" bgcolor="#EE3537" class="heading">
<a href="http://www.youtube.com/khlgroup">
<img src="http://www.khl.com/other_files/newsletters/WD-new/social-icon-youtube.gif"/>
</a>
<a href="http://www.youtube.com/user/KHLGroup/videos?view=1"></a>
</td>
<td width="10" valign="middle" class="heading"> </td>
<td width="40" align="center" valign="middle" bgcolor="#F58020" class="heading">
<a href="http://www.khl.com/feeds">
<img src="http://www.khl.com/other_files/newsletters/WD-new/social-icon-rss.gif"/>
</a>
</td>
<td width="10" valign="middle" class="heading"> </td>
</tr>
</tbody>
</table>*
<table width="70" height="10" border="0" cellpadding="0" cellspacing="0">
<br></br>
<tbody>
<tr>
<td bgcolor="#666666" width="80" style="font-size: 11px; line-height: 18px; font-family: Arial,Tahoma, Helvetica, sans-serif; color:#bc2024; font-weight:bold; text-align:center;" title="textColor">
<span title="textColor" style="text-decoration: none; color: #FFFFFF;"> SPONSOR </span>
</td>
</tr>
<xsl:if test="$prem1_img != ''">
<tr>
<td colspan="2">
<table cellspacing="0" cellpadding="0" border="0" width="764">
<tbody>
<tr>
<td colspan="2" height="50" align="center">
<!--img height="30" width="760" src="http://www.khl.com/other_files/newsletters/world-demolition/wd-sponsor.gif" /><br /-->
<a href="{$prem1_link}">
<img border="0" src="{$prem1_img}" />
</a>
<br />
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</xsl:if>
</tbody>
</table>
<table width="770" height="25" border="0" cellpadding="0" cellspacing="0" bgcolor="#111D25">
<br></br>
<tr>
<td width="10">
<img src="http://www.khl.com/other_files/newsletters/WD-new/spacer-111d25.gif" alt="" width="10" height="20" />
</td>
<td height="25" valign="middle" class="heading">DEMOLITION NEWS »</td>
</tr>
</table>
-->
<xsl:if test="$prem3_img != ''">
<tr>
<td colspan="2">
<table cellspacing="0" cellpadding="0" border="0" width="764">
<tbody>
<tr>
<td colspan="2" height="120" align="center">
<!--img height="30" width="760" src="http://www.khl.com/other_files/newsletters/world-demolition/wd-sponsor.gif" /><br /-->
<a href="{$prem3_link}">
<img border="0" src="{$prem3_img}" />
</a>
<br />
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</xsl:if>
</table>
</xsl:template>
<xsl:template match="data-item" mode="access-news">
<xsl:variable name="title">
<xsl:call-template name="replaceTitle">
<xsl:with-param name="title" select="content/item/title"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="path">
<xsl:call-template name="detail_path">
<xsl:with-param name="item" select="current()"/>
</xsl:call-template>
</xsl:variable>
<td width="110" valign="top" class="tumbImage">
<a href="http://www.khl.com{$path}/{link}{$title}?nltr=rw">
<xsl:choose>
<xsl:when test="item-links/item-link[@id=466]/items/item[1]">
<img border="0" width="110" height="80" src="http://www.khl.com{item-links/item-link[@id=466]/items/item/derived-files/preview}"/>
</xsl:when>
<xsl:otherwise>
<img border="0" width="110" height="80" src="http://www.khl.com{item-links/item-link[@id=2]/items/item/derived-files/preview}"/>
</xsl:otherwise>
</xsl:choose>
</a>
</td>
<td width="285" valign="top">
<a class="headLineLink2" href="http://www.khl.com{$path}/{link}{$title}?nltr=rw">
<strong>
<xsl:value-of select="name" />
</strong>
</a>
<br />
<br />
<xsl:value-of select="substring(content/item/standfirst,0,120)" disable-output-escaping="yes"/>
<xsl:text>...</xsl:text>
</td>
</xsl:template>
<xsl:template match="data-item" mode="access-news2">
<xsl:variable name="title">
<xsl:call-template name="replaceTitle">
<xsl:with-param name="title" select="content/item/title"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="path">
<xsl:call-template name="detail_path">
<xsl:with-param name="item" select="current()"/>
</xsl:call-template>
</xsl:variable>
<td width="110" valign="top" class="tumbImage">
<a href="http://www.khl.com{$path}/{link}{$title}?nltr=rw">
<xsl:choose>
<xsl:when test="item-links/item-link[@id=466]/items/item[1]">
<img border="0" width="110" height="80" src="http://www.khl.com{item-links/item-link[@id=466]/items/item/derived-files/preview}"/>
</xsl:when>
<xsl:otherwise>
<img border="0" width="110" height="80" src="http://www.khl.com{item-links/item-link[@id=2]/items/item/derived-files/preview}"/>
</xsl:otherwise>
</xsl:choose>
</a>
</td>
<td width="300" valign="top">
<a class="headLineLink2" href="http://www.khl.com{$path}/{link}{$title}?nltr=rw">
<strong>
<xsl:value-of select="name" />
</strong>
</a>
<br />
<br />
<xsl:value-of select="substring(content/item/standfirst,0,282)" disable-output-escaping="yes"/>
<xsl:text>...</xsl:text>
</td>
</xsl:template>
<xsl:template match="data-item" mode="access-news3">
<xsl:variable name="title">
<xsl:call-template name="replaceTitle">
<xsl:with-param name="title" select="content/item/title"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="path">
<xsl:call-template name="detail_path">
<xsl:with-param name="item" select="current()"/>
</xsl:call-template>
</xsl:variable>
<tr>
<td width="250">
<a class="headLineLink2" href="http://www.khl.com{$path}/{link}{$title}?nltr=rw">
<strong>
<xsl:value-of select="name" />
</strong>
</a>
</td>
</tr>
<td width="110" valign="top" class="tumbImage">
<a href="http://www.khl.com{$path}/{link}{$title}?nltr=rw">
<xsl:choose>
<xsl:when test="item-links/item-link[@id=466]/items/item[1]">
<img border="0" width="110" height="80" align="left" src="http://www.khl.com{item-links/item-link[@id=466]/items/item/derived-files/preview}"/>
</xsl:when>
<xsl:otherwise>
<img border="0" width="110" height="80" align="left" src="http://www.khl.com{item-links/item-link[@id=2]/items/item/derived-files/preview}"/>
<img src="http://www.khl.com/other_files/newsletters/spacer-new.gif" width="10" height="110" align="left"></img>
</xsl:otherwise>
</xsl:choose>
</a>
<xsl:value-of select="substring(content/item/standfirst,0,120)" disable-output-escaping="yes"/>
<xsl:text>...</xsl:text>
</td>
</xsl:template>
<xsl:template match="data-item" mode="access-newsQ">
<xsl:variable name="title">
<xsl:call-template name="replaceTitle">
<xsl:with-param name="title" select="content/item/title"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="path">
<xsl:call-template name="detail_path">
<xsl:with-param name="item" select="current()"/>
</xsl:call-template>
</xsl:variable>
<tr>
<td width="250">
<a class="headLineLink2" href="http://www.khl.com{$path}/{link}{$title}?nltr=rw">
<strong>
<xsl:value-of select="name" />
</strong>
</a>
</td>
</tr>
<td width="110" valign="top" class="tumbImage">
<a href="http://www.khl.com{$path}/{link}{$title}?nltr=rw">
<xsl:choose>
<xsl:when test="item-links/item-link[@id=466]/items/item[1]">
<img border="0" width="110" height="80" align="left" src="http://www.khl.com{item-links/item-link[@id=466]/items/item/derived-files/preview}"/>
</xsl:when>
<xsl:otherwise>
<img border="0" width="110" height="80" align="left" src="http://www.khl.com{item-links/item-link[@id=2]/items/item/derived-files/preview}"/>
<img src="http://www.khl.com/other_files/newsletters/spacer-new.gif" width="10" height="110" align="left"></img>
</xsl:otherwise>
</xsl:choose>
</a>
<xsl:value-of select="substring(content/item/standfirst,0,120)" disable-output-escaping="yes"/>
<xsl:text>...</xsl:text>
</td>
</xsl:template>
<xsl:template match="data-item" mode="access-newsN">
<xsl:variable name="title">
<xsl:call-template name="replaceTitle">
<xsl:with-param name="title" select="content/item/title"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="path">
<xsl:call-template name="detail_path">
<xsl:with-param name="item" select="current()"/>
</xsl:call-template>
</xsl:variable>
<tr>
<td width="250">
<a class="headLineLink2" href="http://www.khl.com{$path}/{link}{$title}?nltr=rw">
<strong>
<xsl:value-of select="name" />
</strong>
</a>
</td>
</tr>
<td width="110" valign="top" class="tumbImage">
<a href="http://www.khl.com{$path}/{link}{$title}?nltr=rw">
<xsl:choose>
<xsl:when test="item-links/item-link[@id=466]/items/item[1]">
<img border="0" width="110" height="80" align="left" src="http://www.khl.com{item-links/item-link[@id=466]/items/item/derived-files/preview}"/>
</xsl:when>
<xsl:otherwise>
<img border="0" width="110" height="80" align="left" src="http://www.khl.com{item-links/item-link[@id=2]/items/item/derived-files/preview}"/>
<img src="http://www.khl.com/other_files/newsletters/spacer-new.gif" width="10" height="110" align="left"></img>
</xsl:otherwise>
</xsl:choose>
</a>
<xsl:value-of select="substring(content/item/standfirst,0,120)" disable-output-escaping="yes"/>
<xsl:text>...</xsl:text>
</td>
</xsl:template>
<xsl:template match="data-item" mode="top-story">
<xsl:variable name="title">
<xsl:call-template name="replaceTitle">
<xsl:with-param name="title" select="content/item/title"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="path">
<xsl:call-template name="detail_path">
<xsl:with-param name="item" select="current()"/>
</xsl:call-template>
</xsl:variable>
<td valign="top" bgcolor="#ffffff" class="tumbImage">
<a href="http://www.khl.com{$path}/{link}{$title}?nltr=wd">
<xsl:choose>
<xsl:when test="item-links/item-link[@id=466]/items/item[1]">
<img border="0" width="200" height="146" src="http://www.khl.com{item-links/item-link[@id=466]/items/item/derived-files/preview}"/>
</xsl:when>
<xsl:otherwise>
<img border="0" width="200" height="146" src="http://www.khl.com{item-links/item-link[@id=2]/items/item/derived-files/preview}"/>
</xsl:otherwise>
</xsl:choose>
</a>
</td>
<td valign="top" bgcolor="#ffffff">
<span class="headLineLink">
<a href="http://www.khl.com{$path}/{link}{$title}?nltr=wd">
<strong>
<xsl:value-of select="name" />
</strong>
</a>
</span>
<p>
<span class="toparticlemaintext">
<xsl:value-of select="substring(content/item/standfirst,0,282)" disable-output-escaping="yes"/>
<p> </p>
<xsl:text> </xsl:text>
</span>
<a class="moreLink" href="http://www.khl.com{$path}/{link}{$title}?nltr=wd">View article »</a>
</p>
</td>
</xsl:template>
<xsl:template match="data-item" mode="other">
<xsl:variable name="title">
<xsl:call-template name="replaceTitle">
<xsl:with-param name="title" select="content/item/title"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="path">
<xsl:call-template name="detail_path">
<xsl:with-param name="item" select="current()"/>
</xsl:call-template>
</xsl:variable>
<td>
<a href="http://www.khl.com{$path}/{link}{$title}?nltr=wd">
<xsl:choose>
<xsl:when test="item-links/item-link[@id=466]/items/item[1]">
<img border="0" width="130" height="80" src="http://www.khl.com{item-links/item-link[@id=466]/items/item/derived-files/preview}"/>
</xsl:when>
<xsl:otherwise>
<img border="0" width="130" height="80" src="http://www.khl.com{item-links/item-link[@id=2]/items/item/derived-files/preview}"/>
</xsl:otherwise>
</xsl:choose>
</a>
</td>
<td valign="top">
<a class="headLineLink" href="http://www.khl.com{$path}/{link}{$title}?nltr=wd">
<strong>
<xsl:value-of select="name" />
</strong>
</a>
<p>
<span name="input-code">
<xsl:value-of select="substring(content/item/standfirst,0,282)" disable-output-escaping="yes"/>
<xsl:text> . . .</xsl:text>
</span>
<a class="moreLink" href="http://www.khl.com{$path}/{link}{$title}?nltr=wd">more</a>
</p>
</td>
</xsl:template>
</xsl:stylesheet>
XML CODE:
<?xml version="1.0" encoding="UTF-8"?>
<search-results>
<size>0</size>
<start-index>1</start-index>
<end-index>1</end-index>
<page-no>1</page-no>
<no-of-pages>1</no-of-pages>
<items-per-page>0</items-per-page>
<forward>
<action>/vyre4/pub_module/pageview4757_70?portal:componentId=16821&portal:type=action&portal:isSecure=false&portal:portletMode=xml</action>
</forward>
<action-path>/vyre4/pub_module/pageview4757_70?portal:componentId=16821&portal:type=action&portal:isSecure=false&portal:portletMode=xml</action-path>
<action-extensions>
<add-to-basket>
<order>&addToBasket=order</order>
<bulk-edit>&addToBasket=bulkEdit</bulk-edit>
</add-to-basket>
<sortable-attributes>
<score>&sortBy=score</score>
<name>&sortBy=sort_name</name>
<creationDate>&sortBy=sort_creationDate_t</creationDate>
<lastModifiedDate>&sortBy=sort_lastModifiedDate_t</lastModifiedDate>
<viewCount>&sortBy=viewCount</viewCount>
<orderCount>&sortBy=orderCount</orderCount>
<ratingAverage>&sortBy=ratingAverage</ratingAverage>
<creatorFamilyName>&sortBy=sort_creatorFamilyName_s</creatorFamilyName>
<creatorFullName>&sortBy=sort_creatorFullName_s</creatorFullName>
<creatorGivenName>&sortBy=sort_creatorGivenName_s</creatorGivenName>
<creatorUserName>&sortBy=sort_creatorUserName_s</creatorUserName>
<lastModifierFamilyName>&sortBy=sort_lastModifierFamilyName_s</lastModifierFamilyName>
<lastModifierFullName>&sortBy=sort_lastModifierFullName_s</lastModifierFullName>
<lastModifierGivenName>&sortBy=sort_lastModifierGivenName_s</lastModifierGivenName>
<lastModifierUserName>&sortBy=sort_lastModifierUserName_s</lastModifierUserName>
<att869>&sortBy=sort_att869_s</att869>
<att10>&sortBy=sort_att10_s</att10>
<att871>&sortBy=sort_att871_s</att871>
<att870>&sortBy=sort_att870_s</att870>
<att5>&sortBy=sort_att5_s</att5>
<att8>&sortBy=sort_att8_t</att8>
</sortable-attributes>
<sort-directions>
<asc>&orderBy=asc</asc>
<desc>&orderBy=desc</desc>
</sort-directions>
<items-per-page>&itemsPerPage=</items-per-page>
<do-redirect>&doRedirect=</do-redirect>
<page-no>&pageNo=</page-no>
<previous-actions/>
</action-extensions>
<search-term>+(+(+active:true +att7:1 +att8:[0 TO $current_date] +(ITEM_LINK_DEF641:$current_item_id OR ITEM_LINK_DEF642:$current_item_id OR ITEM_LINK_DEF643:$current_item_id OR ITEM_LINK_DEF644:$current_item_id OR ITEM_LINK_DEF645:$current_item_id OR ITEM_LINK_DEF646:$current_item_id OR ITEM_LINK_DEF647:$current_item_id OR ITEM_LINK_DEF648:$current_item_id OR ITEM_LINK_DEF649:$current_item_id OR ITEM_LINK_DEF650:$current_item_id OR ITEM_LINK_DEF652:$current_item_id OR ITEM_LINK_DEF669:$current_item_id OR ITEM_LINK_DEF670:$current_item_id or ITEM_LINK_DEF691:$current_item_id))) +locale:en -(ITEM_LINK_DEF9:57303 OR ITEM_LINK_DEF9:57302)</search-term>
<sorting>
<first-sort-field>att8</first-sort-field>
<first-sort-field-direction>desc</first-sort-field-direction>
<second-sort-field>lastModifiedDate</second-sort-field>
<second-sort-field-direction>desc</second-sort-field-direction>
</sorting>
<items/>
</search-results>
答案 0 :(得分:0)
XSLT代码必须是格式良好的XML。这意味着你不能将start-table标签分成一个模板,将end-table标签分成另一个模板;每个模板都必须平衡。
我没有仔细查看你的样式表,但通常的解决方法是将<table></table>
对移动到一个级别,将它们包裹在生成表格内容的<xsl:apply-templates>
周围。