我无法将我的XSLT / XSL样式表导入到XML中,但这只是一直不起作用。我在w3schools上编写了代码,并在那里工作,就像它在内部为我完成的工作一样,但是由于将它们放入两个单独的文档中,我无法将它们链接起来。
多种导入方式,多个href,移动其位置。
XML
<?xml version="1.0" encoding="UTF-8"?>
<href="cuisinexsl.xsl"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform%22%3E"
xsl:stylesheetversion="1.0">
<cuisines>
<greek>
<name>Food from Zeus</name>
<address>96 Almighty Road</address>
<phone>02 2321 5592</phone>
<deliveryfee>Delivery fee is $7</deliveryfee>
<URL>https://zeusfoods.com.au/</URL>
<takeaway>Yes</takeaway>
<dinein>Yes</dinein>
<openhours>9-5 Mon-Sat,Sunday Closed</openhours>
<description>Food created by us, that even the almighty would die
for.</description>
</greek>
<greek>
<name>Gone Greek</name>
<address>25 Meldo Road</address>
<phone>02 9597 5062</phone>
<deliveryfee>Delivery fee is $10</deliveryfee>
<URL>https://www.meetthegreek.com.au/</URL>
<takeaway>Yes</takeaway>
<dinein>Yes</dinein>
<openhours>10-7 Tue-Sun,Closed Mondays</openhours>
<description>Classic Dishes, Great Greek food and salads.
</description>
</greek>
<greek>
<name>The 300</name>
<address>16 Madness Road</address>
<phone>02 4251 6182</phone>
<deliveryfee>Delivery's not available</deliveryfee>
<URL>https://thethreehundred.com.au/</URL>
<takeaway>No</takeaway>
<dinein>Yes</dinein>
<openhours>11-9 Mon-Sun</openhours>
<description>Enjoy our renowned dining experience.</description>
</greek>
</cuisines>
xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<body>
<h1>Greek Cuisine Restaurants</h1>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="greek">
<xsl:for-each select="cuisines/greek">
<xsl:sort select="name"/>
</xsl:for-each>
<p>
<xsl:apply-templates select="name"/>
<xsl:apply-templates select="address"/>
<xsl:apply-templates select="phone"/>
<xsl:apply-templates select="deliveryfee"/>
<xsl:apply-templates select="URL"/>
<xsl:apply-templates select="takeaway"/>
<xsl:apply-templates select="dinein"/>
<xsl:apply-templates select="openhours"/>
<xsl:apply-templates select="description"/>
</p>
</xsl:template>
<xsl:template match="name">
Name: <span style="">
<xsl:value-of select="."/></span>
<br />
</xsl:template>
<xsl:template match="address">
Artist: <span style="">
<xsl:value-of select="."/></span>
<br />
</xsl:template>
</xsl:stylesheet>
让XSL导入XML并显示其意图,而不是大麻烦。链接此模板时,我删除了大多数模板匹配项以节省空间。