Why the value of the tag isn’t outputted

I am new in XSLT and I don’t understand the basic idea of templates.
I am doing an experiment to see if the output is what I expect. Unfortunately not. This are the files in transformation:

The XML:

<?xml version="1.0" encoding="UTF-8"?>

<catalog>
    <cd>
        <title>Empire</title>
        <artist>Bob Dylan</artist>
        <continent>America</continent>
        <country>USA</country>
        <company>Columbia</company>
        <price>10.90</price>
        <year>1985</year>
    </cd>
    <cd>
        <title>Hide your heart</title>
        <artist>Bonnie Tyler</artist>
        <country>Bulgaria</country>
        <company>CBS Records</company>
        <price>9.90</price>
        <year>1988</year>
    </cd>
</catalog>

And this is the XSLT:

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="text"/>
    <xsl:template match="/">
        <xsl:apply-templates select="//continent"/>
    </xsl:template>
    <xsl:template match="//continent">
        <xsl:value-of select="continent"/>
    </xsl:template>
</xsl:stylesheet>

The output is empty sheet. I expect the value of the continent tag to be printed, namely America. Please shed some light on this matter. Thank tou.


Source: xml

Leave a Reply