我有一个XSL模板有点奇怪的情况。它的大部分输出很好,但是每个循环都有一定的问题。XSL模板输出大量文本,而不是HTML。但只在一个部分
这里的XML:
<area>
<feature type="Hall">
<Heading><![CDATA[Hall]]></Heading>
<Para><![CDATA[Communal gardens, pathway leading to PVCu double glazed communal front door to]]></Para>
</feature>
<feature type="Entrance Hall">
<Heading><![CDATA[Communal Entrance Hall]]></Heading>
<Para><![CDATA[Plain ceiling, centre light fitting, fire door through to inner hallway, wood and glazed panelled front door to]]></Para>
</feature>
<feature type="Inner Hall">
<Heading><![CDATA[Inner Hall]]></Heading>
<Para><![CDATA[Plain ceiling with pendant light fitting and covings, security telephone, airing cupboard housing gas boiler serving domestic hot water and central heating, telephone point, storage cupboard housing gas and electric meters, wooden panelled doors off to all rooms.]]></Para>
</feature>
<feature type="Lounge (Reception)" width="3.05" length="4.57" units="metre">
<Heading><![CDATA[Lounge (Reception)]]></Heading>
<Para><![CDATA[15' 6" x 10' 7" (4.72m x 3.23m) Window to the side and rear elevation, papered ceiling with pendant light fitting and covings, two double panelled radiators, power points, wall mounted security entry phone, TV aerial point.]]></Para>
</feature>
<feature type="Kitchen" width="3.05" length="3.66" units="metre">
<Heading><![CDATA[Kitchen]]></Heading>
<Para><![CDATA[12' x 10' (3.66m x 3.05m) Double glazed window to the rear elevation, textured ceiling with strip lighting, range of base and wall units in Beech with brushed aluminium handles, co-ordinated working surfaces with inset stainless steel sink with mixer taps over, co-ordinated tiled splashbacks, gas and electric cooker points, large storage cupboard with shelving, power points.]]></Para>
</feature>
<feature type="Entrance Porch">
<Heading><![CDATA[Balcony]]></Heading>
<Para><![CDATA[Views across the communal South facing garden, wrought iron balustrade.]]></Para>
</feature>
<feature type="Bedroom" width="3.35" length="3.96" units="metre">
<Heading><![CDATA[Bedroom One]]></Heading>
<Para><![CDATA[13' 6" x 11' 5" (4.11m x 3.48m) Double glazed windows to the front and side elevations, papered ceiling with pendant light fittings and covings, single panelled radiator, power points, telephone point, security entry phone.]]></Para>
</feature>
<feature type="Bedroom" width="3.05" length="3.35" units="metre">
<Heading><![CDATA[Bedroom Two]]></Heading>
<Para><![CDATA[11' 4" x 10' 1" (3.45m x 3.07m) Double glazed window to the front elevation, plain ceiling with centre light fitting and covings, power points.]]></Para>
</feature>
<feature type="bathroom">
<Heading><![CDATA[Bathroom]]></Heading>
<Para><![CDATA[Obscure double glazed window to the rear elevation, textured ceiling with centre light fitting and extractor fan, suite in white comprising of low level WC, wall mounted wash hand basin and walk in shower housing 'Triton T80' electric shower, co-ordinated tiled splashbacks.]]></Para>
</feature>
</area>
这是我的模板的一个处理该节:
<xsl:for-each select="area">
<li>
<xsl:for-each select="feature">
<li>
<h5>
<xsl:value-of select="Heading"/>
</h5>
<xsl:value-of select="Para"/>
</li>
</xsl:for-each>
</li>
</xsl:for-each>
而这里的输出:
Hall Communal gardens, pathway leading to PVCu double glazed communal front door to Communal Entrance Hall Plain ceiling, centre light fitting, fire door through to inner hallway, wood and glazed panelled front door to Inner Hall Plain ceiling with pendant light fitting and covings, security telephone, airing cupboard housing gas boiler serving domestic hot water and central heating, telephone point, storage cupboard housing gas and electric meters, wooden panelled doors off to all rooms. Lounge (Reception) 15' 6" x 10' 7" (4.72m x 3.23m) Window to the side and rear elevation, papered ceiling with pendant light fitting and covings, two double panelled radiators, power points, wall mounted security entry phone, TV aerial point. Kitchen 12' x 10' (3.66m x 3.05m) Double glazed window to the rear elevation, textured ceiling with strip lighting, range of base and wall units in Beech with brushed aluminium handles, co-ordinated working surfaces with inset stainless steel sink with mixer taps over, co-ordinated tiled splashbacks, gas and electric cooker points, large storage cupboard with shelving, power points. Balcony Views across the communal South facing garden, wrought iron balustrade. Bedroom One 13' 6" x 11' 5" (4.11m x 3.48m) Double glazed windows to the front and side elevations, papered ceiling with pendant light fittings and covings, single panelled radiator, power points, telephone point, security entry phone. Bedroom Two 11' 4" x 10' 1" (3.45m x 3.07m) Double glazed window to the front elevation, plain ceiling with centre light fitting and covings, power points. Bathroom Obscure double glazed window to the rear elevation, textured ceiling with centre light fitting and extractor fan, suite in white comprising of low level WC, wall mounted wash hand basin and walk in shower housing 'Triton T80' electric shower, co-ordinated tiled splashbacks.
仅供参考,这里的整个XSLT:http://pastie.org/private/eq4gjvqoc1amg9ynyf6wzg
编辑:这里是完整的XML:http://pastie.org/private/upu3g9rstw8pilemtaq
其余的都输出良好 - 我从上面的部分缺少什么?
为什么CDATA标签中的所有标签内容?这似乎是矫枉过正。 – scunliffe 2010-03-18 11:00:19
@scunliffe,希望我知道,这不是我的XML - 它是来自客户端系统的提要。 – robotmay 2010-03-18 11:03:51
@代表,谢谢你的建议 - 自从我做XSL以来已经有一段时间了。切换到模板后,我仍然有同样的问题 - 可以用CDATA标签吗? – robotmay 2010-03-18 11:04:09