0
我將atom xml轉換爲html,但是在xml中我有元素,它顯示html,並在我的結果中將其作爲文本獲取。使用xslt將原子xml轉換爲html - 如何顯示原始HTML
的XML:
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:v3="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xml:base="http://apps.nlm.nih.gov/medlineplus/services/" xml:lang="es">
<title type="text">MedlinePlus Connect</title>
<subtitle type="text">MedlinePlus Connect results for ICD-9-CM 250.33</subtitle>
<author>
<name>U.S. National Library of Medicine</name>
<uri>http://www.nlm.nih.gov</uri>
</author>
<updated type="text">2014-01-29T01:01:09Z</updated>
<category scheme="REDS_MT010001UV" term="MATCHED">
<v3:mainSearchCriteria xmlns:v3="urn:hl7-org:v3" classCode="OBS" moodCode="DEF">
<v3:code xmlns:v3="urn:hl7-org:v3" code="KSUBJ" codeSystem="2.16.840.1.113883.5.4"/>
<v3:value xmlns:v3="urn:hl7-org:v3" code="250.33" codeSystem="2.16.840.1.113883.6.103" displayName="Diabetes mellitus with other coma type 1 uncontrolled"/>
</v3:mainSearchCriteria>
<v3:informationRecipient xmlns:v3="urn:hl7-org:v3" typeCode="IRCP">
<v3:patient xmlns:v3="urn:hl7-org:v3" classCode="PAT"/>
</v3:informationRecipient>
</category>
<id/>
<entry>
<title>Coma</title>
<link href="http://www.nlm.nih.gov/medlineplus/spanish/coma.html" rel="alternate"/>
<id> tag: nlm.nih.gov, 2014-29-01:/medlineplus/spanish/coma.html </id>
<updated>2014-01-29T01:01:09Z</updated>
<summary type="html">
<p class="NLMalsoCalled">Otros nombres: Estado vegetativo</p> <p>El coma es un estado profundo de inconsciencia. Una persona en coma está viva pero incapaz de moverse o responder a su entorno. El estado de coma se puede presentar como una complicación de una enfermedad subyacente o como resultado de lesiones, tales como <a href="http://www.nlm.nih.gov/medlineplus/spanish/traumaticbraininjury.html">traumatismo del cráneo</a>. </p>
<p>El estado de coma rara vez dura más de 2 a 4 semanas. El resultado depende de la causa, la severidad y sitio de la lesión. La gente puede salir de un coma con problemas físicos, intelectuales y psicológicos. Algunas personas pueden permanecer en coma durante años o incluso décadas. Para esa gente, la causa de muerte más común es una infección, como una neumonía. </p>
<p class="NLMattribution"> NIH: Instituto Nacional de Trastornos Neurológicos y Accidentes Cerebrovasculares</p> <p class="NLMrelatedLinks"><ul><li><a href="http://www.nlm.nih.gov/medlineplus/spanish/ency/article/003931.htm">Electroencefalograma</a></li></ul></p>
</summary>
</entry>
</feed>
的XSLT:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:atom="http://www.w3.org/2005/Atom"
version="1.0">
<xsl:output method="html"/>
<xsl:template match="atom:feed">
<html>
<body>
<atom:Feed>
<atom:entries rdf:parseType="Collection">
<xsl:for-each select="atom:entry">
<atom:Entry>
<p>
<xsl:for-each select="atom:title">
<xsl:apply-templates select="." mode="object"/>
</xsl:for-each>
</p>
<p>
<a href="{atom:link/@href}">For More Data</a>
</p>
<p>
<xsl:for-each select="atom:summary">
<xsl:apply-templates select="." mode="html"/>
</xsl:for-each>
</p>
</atom:Entry>
</xsl:for-each>
</atom:entries>
</atom:Feed>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
我wan't這裏面 的HTML將顯示的設計,而不是作爲文本
的問題是在:
<xsl:for-each select="atom:summary">
<xsl:apply-templates select="." mode="html"/>
</xsl:for-each>
將被替換第一個解決方案 - 謝謝! – user3249888