【发布时间】:2013-12-19 00:32:27
【问题描述】:
我想使用 xslt 对以下 xml 执行两项任务。可以帮忙吗,谢谢。
- 有字符串'null'的地方用空字符串替换
- SSN 以零开头的地方会截断它们
有人可以帮我指明正确的方向吗?
源 XML:
<?xml version='1.0'?>
<!-- This file represents a fragment of a book store inventory database -->
<bookstore>
<book genre="autobiography" publicationdate="1981" ISBN="1-861003-11-0">
<title>The Autobiography of Benjamin Franklin</title>
<author>
<first-name>Benjamin</first-name>
<last-name>Franklin</last-name>
<SSN>0001111</SSN>
<address></address>
</author>
<price>8.99</price>
</book>
<book genre="novel" publicationdate="1967" ISBN="0-201-63361-2">
<title>The Confidence Man</title>
<author>
<first-name>Herman</first-name>
<last-name>Melville</last-name>
<SSN>0001112</SSN>
<address></address>
</author>
<price>11.99</price>
</book>
<book genre="philosophy" publicationdate="1991" ISBN="1-861001-57-6">
<title>The Gorgias</title>
<author>
<first-name>JJ</first-name>
<last-name>MM</last-name>
<SSN>0001113</SSN>
<address>null</address>
</author>
<price>5.99</price>
</book>
</bookstore>
生成的 XML 示例
<bookstore>
<book genre="autobiography" publicationdate="1981" ISBN="1-861003-11-0">
<title>The Autobiography of Benjamin Franklin</title>
<author>
<first-name>Benjamin</first-name>
<last-name>Franklin</last-name>
<SSN>0001112</SSN>
<address></address>
</author>
<price>8.99</price>
</book>
...
</bookstore>
【问题讨论】:
-
你能发布你在 XSLT 上的尝试来解决这个问题吗?另外,截断是什么意思?您样本中的 SSN 仍然有前导零吗?
标签: string xslt replace truncate