Reputation: 3081
Document:
<?xml version="1.0" encoding="utf-8"?>
<page>
<tab dim="30">
<column>
</column>
<column>
</column>
</tab>
<tab dim="70">
</tab>
</page>
stylesheet:
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:text disable-output-escaping='yes'><!DOCTYPE html></xsl:text>
<html>
<head>
</head>
<body>
<xsl:for-each select="tab">
<div class="tab">tab</div>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
producing this
<!DOCTYPE html><html><head></head><body></body></html>
I want this
<!DOCTYPE html><html><head></head><body><div class="tab">tab</div><div class="tab">tab</div></body></html>
Upvotes: 2
Views: 244
Reputation: 13163
I would use template matching for <tab> – and for <page>
<xsl:template match="page">
<xsl:text disable-output-escaping='yes'><!DOCTYPE html></xsl:text>
<html>
<head></head>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="tab">
<div class="tab">tab</div>
</xsl:template>
Upvotes: 0
Reputation: 20873
You need
<xsl:for-each select="page/tab">
instead of
<xsl:for-each select="tab">
Either that, or you could do
<xsl:template match="/page">
instead of
<xsl:template match="/">
Upvotes: 1