Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. XSL copy-of problem!

XSL copy-of problem!

Scheduled Pinned Locked Moved XML / XSL
xmlhtmlregexhelp
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Saul Johnson
    wrote on last edited by
    #1

    Hi All! The advice I got from this forum in regards to using copy-of instead of value-of was excellent, my XSL is working almost perfectly, however there is one small problem. This XSL:

    <xsl:template match="/HTML/BODY//B">
    <B ID="{@ID}" CLASS="{@CLASS}" TITLE="{@TITLE}" STYLE="{@STYLE}" DIR="{@DIR}" LANG="{@LANG}" ONFOCUS="{@ONFOCUS}" ONBLUR="{@ONBLUR}" ONCLICK="{@ONCLICK}" ONDBLCLICK="{@ONDBLCLICK}" ONMOUSEDOWN="{@ONMOUSEDOWN}" ONMOUSEUP="{@ONMOUSEUP}" ONMOUSEOVER="{@ONMOUSEOVER}" ONMOUSEMOVE="{@ONMOUSEMOVE}" ONMOUSEOUT="{@ONMOUSEOUT}" ONKEYPRESS="{@ONKEYPRESS}" ONKEYDOWN="{@ONKEYDOWN}" ONKEYUP="{@ONKEYUP}">
    <xsl:copy-of select="."/>
    </B>
    </xsl:template>

    Produces this output:

    <B ONCLICK="" ONDBLCLICK="" ONMOUSEDOWN="" ONMOUSEUP="" ONMOUSEOVER="" ONMOUSEMOVE="" ONMOUSEOUT="" ONKEYPRESS="" ONKEYDOWN="" ONKEYUP="" ID="" CLASS="" TITLE="" STYLE="" DIR="" LANG="">
    <B>
    Hello World!
    </B></B>

    From this input:

    <B>
    Hello World!

    	</B><BR/>
    

    The B tags are being duplicated due to my use of the "." Xpath syntax, however when I tried "child::*" the text inside all single level tags like:

    <B>Hello World!</B>

    is not displayed at all. Can anybody suggest a soloution to this problem. Thanks! MrWolfy :-D

    F 1 Reply Last reply
    0
    • S Saul Johnson

      Hi All! The advice I got from this forum in regards to using copy-of instead of value-of was excellent, my XSL is working almost perfectly, however there is one small problem. This XSL:

      <xsl:template match="/HTML/BODY//B">
      <B ID="{@ID}" CLASS="{@CLASS}" TITLE="{@TITLE}" STYLE="{@STYLE}" DIR="{@DIR}" LANG="{@LANG}" ONFOCUS="{@ONFOCUS}" ONBLUR="{@ONBLUR}" ONCLICK="{@ONCLICK}" ONDBLCLICK="{@ONDBLCLICK}" ONMOUSEDOWN="{@ONMOUSEDOWN}" ONMOUSEUP="{@ONMOUSEUP}" ONMOUSEOVER="{@ONMOUSEOVER}" ONMOUSEMOVE="{@ONMOUSEMOVE}" ONMOUSEOUT="{@ONMOUSEOUT}" ONKEYPRESS="{@ONKEYPRESS}" ONKEYDOWN="{@ONKEYDOWN}" ONKEYUP="{@ONKEYUP}">
      <xsl:copy-of select="."/>
      </B>
      </xsl:template>

      Produces this output:

      <B ONCLICK="" ONDBLCLICK="" ONMOUSEDOWN="" ONMOUSEUP="" ONMOUSEOVER="" ONMOUSEMOVE="" ONMOUSEOUT="" ONKEYPRESS="" ONKEYDOWN="" ONKEYUP="" ID="" CLASS="" TITLE="" STYLE="" DIR="" LANG="">
      <B>
      Hello World!
      </B></B>

      From this input:

      <B>
      Hello World!

      	</B><BR/>
      

      The B tags are being duplicated due to my use of the "." Xpath syntax, however when I tried "child::*" the text inside all single level tags like:

      <B>Hello World!</B>

      is not displayed at all. Can anybody suggest a soloution to this problem. Thanks! MrWolfy :-D

      F Offline
      F Offline
      Frank Horn
      wrote on last edited by
      #2

      Starting to feel sort of responsible for your project... I'm not sure what the problem is this time though. What's the overall goal of your transformation? Do you want to a) copy all the B and EM tags of some HTML to a self defined XML( or HTML) structure, or b) reproduce a complete HTML with all B and EM tags having a set of attributes which may be missing in the original? When a: what's your target structure? When b: probably a little recursion is called for. http://www.xmlplease.com/xsltidentity might be a good link to start with.

      S 1 Reply Last reply
      0
      • F Frank Horn

        Starting to feel sort of responsible for your project... I'm not sure what the problem is this time though. What's the overall goal of your transformation? Do you want to a) copy all the B and EM tags of some HTML to a self defined XML( or HTML) structure, or b) reproduce a complete HTML with all B and EM tags having a set of attributes which may be missing in the original? When a: what's your target structure? When b: probably a little recursion is called for. http://www.xmlplease.com/xsltidentity might be a good link to start with.

        S Offline
        S Offline
        Saul Johnson
        wrote on last edited by
        #3

        Hi and Thanks! Frank... Your help has been fantastic, clear and precise. If not for your help I'd still be trying to copy nodes with value-of :laugh: . The article you provided solved my problem completely and was exactly what I was looking for. However there is just one more little nagging detail. How would I only output attributes with a value, so that all attributes such as ONCLICK="" will not be displayed? Thanks for all your help! MrWolfy :-D

        F 1 Reply Last reply
        0
        • S Saul Johnson

          Hi and Thanks! Frank... Your help has been fantastic, clear and precise. If not for your help I'd still be trying to copy nodes with value-of :laugh: . The article you provided solved my problem completely and was exactly what I was looking for. However there is just one more little nagging detail. How would I only output attributes with a value, so that all attributes such as ONCLICK="" will not be displayed? Thanks for all your help! MrWolfy :-D

          F Offline
          F Offline
          Frank Horn
          wrote on last edited by
          #4

          In the article they suppress the id attributes with the help of a template which matches them but does nothing. I think you're looking for something like Haven't tried it out though; could be faulty, but I hope you get the idea.

          S 1 Reply Last reply
          0
          • F Frank Horn

            In the article they suppress the id attributes with the help of a template which matches them but does nothing. I think you're looking for something like Haven't tried it out though; could be faulty, but I hope you get the idea.

            S Offline
            S Offline
            Saul Johnson
            wrote on last edited by
            #5

            Hi and Thanks! Thanks Frank! Problem solved, that template was just what I needed to complete my project! Thanks Again! MrWolfy :-D

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups