我有一本书的xml文件,它包含多个section标签和多个article-title标签。我需要获得每个article-tag值的值以及相应的section title。
我的XML看起来像这样:
<root>
<article>
<series-title content-type="section-heading">Reviews</series-title>
</article>
<title>
<article-title>Post-epilepsy stroke: A review</article-title>
</title>
</root>
<root>
<article>
<series-title content-type="section-heading">Original Research</series-title>
</article>
<title>
<article-title>Prognostic implications of the Ankle Brachial Index</article-title>
</title>
</root>
<root>
<article>
<series-title content-type="section-heading">Editorial</series-title>
</article>
<title>
<article-title>What is NODDI and what is its role</article-title>
</title>
</root>
<root>
<article>
<series-title content-type="section-heading">Reviews</series-title>
</article>
<title>
<article-title>An update on the comorbidity of ADHD and ASD</article-title>
</title>
</root>
<root>
<article>
<series-title content-type="section-heading">Editorial</series-title>
</article>
<title>
<article-title>Occipital nerve stimulation and beyond</article-title>
</title>
</root>
我的输出应该是:
<h2>Reviews</h2>
<h3>Post-epilepsy stroke: A review</h3>
<h2>Original Research</h2>
<h3>Prognostic implications of the Ankle Brachial Index</h3>
<h2>Editorial</h2>
<h3>What is NODDI and what is its role</h3>
<h2>Reviews</h2>
<h3>An update on the comorbidity of ADHD and ASD</h3>
<h2>Editorial</h2>
<h3>Occipital nerve stimulation and beyond</h3>
事情是,我只使用一个模板匹配条件。
任何人都可以提供帮助:
答案 0 :(得分:0)
这是你想要的吗?
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" omit-xml-declaration="yes" version="1.0" encoding="utf-8" indent="yes"/>
<xsl:template match="/this/root">
<h2>
<xsl:value-of select="article/series-title"/>
</h2>
<h3>
<xsl:value-of select="title/article-title"/>
</h3>
</xsl:template>
</xsl:stylesheet>
在此解决方案中,所有根标记都应位于“this”标记中。