我是XML和XSLT的新手。我正在尝试使用for-each打印元素下的所有变量,但只显示1。如何打印所有使用for-each?
XSL:
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<body>
<xsl:for-each select="/PubmedArticle/MedlineCitation/Article/Abstract">
<h4>Abstract:</h4>
<ul>
<li><xsl:value-of select="AbstractText"/></li>
</ul>
<h4>Copy Right Information</h4>
<ul>
<li><xsl:value-of select="CopyrightInformation"/></li>
</ul>
</xsl:for-each>
</body>
</html>
XML:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="article11.xsl"?>
<PubmedArticle>
<MedlineCitation Owner="NLM" Status="In-Data-Review">
<Article PubModel="Print-Electronic">
<Abstract>
<AbstractText Label="BACKGROUND" NlmCategory="BACKGROUND">Pituitary apoplexy is a rare clinical emergency which results from hemorrhage or infarction in the pituitary gland.</AbstractText>
<AbstractText Label="PATIENT" NlmCategory="METHODS">We present a 14-year-old girl with pituitary apoplexy and review the literature.</AbstractText>
<AbstractText Label="CONCLUSIONS" NlmCategory="CONCLUSIONS">Although pituitary apoplexy is rare in pediatric patients, prompt evaluation including detailed ophthalmic examination, biochemical evaluation, endocrine workup, and image study are very important.</AbstractText>
<CopyrightInformation>Copyright c 2014 Elsevier Inc. All rights reserved.</CopyrightInformation>
</Abstract>
</Article>
</MedlineCitation>
</PubmedArticle>
答案 0 :(得分:0)
变化
<h4>Abstract:</h4>
<ul>
<li><xsl:value-of select="AbstractText"/></li>
</ul>
到
<h4>Abstract:</h4>
<ul>
<xsl:for-each select="AbstractText">
<li><xsl:value-of select="."/></li>
</xsl:for-each>
</ul>