htmlを定義するxmlドキュメントをhtml形式に変換するための非常に単純なxslスタイルシートがあります(理由を聞かないでください、それは私たちがしなければならない方法です...)
<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/>
は変換のロジックを壊し、段落ブロックの前半だけを表示しますSend instant ecards this season <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>
提案?