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 Nesting Problem!

XSL Nesting Problem!

Scheduled Pinned Locked Moved XML / XSL
xmlhtmlwpfregexhelp
6 Posts 3 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! I need to emulate the HTML <B> and <EM> tags complete with all attributes and event handlers for a little project of mine and everything works fine when these elements are seperate, Here's my xsl stylesheet:

    <?xml version="1.0"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

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

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

    </xsl:stylesheet>

    Now this works fine when <B> and <EM> are seperate, however when one tag is inside the other the result is no formatting at all! The problem is that the match attribute of each xsl:template tag is only neing applied to B and EM tags in the BODY, is there any way I can apply the B and EM templates to the BODY and to all infinetly deeper nesting levels? Thanks! MrWolfy :-D

    L F 2 Replies Last reply
    0
    • S Saul Johnson

      Hi All! I need to emulate the HTML <B> and <EM> tags complete with all attributes and event handlers for a little project of mine and everything works fine when these elements are seperate, Here's my xsl stylesheet:

      <?xml version="1.0"?>
      <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

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

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

      </xsl:stylesheet>

      Now this works fine when <B> and <EM> are seperate, however when one tag is inside the other the result is no formatting at all! The problem is that the match attribute of each xsl:template tag is only neing applied to B and EM tags in the BODY, is there any way I can apply the B and EM templates to the BODY and to all infinetly deeper nesting levels? Thanks! MrWolfy :-D

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      MrWolfy wrote:

      the result is no formatting at all!

      No formatting in what? A Browser? If so, looking at your XSL isn't helping us at all. Post the HTML that is not rendering correctly and the browser version you are using.

      led mike

      1 Reply Last reply
      0
      • S Saul Johnson

        Hi All! I need to emulate the HTML <B> and <EM> tags complete with all attributes and event handlers for a little project of mine and everything works fine when these elements are seperate, Here's my xsl stylesheet:

        <?xml version="1.0"?>
        <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

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

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

        </xsl:stylesheet>

        Now this works fine when <B> and <EM> are seperate, however when one tag is inside the other the result is no formatting at all! The problem is that the match attribute of each xsl:template tag is only neing applied to B and EM tags in the BODY, is there any way I can apply the B and EM templates to the BODY and to all infinetly deeper nesting levels? Thanks! MrWolfy :-D

        F Offline
        F Offline
        Frank Horn
        wrote on last edited by
        #3
        S L 2 Replies Last reply
        0
        • F Frank Horn
          S Offline
          S Offline
          Saul Johnson
          wrote on last edited by
          #4

          Hi and Thanks! Thanks Frank! The code works perfectly! Problem Solved! Thanks Again! MrWolfy :-D

          F 1 Reply Last reply
          0
          • S Saul Johnson

            Hi and Thanks! Thanks Frank! The code works perfectly! Problem Solved! Thanks Again! MrWolfy :-D

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

            You're welcome. In case you can read German or French, this is where I learnt it all: http://selfhtml.org/ I hardly ever use websites in my native language when it comes to software development cause anglophone sites are abundant and (when they have a forum) well populated, but this one is so good I took it on as my default HTML and XSL reference.

            1 Reply Last reply
            0
            • F Frank Horn
              L Offline
              L Offline
              led mike
              wrote on last edited by
              #6

              wow, I did not understand that was what he was asking at all. :omg: Nice catch!

              led mike

              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