xsl:copy-of not copy element name?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shifflav
    New Member
    • Dec 2008
    • 10

    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="descrip tion"/>


    HTML output (will not validate):

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

    Desired HTML output:


    A Description that is <br/> really important.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    try
    Code:
    // selects all child nodes of <description>
    <xsl:copy-of select="description/node()"/>
    regards

    PS please use [code] tags when posting code, it's much better readable this way

    Comment

    • shifflav
      New Member
      • Dec 2008
      • 10

      #3
      tags changed

      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.

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        you're probably using html output method.

        yes, use xml output method.

        Comment

        • shifflav
          New Member
          • Dec 2008
          • 10

          #5
          Great! Thanks for your help!

          Comment

          Working...