How can I extract all the titles from a particular XML file?
I have the following XML stream:
<?xml version="1.0"?>
<zs:searchRetrieveResponse xmlns:zs="http://www.loc.gov/zing/srw/">
<zs:version>1.1</zs:version>
<zs:numberOfRecords>1344</zs:numberOfRecords>
<zs:records>
<zs:record>
<zs:recordSchema>info:srw/schema/1/dc-v1.1</
zs:recordSchema>
<zs:recordPacking>xml</zs:recordPacking>
<zs:recordData>
<srw_dc:dc xmlns:srw_dc="info:srw/schema/1/dc-
schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://purl.org/dc/elements/1.1/" xsi:schemaLocation="info:srw/
schema/1/dc-schema http://www.loc.gov/z3950/agency/zing/srw/dc-
schema.xsd">
<title>A ceremony unveiling the portrai.../title>
<creator>United States. Congress. House.
Committee on Resources.</creator>
<subject>Hansen, James V.</subject>
<subject>Legislators</subject>
</srw_dc:dc>
</zs:recordData>
<zs:recordPosition>2</zs:recordPosition>
</zs:record>
</zs:records>
</zs:searchRetrieveResponse>
I also have this XSL:
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:zs="http://www.loc.gov/zing/srw/"
xmlns:srw_dc="info:srw/schema/1/dc-schema"
version='1.0'>
<xsl:output method='html' omit-xml-declaration='yes' />
<xsl:template match='/'>
<p>Here is a list of records from your search:</p>
<ul>
<xsl:for-each select='//srw_dc:dc'>
<li><xsl:value-of select='title' /></li>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
</xsl:for-each>
</ul>
</xsl:template>
</xsl:stylesheet>
Unfortunately, my selecting of the title does not output anything.
What am I doing wrong? Do I need to preface my title element with a
namespace?
--
Eric Lease Morgan
Head, Digital Access and Information Architecture Department
University Libraries of Notre Dame
(574) 631-8604
|