(Should Be) Simple XSLT Query Problem

Here should go questions about transforming XML with XSLT and FOP.
Posts: 1

(Should Be) Simple XSLT Query Problem

Fri Sep 23, 2005 8:39 am

Hey folks,

I'm working on an XSLT file here and running into a bit of a problem. Take the following XML source:

Code: Select all

  <body>This is the body of the text <div>including HTML tags</div>.</body>

How would I go about selecting the contents of <body> (including _all_ nodes underneath it) into a variable.

As far as I've gotten is (from 'body' scope):
<xsl:variable name="varBody" select="descendant-or-self::*" />

That gives me all the contents (including children & grandchildren), but I'm missing the nodes/tags.

What I want:
"This is the body of the text <div>including HTML tags</div>"

What I'm getting:
"This is the body of the text including HTML tags"

How should I be referencing it? I heard mention of 'xsl:copy-of' but couldn't produce anything different from above when trying it. Seems like it should be simple enough, but I'm stuck.

Thanks in advance.
Posts: 5994

Fri Sep 23, 2005 10:13 am


"xsl:copy-of" is the way to go.
The following sample stylesheet would accomplish the intended result:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="/">
        <xsl:copy-of select="note/body/*"/>

You can see the differences between copy and copy-of here:

Regards, Radu.

Return to “XSLT and FOP”

Who is online

Users browsing this forum: No registered users and 0 guests