472,127 Members | 1,944 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 software developers and data experts.

xsl:copy-of not copy element name?

I'm using xsl:copy-of because I need to preserve a break tag in my 'description' element (see below). While it does work, it also copies over the <description> tags and puts them in my HTML, which obviously cannot pass W3C validation. Is there any way to copy everything, except for the <description> tags. Or is there a better way? I'm new at this. Thanks...

Sample from .xml file

<item id="MGEBSK">
<title>A Product Title</title>
<description>A Description that is <br/> really important.</description>

Sample from .xsl transformation file

<xsl:copy-of select="description"/>

HTML output (will not validate):

<description>A Description that is <br/> really important.</description>

Desired HTML output:

A Description that is <br/> really important.
Dec 27 '08 #1
4 3740
8,658 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. // selects all child nodes of <description>
  2. <xsl:copy-of select="description/node()"/>

PS please use [code] tags when posting code, it's much better readable this way
Dec 27 '08 #2
Thanks, that worked great!

Any idea why it changed my break tag from <br/> to <br>? Can that be prevented?

Sorry about the [code] tags... I'll make a note of that.
Dec 27 '08 #3
8,658 Expert Mod 8TB
you're probably using html output method.

yes, use xml output method.
Dec 27 '08 #4
Great! Thanks for your help!
Dec 28 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Fezboy | last post: by
8 posts views Thread by arunmt07 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.