|
Subject: Re: [xsl] copy of specific elements From: Norman Gray <norman@xxxxxxxxxxxxxxx> Date: Mon, 18 Aug 2008 16:43:43 +0100 |
I tried with the FAQ and i understood it so as i am witing the code snippet bellow! Here is the sample. In this loop it should turns 2 times because there are 2 sections and than displays the author names in: author[1] and author[2] (this is the array: [@type='author'][position()])
% cat hh.xml
<document>
<elements>
<element type="author">Author number 1</element>
<element type="author">Author number 2</element>
<element type="section">section 1</element>
<element type="section">section 2</element>
</elements>
</document>
% cat hh.xslt
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<body>
<xsl:apply-templates
select='document/elements/element[@type="section"]'/>
</body>
</html>
</xsl:template>
<xsl:template match='element'>
<p>Element: <xsl:apply-templates/></p>
</xsl:template>
</xsl:stylesheet>
% xsltproc hh.xslt hh.xml
<html><body>
<p>Element: section 1</p>
<p>Element: section 2</p>
</body></html>
%
-- Norman Gray : http://nxg.me.uk Physics and Astronomy, University of Leicester
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] copy of specific elements, Florent Georges | Thread | Re: [xsl] copy of specific elements, Colin Adams |
| Re: [xsl] copy of specific elements, Florent Georges | Date | Re: [xsl] copy of specific elements, Colin Adams |
| Month |