(Should Be) Simple XSLT Query Problem
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 1
- Joined: Fri Sep 23, 2005 8:30 am
(Should Be) Simple XSLT Query Problem
Hey folks,
I'm working on an XSLT file here and running into a bit of a problem. Take the following XML source:
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.
I'm working on an XSLT file here and running into a bit of a problem. Take the following XML source:
Code: Select all
<note>
<title>Hello</title>
<body>This is the body of the text <div>including HTML tags</div>.</body>
</note>
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: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Hi,
"xsl:copy-of" is the way to go.
The following sample stylesheet would accomplish the intended result:
You can see the differences between copy and copy-of here:
http://www.w3schools.com/xsl/el_copy-of.asp
http://www.w3schools.com/xsl/el_copy.asp
Regards, Radu.
"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/*"/>
</xsl:template>
</xsl:stylesheet>
http://www.w3schools.com/xsl/el_copy-of.asp
http://www.w3schools.com/xsl/el_copy.asp
Regards, Radu.
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service