2017-10-15 72 views
-1

這是XML代碼:更改姓名使用XSLT

<?xml version="1.0"?> 
<!-- Yavuz --> 
<?xml-stylesheet type="text/xsl" href="books.xsl"?> 
<catalog> 
     <book id="bk101"> 
     <author>Gambardella, Matthew</author> 
     <title>XML Developer's Guide</title> 
     <genre>Computer</genre> 
     <price>44.95</price> 
     <publish_date>2000-10-01</publish_date> 
     </book> 
</catalog> 

我想筆者這個樣子。

最新的書是2000年10月1日發佈的XML開發人員指南,本書的作者是Matthew Gambardella。

回答

0

嘗試下面的XSLT以獲取輸出文本。

<xsl:template match="book"> 
    <xsl:text>The newest book is </xsl:text> 
    <xsl:value-of select="title" /> 
    <xsl:text> published on </xsl:text> 
    <xsl:value-of select="publish_date" /> 
    <xsl:text> and the author of this book is </xsl:text> 
    <xsl:value-of select="concat(normalize-space(substring-after(author, ',')),' ', substring-before(author, ','))" /> 
</xsl:template>