[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Copy a node inside a template but exclude a deeply nested child


Subject: [xsl] Copy a node inside a template but exclude a deeply nested child
From: "Adam Retter" <adam.retter@xxxxxxxxxxxx>
Date: Mon, 4 Sep 2006 12:46:08 +0100

Hi Chaps,

I have an existing xslt and in one of the templates it makes a copy of a
node from the xml document, I now have the need to exclude a deeply
nested child from that copy, but I cant figure out how, I may need to
break up my template into further templates but im not sure how
exactly...

My simplified XML document looks like this -

<root>
    <categories_flat/>
    <pages/>
    <page>

        <!-- cut: lots of nodes -->

        <content>
            <main>
                <show>
                    <h1>General Enquiries</h1>
                    <p>This form is for general enquiries only.</p>
                    <br/>
                    <div id="xform">
                        <xforms:model>
                            <!-- cut: xform model -->
                        </xforms:model>
                    </div>
                </show>
            </main>
        </content>

    </page>
</root>


My current my XSLT document is below.
Now at the moment it deep copies the nodes inside the show node, but I
would like to exclude the xforms:model node, I cant really reference
this node by path as its nesting may be different each time, although it
will always be somewhere inside a child of the show node, although its
depth may vary. So, how can I acheieve this?


<xsl:template match="/page">
    <html>
        <head>
            <title>some page title</title>
        </head>
        <body>

            <!-- cut: lots of node parsing and xhtml generation -->

            <xsl:if test="content/main/show">
                <div class="textpage"><!-- text page -->
                    <xsl:copy-of select="content/main/show/node()"/>
                </div>
            </xsl:if>

        </body>
    </html>
</xsl:template>


Thanks Adam



Adam Retter

Devon Portal Principal Developer
Devon Portal Project, e-Partnership
Ext: 3683
DDI: 01392 383683
e: adam.retter@xxxxxxxxxxxx

http://www.devonline.gov.uk


Current Thread
Keywords