469,304 Members | 1,888 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,304 developers. It's quick & easy.

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>
</item>


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 3616
Dormilich
8,651 Expert Mod 8TB
try
Expand|Select|Wrap|Line Numbers
  1. // selects all child nodes of <description>
  2. <xsl:copy-of select="description/node()"/>
regards

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
Dormilich
8,651 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
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.