0
我有一个XML文件,我想使用XSLT进行转换。这个想法是将每个<paragraph/>
标签之前的所有内容放入<p></p>
标签。无法使用XPath访问文本块
XML文件:
<section>
Hello everyone, I'm
<bold>Hackmania</bold>
<bold>15</bold>
<line/>
I am looking for an
<highlight>answer</highlight>
<paragraph/>
Here is an other
<bold>paragraph</bold>
<highlight>with the same tags</highlight>
<paragraph/>
</section>
通缉转换XML:
<section>
<p>
Hello everyone, I'm
<bold>Hackmania</bold>
<bold>15</bold>
<line/>
I am looking for an
<highlight>answer</highlight>
</p>
<p>
HHere is an other
<bold>paragraph</bold>
<highlight>with the same tags</highlight>
</p>
</section>
这里是我的XSL文件:提前
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet>
<xsl:template match="/">
<section>
<xsl:apply-templates/>
</section>
</xsl:template>
<xsl:template match="paragraph">
<xsl:for-each select=".">
<p>
<xsl:apply-templates select="/*/*[preceding-sibling::paragraph]"/>
</p>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
感谢您帮助。
感谢您的帮助@ michael.hor257k。 – Hackmania15