我有一个非常简单的XSL样式表,用于将定义我们的HTML的XML文档转换为HTML格式(请不要问为什么,这只是我们必须这样做的方式...)
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="HtmlElement">
<xsl:element name="{ElementType}">
<xsl:apply-templates select="Attributes"/>
<xsl:value-of select="Text"/>
<xsl:apply-templates select="HtmlElement"/>
</xsl:element>
</xsl:template>
<xsl:template match="Attributes">
<xsl:apply-templates select="Attribute"/>
</xsl:template>
<xsl:template match="Attribute">
<xsl:attribute name="{Name}">
<xsl:value-of select="Value"/>
</xsl:attribute>
</xsl:template>
当我遇到需要转化的HTML代码时,问题出现了:
<p>
Send instant ecards this season <br/> and all year with our ecards!
</p>
中间的<br/>
打破了转化逻辑,使我只得到段落块的前半部分:发送即时电子贺卡本季<br></br>
。试图进行转换的XML如下:
<HtmlElement>
<ElementType>p</ElementType>
<Text>Send instant ecards this season </Text>
<HtmlElement>
<ElementType>br</ElementType>
</HtmlElement>
<Text> and all year with our ecards!</Text>
</HtmlElement>
建议?
<i>...</i>
标签吗?我不确定我理解你的回答的方向。 - CallMeTroggy