我只是在这个基本的XML课程中,我正忙着弄清楚我在做什么。我一直试图弄清楚如何使用XSLT显示XML文档看起来像这样:
https://i.stack.imgur.com/mdedM.png
我的XML:
<systemMetadata>
<title>Koha</title>
<creator>by Katipo Communications</creator>
<subject>library community, research, information services,public
libraries, bibliographic management, distributed library systems, metadata,
resource discovery, conferences,lectures, workshops</subject>
<description>Koha was one of the the first open-source Integrated Library Systems
It is used and maintained by the worldwide library community.</description>
<date>2000</date>
<type>ILS</type>
<rights>Open-source</rights>
<identifier>http://www.koha.org/</identifier>
</systemMetadata>
<aboutRecord>
<recordCreator>Created by Matthew Weidemann</recordCreator>
<creationDate>on 2018-05-03</creationDate>
</aboutRecord>
非常感谢您的任何想法。
答案 0 :(得分:0)
为每个条目添加xml声明和游戏,游戏标签。
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="catalog.xsl"?>
<games>
<game>
<systemMetadata>
<title>Koha</title>...
</aboutRecord>
</game>
</games>
然后像这样创建目录xsl表:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<xsl:for-each select="games/game">
<h1><xsl:value-of select="systemMetadata/title"/></h1>
<h3>by <xsl:value-of select="systemMetadata/creator"/></h3>
<h3><xsl:value-of select="systemMetadata/subject"/></h3>
<p>
<xsl:value-of select="systemMetadata/title"/> <xsl:value-of select="systemMetadata/date"/>
<xsl:value-of select="systemMetadata/type"/> <xsl:value-of select="systemMetadata/description"/>
</p>
<h2><xsl:value-of select="systemMetadata/rights"/></h2>
<br/>
<h2><i>Record created by <xsl:value-of select="aboutRecord/recordCreator"/> on
<xsl:value-of select="aboutRecord/creationDate"/></i></h2>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>