我已经使用了xsl:何时显示我的细节。我需要展示的细节是本书的标题。现在我想用一个变化显示标题。如果标题是'Cpp .....',我需要用'C++ ....'替换它,然后在浏览器中显示该书名。 这是为所有书名中包含Cpp的图书合并的。使用xsl:当
我编辑了我的问题。 你能帮我吗?
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" exclude-result-prefixes="rdf rss"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:rss="http://my.netscape.com/rdf/simple/0.9/"
xmlns:kb="http://protege.stanford.edu/kb#">
<xsl:output method="html" indent="yes" />
<xsl:template match="wt:sparql/wt:results/wt:result"
xmlns:wt="http://www.w3.org/2005/sparql-results#">
<script type="text/javascript"></script>
<h3>
<xsl:choose>
<xsl:when test="wt:binding[@name='count']/wt:literal <= 5">
<a style="color:red">
<xsl:attribute name="onclick">
prepareEditValue('<xsl:value-of select="wt:binding[@name='x']/wt:uri"></xsl:value-of>', false);
</xsl:attribute>
<xsl:value-of select="wt:binding[@name='title']/wt:literal" />
</a>
</xsl:when>
<xsl:when test="wt:binding[@name='count']/wt:literal <= 50">
<a style="color:blue">
<xsl:attribute name="onclick">
prepareEditValue('<xsl:value-of select="wt:binding[@name='x']/wt:uri"></xsl:value-of>', false);
</xsl:attribute>
<xsl:value-of select="wt:binding[@name='title']/wt:literal" />
</a>
</xsl:when>
<xsl:otherwise>
<a>
<xsl:attribute name="onclick">
prepareEditValue('<xsl:value-of select="wt:binding[@name='x']/wt:uri"></xsl:value-of>', false);
</xsl:attribute>
<xsl:value-of select="wt:binding[@name='title']/wt:literal" />
</a>
</xsl:otherwise>
</xsl:choose>
</h3>
<div>
<xsl:value-of select="wt:binding[@name='description']/wt:literal" /> Price:
<xsl:value-of select="wt:binding[@name='price']/wt:literal" />
<xsl:value-of select="wt:binding[@name='currency']/wt:literal" />
<div style="float:right;">
<input type="button" value="Edit">
<xsl:attribute name="onclick">
prepareEditValue('<xsl:value-of select="wt:binding[@name='x']/wt:uri"></xsl:value-of>', true);
</xsl:attribute>
</input>
<input type="button" value="Delete">
<xsl:attribute name="onclick">
deleteBookDialog('<xsl:value-of select="wt:binding[@name='x']/wt:uri"></xsl:value-of>');
</xsl:attribute>
</input>
</div>
</div>
</xsl:template>
</xsl:stylesheet>
它具有数据RDF文件是
欢迎到C YY $
的.cpp的Primer Plus 斯蒂芬·普拉塔 â, ¬ 36.94
<rdf:Description rdf:about="http://protege.stanford.edu/kb#Linux Programming Bible">
<kb:Title>Linux Programming Bible</kb:Title>
<kb:Author>John Goerzen</kb:Author>
<kb:Currency>$</kb:Currency>
<kb:Price>77</kb:Price>
<kb:Count>34</kb:Count>
</rdf:Description>
<rdf:Description rdf:about="http://protege.stanford.edu/kb#CSharp-The Basics">
<kb:Title>CSharp-The Basics</kb:Title>
<kb:Author>Vijay Mukhi</kb:Author>
<kb:Currency>€</kb:Currency>
<kb:Price>56</kb:Price>
<kb:Count>6</kb:Count>
</rdf:Description>
<rdf:Description rdf:about="http://protege.stanford.edu/kb#Cpp Primer Answer Book">
<kb:Title>Cpp Primer Answer Book</kb:Title>
<kb:Author>Clovis L.Tondo</kb:Author>
<kb:Currency>$</kb:Currency>
<kb:Price>24.40</kb:Price>
<kb:Count>100</kb:Count>
</rdf:Description>
<rdf:Description rdf:about="http://protege.stanford.edu/kb#Ajax for Dummies">
<kb:Title>Ajax for Dummies</kb:Title>
<kb:Author>Steve Holzner</kb:Author>
<kb:Currency>$</kb:Currency>
<kb:Price>21.89</kb:Price>
<kb:Count>3</kb:Count>
</rdf:Description>
<rdf:Description rdf:about="http://protege.stanford.edu/kb#Beginning Programming with
Cpp For Dummies">
<kb:Title>Beginning Programming with Cpp For Dummies</kb:Title>
<kb:Author>Stephen R.Davis</kb:Author>
<kb:Currency>$</kb:Currency>
<kb:Price>19.69</kb:Price>
<kb:Count>99</kb:Count>
</rdf:Description>
<rdf:Description rdf:about="http://protege.stanford.edu/kb#Programming in ANSI C">
<kb:Title>Programming in ANSI C</kb:Title>
<kb:Author>Stephen G.Kochan</kb:Author>
<kb:Currency>$</kb:Currency>
<kb:Price>99</kb:Price>
<kb:Count>9</kb:Count>
</rdf:Description>
<rdf:Description rdf:about="http://protege.stanford.edu/kb#Introduction to Programming
Using Java">
<kb:Title>Introduction to Programming Using Java</kb:Title>
<kb:Author>David J.Eck</kb:Author>
<kb:Currency>$</kb:Currency>
<kb:Price>89</kb:Price>
<kb:Count>23</kb:Count>
</rdf:Description>
<rdf:Description rdf:about="http://protege.stanford.edu/kb#Crafting a Compiler with C">
<kb:Title>Crafting a Compiler with C</kb:Title>
<kb:Author>Charles N.Fischer</kb:Author>
<kb:Currency>$</kb:Currency>
<kb:Price>95</kb:Price>
<kb:Count>8</kb:Count>
</rdf:Description>
<rdf:Description rdf:about="http://protege.stanford.edu/kb#Sams Teach Yourself C Sharp
in 24 Hours">
<kb:Title>Sams Teach Yourself C Sharp in 24 Hours</kb:Title>
<kb:Author>Sams</kb:Author>
<kb:Currency>$</kb:Currency>
<kb:Price>89</kb:Price>
<kb:Count>9</kb:Count>
</rdf:Description>
<rdf:Description rdf:about="http://protege.stanford.edu/kb#Compiler Constructions">
<kb:Title>Compiler Constructions</kb:Title>
<kb:Author>Jeremy Perk</kb:Author>
<kb:Currency>$</kb:Currency>
<kb:Price>88</kb:Price>
<kb:Count>9</kb:Count>
</rdf:Description>
<rdf:Description rdf:about="http://protege.stanford.edu/kb#Real Time Concepts for
Embedded Systems">
<kb:Title>Real Time Concepts for Embedded Systems</kb:Title>
<kb:Author>Qing Li</kb:Author>
<kb:Currency>€</kb:Currency>
<kb:Price>109</kb:Price>
<kb:Count>88</kb:Count>
</rdf:Description>
<rdf:Description rdf:about="http://protege.stanford.edu/kb#Introduction to Algorithms">
<kb:Title>Introduction to Algorithms</kb:Title>
<kb:Author>Thomas Cormen</kb:Author>
<kb:Currency>$</kb:Currency>
<kb:Price>33</kb:Price>
<kb:Count>6</kb:Count>
</rdf:Description>
<rdf:Description rdf:about="http://protege.stanford.edu/kb#Begineer to Cpp ">
<kb:Count>7</kb:Count>
<kb:Price>77</kb:Price>
<kb:Currency>$</kb:Currency>
<kb:Author>Harry</kb:Author>
<kb:Title>Begineer to Cpp </kb:Title>
</rdf:Description>
</rdf:RDF>
阿奇纳。
你能举一个你已经有的代码的例子吗? – 2011-04-05 09:54:50
这是一个糟糕的问题的另一个例子。 XML文档在哪里?你忘了它。 – 2011-04-05 13:04:13
它看起来像你想用另一个替换一个子串。有很多[回答](http://www.google.com/search?q=site%3Astackoverflow.com+xslt+replace)在这里SO – 2011-04-05 13:28:55