我們有在XSL中創建的新聞簡報,這允許編輯者標記文章,然後自動生成新聞簡報。這是一個相對強大的系統。在XSL中爲簡報收一個簡單表格
我是新來的XSL和我在努力讓通訊在Outlook中正確顯示(它出現100%的罰款在Web瀏覽器,但我敢肯定我知道爲什麼問題發生。
我明白各種填充問題簡報,但我發現很難關閉表 - 是一個簡單的表,我真的不知道,如果有人能幫助我解決這一點,但在這裏我們去:
我強調唯一有問題的代碼。 。在大膽的部分末尾添加</table>
就不會編譯 - 它迫使我關閉</xsl:template>
和</xsl:stylesheet>
。這意味着斜體代碼de的模式是「頂級故事」,但這隻發生在電子郵件客戶端而不是瀏覽器。
完整的代碼太長,張貼在這裏(939線長),所以我創建了一個簡化版本(hopfully有沒有太多的語法錯誤)
<?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代碼:
<?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>
你的輸入XML是什麼樣的? – JLRishe
嗨XML是好的,因爲所有的數據都被拉出來,並且在這個評論中打印太長編輯:張貼以上 – user3036451
我並不是說你的XML有問題。我指出我們需要一些XML來測試和理解你的509行XSLT。 – JLRishe