2012-05-02 46 views

回答

1

此輸入...

<name> 
    <last-name>aaa</last-name> 
    <first-name>bbb</first-name> 
</name> 

這個樣式表...

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
<xsl:output method="xml" indent="yes"/> 

<xsl:template match="/"> 
    <xsl:apply-templates /> 
</xsl:template> 

<xsl:template match="first-name" /> 

<xsl:template match="last-name"> 
    <xsl:comment>for last-name of <xsl:value-of select="." /></xsl:comment> 
    <first-name> 
    <xsl:value-of select="following-sibling::*" />  
    </first-name> 
</xsl:template> 

</xsl:stylesheet> 

... ...產生

<?xml version="1.0" encoding="utf-8"?> 
<!--for last-name of aaa--><first-name>bbb</first-name> 
+0

此外,如果不能依靠第一姓和名的名稱內的相對位置,然後作爲一種替代的,可以使用...

2

使用

<xsl:value-of select="../first-name"/> 
相關問題