我有興趣更改XML文件以創建帶有表格的html文件。刪除然後將文本添加到xml字段
這裏原始的XML
<?xml version="1.0" encoding="UTF-8"?>
<library xmlns:dc="http://purl.org/dc/elements/1.1/">
<item>
<title>Electronic Payments for State Taxes and Fees</title>
<link>http://mesharpe.metapress.com/link.asp?id=T861142L5675QQW2</link>
<dc:identifier>DOI 10.2753/PMR1530-9576360406</dc:identifier>
</item>
<item>
<title>The Determinants of Union Attitudes among Community College Professors</title>
<link>http://baywood.metapress.com/link.asp?id=R216M2L6263165N1</link>
<dc:identifier>DOI 10.2190/CN.32.4.a</dc:identifier>
</item>
<item>
<title>Using Dedicated Nurses to Improve Core Measures Compliance</title>
<link>http://rss.sciencedirect.com/...link>
<dc:identifier>http://rss.sciencedirect.com/...</dc:identifier>
</item>
</library>
我要創建這樣的一個樣本:
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns:h="http://purl.org/rss/1.0/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:prism="http://prismstandard.org/namespaces/1.2/basic/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:mn="http://usefulinc.com/rss/manifest/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
<body>
<h1 align="center">Something</h1>
<table border="1" width="700" align="center">
<tr bgcolor="#CC661F">
<th>Title</th>
<th>Identifier</th>
</tr>
<tr>
<td>Electronic Payments for State Taxes and Fees</td>
<td>http://dx.doi.org/10.2753/PMR1530-9576360406</td>
</tr>
<tr>
<td>The Determinants of Union Attitudes among Community College Professors</td>
<td>http://dx.doi.org/10.2190/CN.32.4.a</td>
</tr>
<tr>
<td>Using Dedicated Nurses to Improve Core Measures Compliance</td>
<td>http://rss.sciencedirect.com/...</td>
</tr>
</table>
</body>
</html>
所以對於外地DC:標識符有任何鏈接或DOI隨後有一個數字。對於每個擁有DOI的人,我想刪除DOI和空間,然後在前面添加http://dx.doi.org/,因此在表中創建一個鏈接。
有關如何完成此任務的任何提示?謝謝!
編輯:我從來沒有使用XSLT文件工作前,我只有一個準系統模板:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:h="http://purl.org/rss/1.0/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:prism="http://prismstandard.org/namespaces/1.2/basic/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:mn="http://usefulinc.com/rss/manifest/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<html>
<body>
<h1 align="center">Title</h1>
<table border="1" width="700" align="center">
<tr bgcolor="#CC661F">
<th>Title</th>
<th>Link</th>
</tr>
<xsl:for-each select="//h:item">
<tr>
<td>
<xsl:value-of select="h:title" disable-output-escaping="yes"/>
</td>
<td>
<xsl:value-of select="dc:identifier"/>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
嗨,歡迎來到stackoverflow。您是否已經嘗試編寫[xslt模板](https://developer.mozilla.org/en-US/docs/XSLT),並且可以與我們分享? – rene
使用子字符串函數。 – OldProgrammer
我把我的xslt模板放在那裏。我懷疑這有幫助。我會看看子字符串函數... – user3203919