2012-09-20 90 views
0

我期待在結果中返回特定XML標記<para>的內容,而不在其子標記<bridgehead><sliceXML>中。我正在測試以下使用http://xslttest.appspot.com/任何幫助一如既往,非常感謝。XSLT - 從結果中刪除子標記

我的XML

<para> 
    <bridgehead>Galaxy Zoo</bridgehead> 
     <sliceXML>Galaxy</sliceXML> 
     The human eye is far better at identifying characteristics of galaxies 
     than any computer. So Galaxy Zoo has called for everyday citizens to 
     help in a massive identification project. Well over a hundred thousand 
     people have helped identify newly discovered galaxies. Now you can, too. 
</para> 

我的XSLT

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sparql-results="http://www.w3.org/2005/sparql-results#" version="1.0"> 

<xsl:template match="/"> 
    <xsl:call-template name="results"/> 
    <xsl:message>FROM simpleHMHTransform XSLT8</xsl:message> 
</xsl:template> 
<xsl:template name="results"> 

<xsl:for-each select="//para"> 
     <xsl:call-template name="para"/> 
    </xsl:for-each> 
</xsl:template> 

<xsl:template name="para"> 
    <div id="para"> 
     <xsl:value-of select="."/> 
    </div> 
</xsl:template> 

</xsl:stylesheet> 

我現在的結果

<?xml version="1.0" encoding="UTF-8"?><div xmlns:sparql- results="http://www.w3.org/2005/sparql-results#" id="para"> 
    Galaxy Zoo 
     Galaxy 
     The human eye is far better at identifying characteristics of galaxies 
     than any computer. So Galaxy Zoo has called for everyday citizens to 
     help in a massive identification project. Well over a hundred thousand 
     people have helped identify newly discovered galaxies. Now you can, too. 
</div> 

所需結果

<?xml version="1.0" encoding="UTF-8"?><div xmlns:sparql-results="http://www.w3.org/2005/sparql-results#" id="para"> 
     The human eye is far better at identifying characteristics of galaxies 
     than any computer. So Galaxy Zoo has called for everyday citizens to 
     help in a massive identification project. Well over a hundred thousand 
     people have helped identify newly discovered galaxies. Now you can, too. 
</div> 

回答

0
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sparql-results="http://www.w3.org/2005/sparql-results#" version="1.0"> 

<xsl:template match="para"> 
    <div id="para"><xsl:copy-of select="text()"/></div> 
</xsl:template> 

</xsl:stylesheet>